diff --git a/lib/encryption/key_manager.dart b/lib/encryption/key_manager.dart index 1dc9501f..76147406 100644 --- a/lib/encryption/key_manager.dart +++ b/lib/encryption/key_manager.dart @@ -640,8 +640,10 @@ class KeyManager { final sessionData = session.sessionData; Map? decrypted; try { - decrypted = json.decode(decryption.decrypt(sessionData['ephemeral'], - sessionData['mac'], sessionData['ciphertext'])); + decrypted = json.decode(decryption.decrypt( + sessionData['ephemeral'] as String, + sessionData['mac'] as String, + sessionData['ciphertext'] as String)); } catch (e, s) { Logs().e('[LibOlm] Error decrypting room key', e, s); } diff --git a/lib/encryption/olm_manager.dart b/lib/encryption/olm_manager.dart index e17618b2..5d53441a 100644 --- a/lib/encryption/olm_manager.dart +++ b/lib/encryption/olm_manager.dart @@ -597,34 +597,36 @@ class OlmManager { client.userDeviceKeys[userId]!.deviceKeys[deviceId]!.ed25519Key; final identityKey = client.userDeviceKeys[userId]!.deviceKeys[deviceId]!.curve25519Key; - for (final Map deviceKey - in deviceKeysEntry.value.values) { - if (fingerprintKey == null || - identityKey == null || - !deviceKey.checkJsonSignature(fingerprintKey, userId, deviceId)) { - Logs().w( - 'Skipping invalid device key from $userId:$deviceId', - deviceKey, - ); - continue; - } - Logs().v('[OlmManager] Starting session with $userId:$deviceId'); - final session = olm.Session(); - try { - session.create_outbound( - _olmAccount!, identityKey, deviceKey['key']); - await storeOlmSession(OlmSession( - key: client.userID!, - identityKey: identityKey, - sessionId: session.session_id(), - session: session, - lastReceived: - DateTime.now(), // we want to use a newly created session - )); - } catch (e, s) { - session.free(); - Logs() - .e('[LibOlm] Could not create new outbound olm session', e, s); + for (final deviceKey in deviceKeysEntry.value.values) { + if (deviceKey is Map) { + if (fingerprintKey == null || + identityKey == null || + !deviceKey.checkJsonSignature( + fingerprintKey, userId, deviceId)) { + Logs().w( + 'Skipping invalid device key from $userId:$deviceId', + deviceKey, + ); + continue; + } + Logs().v('[OlmManager] Starting session with $userId:$deviceId'); + final session = olm.Session(); + try { + session.create_outbound( + _olmAccount!, identityKey, deviceKey['key'] as String); + await storeOlmSession(OlmSession( + key: client.userID!, + identityKey: identityKey, + sessionId: session.session_id(), + session: session, + lastReceived: + DateTime.now(), // we want to use a newly created session + )); + } catch (e, s) { + session.free(); + Logs().e( + '[LibOlm] Could not create new outbound olm session', e, s); + } } } }