From d3cd87b4fefd75941674ecd37bd466169057d2f9 Mon Sep 17 00:00:00 2001 From: Mauro Romito Date: Tue, 21 Mar 2023 14:45:53 +0100 Subject: [PATCH 1/6] Prepare for new sprint From f175e9ff987d68489833919c1ca0cb27d89f2296 Mon Sep 17 00:00:00 2001 From: Doug Date: Wed, 22 Mar 2023 17:05:07 +0000 Subject: [PATCH 2/6] Prepare for new sprint From ce07a80cbde2dff0e670eeaf5a8f6e3637c553d2 Mon Sep 17 00:00:00 2001 From: Andy Uhnak Date: Wed, 22 Mar 2023 19:03:14 +0000 Subject: [PATCH 3/6] Cross-signing does not depend on MSK --- .../CrossSigning/MXCrossSigningV2.swift | 24 +++++++++-- .../Migration/MXCryptoMigrationV2.swift | 20 +++++----- .../MXCrossSigningV2UnitTests.swift | 40 +++++++++++-------- .../Migration/MXCryptoMigrationV2Tests.swift | 2 +- 4 files changed, 57 insertions(+), 29 deletions(-) diff --git a/MatrixSDK/Crypto/CrossSigning/MXCrossSigningV2.swift b/MatrixSDK/Crypto/CrossSigning/MXCrossSigningV2.swift index 6fb1a7fb06..a9e17212b9 100644 --- a/MatrixSDK/Crypto/CrossSigning/MXCrossSigningV2.swift +++ b/MatrixSDK/Crypto/CrossSigning/MXCrossSigningV2.swift @@ -29,7 +29,8 @@ class MXCrossSigningV2: NSObject, MXCrossSigning { } if info.trustLevel.isVerified { - return hasAllPrivateKeys ? .canCrossSign : .trustCrossSigning + let status = crossSigning.crossSigningStatus() + return status.hasSelfSigning && status.hasUserSigning ? .canCrossSign : .trustCrossSigning } else { return .crossSigningExists } @@ -115,14 +116,14 @@ class MXCrossSigningV2: NSObject, MXCrossSigning { success: ((Bool) -> Void)?, failure: ((Swift.Error) -> Void)? = nil ) { - log.debug("->") + log.debug("Refreshing cross signing state, current state: \(state)") Task { do { try await crossSigning.refreshCrossSigningStatus() myUserCrossSigningKeys = infoSource.crossSigningInfo(userId: crossSigning.userId) - log.debug("Cross signing state refreshed") + log.debug("Cross signing state refreshed, new state: \(state)") await MainActor.run { success?(true) } @@ -231,3 +232,20 @@ extension MXCrossSigningV2: MXRecoveryServiceDelegate { signUser(withUserId: userId, success: success, failure: failure) } } + +extension MXCrossSigningState: CustomStringConvertible { + public var description: String { + switch self { + case .notBootstrapped: + return "notBootstrapped" + case .crossSigningExists: + return "crossSigningExists" + case .trustCrossSigning: + return "trustCrossSigning" + case .canCrossSign: + return "canCrossSign" + @unknown default: + return "unknown" + } + } +} diff --git a/MatrixSDK/Crypto/Migration/MXCryptoMigrationV2.swift b/MatrixSDK/Crypto/Migration/MXCryptoMigrationV2.swift index 3c047bffbf..4368ad68ea 100644 --- a/MatrixSDK/Crypto/Migration/MXCryptoMigrationV2.swift +++ b/MatrixSDK/Crypto/Migration/MXCryptoMigrationV2.swift @@ -58,15 +58,17 @@ class MXCryptoMigrationV2: NSObject { let details = """ Migration summary - - user id : \(data.account.userId) - - device id : \(data.account.deviceId) - - olm_sessions : \(store.olmSessionCount) - - megolm_sessions : \(store.megolmSessionCount) - - backup_key : \(data.backupRecoveryKey != nil ? "true" : "false") - - cross_signing : \(data.crossSigning.masterKey != nil ? "true" : "false") - - tracked_users : \(data.trackedUsers.count) - - room_settings : \(data.roomSettings.count) - - global_settings : \(store.globalSettings) + - user id : \(data.account.userId) + - device id : \(data.account.deviceId) + - olm_sessions : \(store.olmSessionCount) + - megolm_sessions : \(store.megolmSessionCount) + - backup_key : \(data.backupRecoveryKey != nil ? "true" : "false") + - master_key : \(data.crossSigning.masterKey != nil ? "true" : "false") + - user_signing_key : \(data.crossSigning.userSigningKey != nil ? "true" : "false") + - self_signing_key : \(data.crossSigning.selfSigningKey != nil ? "true" : "false") + - tracked_users : \(data.trackedUsers.count) + - room_settings : \(data.roomSettings.count) + - global_settings : \(store.globalSettings) """ log.debug(details) diff --git a/MatrixSDKTests/Crypto/CrossSigning/MXCrossSigningV2UnitTests.swift b/MatrixSDKTests/Crypto/CrossSigning/MXCrossSigningV2UnitTests.swift index 8ec65bab85..6f6a136046 100644 --- a/MatrixSDKTests/Crypto/CrossSigning/MXCrossSigningV2UnitTests.swift +++ b/MatrixSDKTests/Crypto/CrossSigning/MXCrossSigningV2UnitTests.swift @@ -76,23 +76,31 @@ class MXCrossSigningV2UnitTests: XCTestCase { waitForExpectations(timeout: 1) } - func test_state_canCrossSign() { - let exp = expectation(description: "exp") - crypto.stubbedStatus = CrossSigningStatus(hasMaster: true, hasSelfSigning: true, hasUserSigning: true) - crypto.stubbedVerifiedUsers = ["Alice"] - crypto.stubbedIdentities = [ - "Alice": .own( - userId: "Alice", - trustsOurOwnDevice: true, - masterKey: "", - selfSigningKey: "", - userSigningKey: "" - ) + func test_state_canCrossSign() async throws { + let statusToState: [(CrossSigningStatus, MXCrossSigningState)] = [ + (.init(hasMaster: false, hasSelfSigning: false, hasUserSigning: false), .trustCrossSigning), + (.init(hasMaster: true, hasSelfSigning: false, hasUserSigning: false), .trustCrossSigning), + (.init(hasMaster: false, hasSelfSigning: true, hasUserSigning: false), .trustCrossSigning), + (.init(hasMaster: false, hasSelfSigning: false, hasUserSigning: true), .trustCrossSigning), + (.init(hasMaster: false, hasSelfSigning: true, hasUserSigning: true), .canCrossSign), + (.init(hasMaster: true, hasSelfSigning: true, hasUserSigning: true), .canCrossSign), ] - crossSigning.refreshState { _ in - XCTAssertEqual(self.crossSigning.state, .canCrossSign) - exp.fulfill() + + for (status, state) in statusToState { + crypto.stubbedStatus = status + crypto.stubbedVerifiedUsers = ["Alice"] + crypto.stubbedIdentities = [ + "Alice": .own( + userId: "Alice", + trustsOurOwnDevice: true, + masterKey: "", + selfSigningKey: "", + userSigningKey: "" + ) + ] + + try await crossSigning.refreshState() + XCTAssertEqual(self.crossSigning.state, state, "Status: \(status)") } - waitForExpectations(timeout: 1) } } diff --git a/MatrixSDKTests/Crypto/Migration/MXCryptoMigrationV2Tests.swift b/MatrixSDKTests/Crypto/Migration/MXCryptoMigrationV2Tests.swift index 39793b0718..610df0d709 100644 --- a/MatrixSDKTests/Crypto/Migration/MXCryptoMigrationV2Tests.swift +++ b/MatrixSDKTests/Crypto/Migration/MXCryptoMigrationV2Tests.swift @@ -266,7 +266,7 @@ private extension MXCrypto { } } -private extension MXCrossSigning { +extension MXCrossSigning { func refreshState() async throws { return try await withCheckedThrowingContinuation { continuation in refreshState { _ in From e29fcbffc34af6327e42270915833c4da0267982 Mon Sep 17 00:00:00 2001 From: Andy Uhnak Date: Wed, 22 Mar 2023 19:21:48 +0000 Subject: [PATCH 4/6] version++ --- CHANGES.md | 5 +++++ MatrixSDK.podspec | 2 +- MatrixSDK/MatrixSDKVersion.m | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 423b5033cc..fac1026f1f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,8 @@ +## Changes in 0.26.4 (2023-03-22) + +No significant changes. + + ## Changes in 0.26.3 (2023-03-22) No significant changes. diff --git a/MatrixSDK.podspec b/MatrixSDK.podspec index a03a2338cc..a02d802d46 100644 --- a/MatrixSDK.podspec +++ b/MatrixSDK.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "MatrixSDK" - s.version = "0.26.3" + s.version = "0.26.4" s.summary = "The iOS SDK to build apps compatible with Matrix (https://www.matrix.org)" s.description = <<-DESC diff --git a/MatrixSDK/MatrixSDKVersion.m b/MatrixSDK/MatrixSDKVersion.m index 7a5f2ae7df..6e033991a6 100644 --- a/MatrixSDK/MatrixSDKVersion.m +++ b/MatrixSDK/MatrixSDKVersion.m @@ -16,4 +16,4 @@ #import -NSString *const MatrixSDKVersion = @"0.26.3"; +NSString *const MatrixSDKVersion = @"0.26.4"; From 099a0f7b6b4cb52db0b10b868b859b25c1f04eab Mon Sep 17 00:00:00 2001 From: Andy Uhnak Date: Wed, 22 Mar 2023 20:09:30 +0000 Subject: [PATCH 5/6] Manual changelog --- CHANGES.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index fac1026f1f..47cfb67dbf 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,8 @@ ## Changes in 0.26.4 (2023-03-22) -No significant changes. +🐛 Bugfixes + +- Crypto: Do not show current session as unverified ([#7446](https://github.com/vector-im/element-ios/issues/7446)) ## Changes in 0.26.3 (2023-03-22) From 7ddf9951521a3c6b75ea3d343f6a5e6b1d7276f8 Mon Sep 17 00:00:00 2001 From: Andy Uhnak Date: Wed, 22 Mar 2023 20:10:44 +0000 Subject: [PATCH 6/6] finish version++