diff --git a/lib/encryption/key_manager.dart b/lib/encryption/key_manager.dart
index 32ab983f..e17faf9a 100644
--- a/lib/encryption/key_manager.dart
+++ b/lib/encryption/key_manager.dart
@@ -47,8 +47,12 @@ class KeyManager {
if (!(info.authData is RoomKeysAuthDataV1Curve25519AesSha2)) {
return false;
}
- return keyObj.init_with_private_key(base64.decode(secret)) ==
- (info.authData as RoomKeysAuthDataV1Curve25519AesSha2).publicKey;
+ if (keyObj.init_with_private_key(base64.decode(secret)) ==
+ (info.authData as RoomKeysAuthDataV1Curve25519AesSha2).publicKey) {
+ _requestedSessionIds.clear();
+ return true;
+ }
+ return false;
} catch (_) {
return false;
} finally {
@@ -399,7 +403,6 @@ class KeyManager {
var hadPreviously =
getInboundGroupSession(room.id, sessionId, senderKey) != null;
try {
- print('FETCHING FROM KEY STORE...');
await loadSingleKey(room.id, sessionId);
} catch (err, stacktrace) {
print('++++++++++++++++++');
@@ -408,7 +411,6 @@ class KeyManager {
}
if (!hadPreviously &&
getInboundGroupSession(room.id, sessionId, senderKey) != null) {
- print('GOT FROM KEY STORE, SUCCESS!!!!!');
return; // we managed to load the session from online backup, no need to care about it now
}
// while we just send the to-device event to '*', we still need to save the
diff --git a/lib/encryption/utils/key_verification.dart b/lib/encryption/utils/key_verification.dart
index 638c7249..dacc4e59 100644
--- a/lib/encryption/utils/key_verification.dart
+++ b/lib/encryption/utils/key_verification.dart
@@ -16,6 +16,7 @@
* along with this program. If not, see .
*/
+import 'dart:async';
import 'dart:typed_data';
import 'package:canonical_json/canonical_json.dart';
import 'package:pedantic/pedantic.dart';
@@ -403,6 +404,27 @@ class KeyVerification {
return [];
}
+ Future maybeRequestSSSSSecrets([int i = 0]) async {
+ final requestInterval = [10, 60];
+ print('Attempting to request ssss secrets...');
+ if ((!encryption.crossSigning.enabled ||
+ (encryption.crossSigning.enabled &&
+ (await encryption.crossSigning.isCached()))) &&
+ (!encryption.keyManager.enabled ||
+ (encryption.keyManager.enabled &&
+ (await encryption.keyManager.isCached())))) {
+ // no need to request cache, we already have it
+ print('Not needed, we already have them');
+ return;
+ }
+ unawaited(encryption.ssss.maybeRequestAll(
+ _verifiedDevices.whereType().toList()));
+ if (requestInterval.length >= i) {
+ return;
+ }
+ Timer(Duration(seconds: requestInterval[i]), () => maybeRequestSSSSSecrets(i + 1));
+ }
+
Future verifyKeys(Map keys,
Future Function(String, SignableKey) verifier) async {
_verifiedDevices = [];
@@ -437,8 +459,7 @@ class KeyVerification {
if (verifiedMasterKey && userId == client.userID) {
// it was our own master key, let's request the cross signing keys
// we do it in the background, thus no await needed here
- unawaited(encryption.ssss
- .maybeRequestAll(_verifiedDevices.whereType().toList()));
+ unawaited(maybeRequestSSSSSecrets());
}
await send('m.key.verification.done', {});