From 8f37466295398c87f9a84c0c399c9a2e05f2c630 Mon Sep 17 00:00:00 2001 From: Reza Date: Thu, 24 Nov 2022 09:33:36 +0100 Subject: [PATCH] fix: minor stuff --- lib/encryption/utils/key_verification.dart | 12 +++++++----- lib/src/utils/device_keys_list.dart | 8 ++++---- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/encryption/utils/key_verification.dart b/lib/encryption/utils/key_verification.dart index 4d85dcc6..1a125524 100644 --- a/lib/encryption/utils/key_verification.dart +++ b/lib/encryption/utils/key_verification.dart @@ -643,11 +643,13 @@ class KeyVerification { .map((device) => device.deviceId) .toList() .contains(key)); - await client.sendToDeviceEncrypted( - deviceKeys!.values.toList(), - type, - payload, - ); + if (deviceKeys != null && deviceKeys.isNotEmpty) { + await client.sendToDeviceEncrypted( + deviceKeys.values.toList(), + type, + payload, + ); + } } } else { Logs().e( diff --git a/lib/src/utils/device_keys_list.dart b/lib/src/utils/device_keys_list.dart index f26cc4e1..1e0ec099 100644 --- a/lib/src/utils/device_keys_list.dart +++ b/lib/src/utils/device_keys_list.dart @@ -225,7 +225,7 @@ abstract class SignableKey extends MatrixSignableKey { Set? onlyValidateUserIds, /// Only check if this key is verified by any Master key. - bool verifiedByAnyMasterKey = false, + bool verifiedByTheirMasterKey = false, }) { if (!client.encryptionEnabled) { return false; @@ -307,16 +307,16 @@ abstract class SignableKey extends MatrixSignableKey { if ((verifiedOnly && key.directVerified) || (key is CrossSigningKey && key.usage.contains('master') && - (verifiedByAnyMasterKey || + (verifiedByTheirMasterKey || (key.directVerified && key.userId == client.userID)))) { return true; // we verified this key and it is valid...all checks out! } - // or else we just recurse into that key and chack if it works out + // or else we just recurse into that key and check if it works out final haveChain = key.hasValidSignatureChain( verifiedOnly: verifiedOnly, visited: visited_, onlyValidateUserIds: onlyValidateUserIds, - verifiedByAnyMasterKey: verifiedByAnyMasterKey); + verifiedByTheirMasterKey: verifiedByTheirMasterKey); if (haveChain) { return true; }