From ec306bfc1f4cd8a5a3f4fdbdee58ef4ab5b23172 Mon Sep 17 00:00:00 2001 From: ismailgulek Date: Thu, 11 Aug 2022 13:52:01 +0300 Subject: [PATCH 1/3] Adapt api changes from key backup module --- .../KeyBackup/Recover/KeyBackupRecoverCoordinator.swift | 2 +- Riot/Modules/KeyBackup/Setup/KeyBackupSetupCoordinator.swift | 2 +- .../Setup/Passphrase/KeyBackupSetupPassphraseViewModel.swift | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Riot/Modules/KeyBackup/Recover/KeyBackupRecoverCoordinator.swift b/Riot/Modules/KeyBackup/Recover/KeyBackupRecoverCoordinator.swift index e12cb2e691..d7d0a9a312 100644 --- a/Riot/Modules/KeyBackup/Recover/KeyBackupRecoverCoordinator.swift +++ b/Riot/Modules/KeyBackup/Recover/KeyBackupRecoverCoordinator.swift @@ -84,7 +84,7 @@ final class KeyBackupRecoverCoordinator: KeyBackupRecoverCoordinatorType { let coordinator: Coordinator & Presentable // Check if a passphrase has been set for given backup - if let megolmBackupAuthData = MXMegolmBackupAuthData(fromJSON: self.keyBackupVersion.authData), megolmBackupAuthData.privateKeySalt != nil { + if self.keyBackupVersion.authData["private_key_salt"] != nil { coordinator = self.createRecoverFromPassphraseCoordinator() } else { coordinator = self.createRecoverFromRecoveryKeyCoordinator() diff --git a/Riot/Modules/KeyBackup/Setup/KeyBackupSetupCoordinator.swift b/Riot/Modules/KeyBackup/Setup/KeyBackupSetupCoordinator.swift index c14c562726..03171ebd2a 100644 --- a/Riot/Modules/KeyBackup/Setup/KeyBackupSetupCoordinator.swift +++ b/Riot/Modules/KeyBackup/Setup/KeyBackupSetupCoordinator.swift @@ -134,7 +134,7 @@ final class KeyBackupSetupCoordinator: KeyBackupSetupCoordinatorType { return } - keyBackup.prepareKeyBackupVersion(withPassword: nil, success: { megolmBackupCreationInfo in + keyBackup.prepareKeyBackupVersion(withPassword: nil, algorithm: nil, success: { megolmBackupCreationInfo in keyBackup.createKeyBackupVersion(megolmBackupCreationInfo, success: { _ in recoveryService.updateRecovery(forSecrets: [MXSecretId.keyBackup.takeUnretainedValue() as String], withPrivateKey: privateKey) { completion(.success(Void())) diff --git a/Riot/Modules/KeyBackup/Setup/Passphrase/KeyBackupSetupPassphraseViewModel.swift b/Riot/Modules/KeyBackup/Setup/Passphrase/KeyBackupSetupPassphraseViewModel.swift index ea2fd47524..b2dd9163c4 100644 --- a/Riot/Modules/KeyBackup/Setup/Passphrase/KeyBackupSetupPassphraseViewModel.swift +++ b/Riot/Modules/KeyBackup/Setup/Passphrase/KeyBackupSetupPassphraseViewModel.swift @@ -96,7 +96,7 @@ final class KeyBackupSetupPassphraseViewModel: KeyBackupSetupPassphraseViewModel self.update(viewState: .loading) - self.keyBackup.prepareKeyBackupVersion(withPassword: passphrase, success: { [weak self] (megolmBackupCreationInfo) in + self.keyBackup.prepareKeyBackupVersion(withPassword: passphrase, algorithm: nil, success: { [weak self] (megolmBackupCreationInfo) in guard let sself = self else { return } @@ -122,7 +122,7 @@ final class KeyBackupSetupPassphraseViewModel: KeyBackupSetupPassphraseViewModel private func setupRecoveryKey() { self.update(viewState: .loading) - self.keyBackup.prepareKeyBackupVersion(withPassword: nil, success: { [weak self] (megolmBackupCreationInfo) in + self.keyBackup.prepareKeyBackupVersion(withPassword: nil, algorithm: nil, success: { [weak self] (megolmBackupCreationInfo) in guard let sself = self else { return } From 067bd92f84f77edc3bbdd02081dd95437a8b770d Mon Sep 17 00:00:00 2001 From: ismailgulek Date: Thu, 11 Aug 2022 13:52:28 +0300 Subject: [PATCH 2/3] Add an entry for event untrusted status into the encryption info view --- .../Views/EncryptionInfoView/MXKEncryptionInfoView.m | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Riot/Modules/MatrixKit/Views/EncryptionInfoView/MXKEncryptionInfoView.m b/Riot/Modules/MatrixKit/Views/EncryptionInfoView/MXKEncryptionInfoView.m index 5ae061284b..cbaea4f845 100644 --- a/Riot/Modules/MatrixKit/Views/EncryptionInfoView/MXKEncryptionInfoView.m +++ b/Riot/Modules/MatrixKit/Views/EncryptionInfoView/MXKEncryptionInfoView.m @@ -192,6 +192,7 @@ - (void)updateTextViewText NSString *claimedKey = _mxEvent.keysClaimed[@"ed25519"]; NSString *algorithm = _mxEvent.wireContent[@"algorithm"]; NSString *sessionId = _mxEvent.wireContent[@"session_id"]; + NSString *untrusted = _mxEvent.isUntrusted ? [VectorL10n userVerificationSessionsListSessionUntrusted] : [VectorL10n userVerificationSessionsListSessionTrusted]; NSString *decryptionError; if (_mxEvent.decryptionError) @@ -277,6 +278,16 @@ - (void)updateTextViewText attributes:@{NSForegroundColorAttributeName: _defaultTextColor, NSFontAttributeName: [UIFont systemFontOfSize:14]}]]; [eventInformationString appendAttributedString:[MXKEncryptionInfoView verticalWhitespace]]; + + [eventInformationString appendAttributedString:[[NSMutableAttributedString alloc] + initWithString:[NSString stringWithFormat:@"%@\n", [VectorL10n sslTrust]] + attributes:@{NSForegroundColorAttributeName: _defaultTextColor, + NSFontAttributeName: [UIFont boldSystemFontOfSize:14]}]]; + [eventInformationString appendAttributedString:[[NSMutableAttributedString alloc] + initWithString:untrusted + attributes:@{NSForegroundColorAttributeName: _defaultTextColor, + NSFontAttributeName: [UIFont systemFontOfSize:14]}]]; + [eventInformationString appendAttributedString:[MXKEncryptionInfoView verticalWhitespace]]; [textViewAttributedString appendAttributedString:eventInformationString]; } From 971ecf0970563b16ba684a2dfb93fa1a5068a986 Mon Sep 17 00:00:00 2001 From: ismailgulek Date: Thu, 11 Aug 2022 13:54:46 +0300 Subject: [PATCH 3/3] Add changelog --- changelog.d/pr-6555.change | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/pr-6555.change diff --git a/changelog.d/pr-6555.change b/changelog.d/pr-6555.change new file mode 100644 index 0000000000..03a9c5ca5f --- /dev/null +++ b/changelog.d/pr-6555.change @@ -0,0 +1 @@ +KeyBackup: Adapt changes from sdk, add an entry into encryption info view of a message.