Skip to content

Commit 0c3ab70

Browse files
authored
Merge pull request #1853 from matrix-org/valere/bump_crypto_sdk_version_0.4.1
Bump rust crypto sdk version 0.4.1
2 parents 30d49a6 + 5b4382d commit 0c3ab70

File tree

13 files changed

+42
-34
lines changed

13 files changed

+42
-34
lines changed

MatrixSDK.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Pod::Spec.new do |s|
4545
ss.dependency 'OLMKit', '~> 3.2.5'
4646
ss.dependency 'Realm', '10.27.0'
4747
ss.dependency 'libbase58', '~> 0.1.4'
48-
ss.dependency 'MatrixSDKCrypto', '0.3.13', :configurations => ["DEBUG", "RELEASE"], :inhibit_warnings => true
48+
ss.dependency 'MatrixSDKCrypto', '0.4.1', :configurations => ["DEBUG", "RELEASE"], :inhibit_warnings => true
4949
end
5050

5151
s.subspec 'JingleCallStack' do |ss|

MatrixSDK/Crypto/CryptoMachine/MXCryptoMachine.swift

+7-2
Original file line numberDiff line numberDiff line change
@@ -591,9 +591,14 @@ extension MXCryptoMachine: MXCryptoCrossSigning {
591591

592592
func bootstrapCrossSigning(authParams: [AnyHashable: Any]) async throws {
593593
let result = try machine.bootstrapCrossSigning()
594+
// If this is called before the device keys have been uploaded there will be a
595+
// request to upload them, do that first.
596+
if let optionalKeyRequest = result.uploadKeysRequest {
597+
try await handleRequest(optionalKeyRequest)
598+
}
594599
let _ = try await [
595600
requests.uploadSigningKeys(request: result.uploadSigningKeysRequest, authParams: authParams),
596-
requests.uploadSignatures(request: result.signatureRequest)
601+
requests.uploadSignatures(request: result.uploadSignatureRequest)
597602
]
598603
}
599604

@@ -833,7 +838,7 @@ extension MXCryptoMachine: MXCryptoBackup {
833838
guard let message = MXCryptoTools.canonicalJSONString(forJSON: object) else {
834839
throw Error.cannotSerialize
835840
}
836-
return machine.sign(message: message)
841+
return try machine.sign(message: message)
837842
}
838843

839844
func backupRoomKeys() async throws {

MatrixSDK/Crypto/Dehydration/DehydrationService.swift

+9-9
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public class DehydrationService: NSObject {
6868
// Convert it back to Data
6969
let pickleKeyData = MXBase64Tools.data(fromBase64: base64PickleKey)
7070

71-
let rehydrationResult = await rehydrateDevice(pickleKeyData: [UInt8](pickleKeyData))
71+
let rehydrationResult = await rehydrateDevice(pickleKeyData: pickleKeyData)
7272
switch rehydrationResult {
7373
case .success((let deviceId, let rehydratedDevice)):
7474
// Fetch and process the to device events available on the dehydrated device
@@ -86,14 +86,14 @@ public class DehydrationService: NSObject {
8686
}
8787

8888
// Finally, create a new dehydrated device with the same pickle key
89-
try await dehydrateDevice(pickleKeyData: [UInt8](pickleKeyData))
89+
try await dehydrateDevice(pickleKeyData: pickleKeyData)
9090
} else { // Otherwise, generate a new dehydration pickle key, store it and dehydrate a device
9191
// Generate a new dehydration pickle key
92-
var pickleKeyData = [UInt8](repeating: 0, count: 32)
92+
var pickleKeyData = Data(count: 32)
9393
_ = SecRandomCopyBytes(kSecRandomDefault, 32, &pickleKeyData)
9494

9595
// Convert it to unpadded base 64
96-
let base64PickleKey = MXBase64Tools.unpaddedBase64(from: Data(bytes: pickleKeyData, count: 32))
96+
let base64PickleKey = MXBase64Tools.unpaddedBase64(from: pickleKeyData)
9797

9898
// Store it on the backend
9999
try await storeSecret(base64PickleKey, secretId: secretId, secretStorageKeys: [secretStorageKeyId: privateKeyData])
@@ -131,10 +131,10 @@ public class DehydrationService: NSObject {
131131

132132
// MARK: - Device dehydration
133133

134-
private func dehydrateDevice(pickleKeyData: [UInt8]) async throws {
135-
let dehydratedDevice = dehydratedDevices.create()
134+
private func dehydrateDevice(pickleKeyData: Data) async throws {
135+
let dehydratedDevice = try dehydratedDevices.create()
136136

137-
let requestDetails = try dehydratedDevice.keysForUpload(deviceDisplayName: deviceDisplayName, pickleKey: [UInt8](pickleKeyData))
137+
let requestDetails = try dehydratedDevice.keysForUpload(deviceDisplayName: deviceDisplayName, pickleKey: pickleKeyData)
138138

139139
let parameters = MXDehydratedDeviceCreationParameters()
140140
parameters.body = requestDetails.body
@@ -150,7 +150,7 @@ public class DehydrationService: NSObject {
150150
}
151151
}
152152

153-
private func rehydrateDevice(pickleKeyData: [UInt8]) async -> Result<(deviceId: String, rehydratedDevice: RehydratedDeviceProtocol), DehydrationServiceError> {
153+
private func rehydrateDevice(pickleKeyData: Data) async -> Result<(deviceId: String, rehydratedDevice: RehydratedDeviceProtocol), DehydrationServiceError> {
154154
await withCheckedContinuation { continuation in
155155
self.restClient.retrieveDehydratedDevice { [weak self] dehydratedDevice in
156156
guard let self else { return }
@@ -163,7 +163,7 @@ public class DehydrationService: NSObject {
163163
}
164164

165165
do {
166-
let rehydratedDevice = try self.dehydratedDevices.rehydrate(pickleKey: [UInt8](pickleKeyData), deviceId: dehydratedDevice.deviceId, deviceData: deviceDataJSON)
166+
let rehydratedDevice = try self.dehydratedDevices.rehydrate(pickleKey: pickleKeyData, deviceId: dehydratedDevice.deviceId, deviceData: deviceDataJSON)
167167
continuation.resume(returning: .success((dehydratedDevice.deviceId, rehydratedDevice)))
168168
} catch {
169169
continuation.resume(returning: .failure(DehydrationServiceError.failedRehydration(error)))

MatrixSDK/Crypto/Migration/Data/MXCryptoMigrationStore.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ struct MXCryptoMigrationStore {
5454
account: try pickledAccount(pickleKey: pickleKey),
5555
sessions: [], // Sessions are extracted in batches separately
5656
inboundGroupSessions: [], // Group sessions are extracted in batches separately
57-
pickleKey: [UInt8](pickleKey),
57+
pickleKey: pickleKey,
5858
backupVersion: legacyStore.backupVersion,
5959
backupRecoveryKey: backupRecoveryKey(),
6060
crossSigning: crossSigning(),
@@ -194,7 +194,7 @@ private extension PickledAccount {
194194
private extension PickledSession {
195195
init(session: MXOlmSession, pickleKey: Data) throws {
196196
let pickle = try session.session.serializeData(withKey: pickleKey)
197-
let time = "\(Int(session.lastReceivedMessageTs))"
197+
let time = UInt64(session.lastReceivedMessageTs)
198198

199199
self.init(
200200
pickle: pickle,

MatrixSDKTests/Crypto/CryptoMachine/Device+Stub.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ extension Device {
4141
isBlocked: isBlocked,
4242
locallyTrusted: locallyTrusted,
4343
crossSigningTrusted: crossSigningTrusted,
44-
firstTimeSeenTs: 0
44+
firstTimeSeenTs: 0,
45+
dehydrated: false
4546
)
4647
}
4748
}

MatrixSDKTests/Crypto/CryptoMachine/MXCryptoProtocolStubs.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ class CryptoCrossSigningStub: CryptoIdentityStub, MXCryptoCrossSigning {
143143
locallyTrusted: device.locallyTrusted,
144144
// Modify cross signing trusted
145145
crossSigningTrusted: true,
146-
firstTimeSeenTs: 0
146+
firstTimeSeenTs: 0,
147+
dehydrated: false
147148
)
148149
}
149150

MatrixSDKTests/Crypto/Migration/Data/MXCryptoMigrationStoreUnitTests.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ class MXCryptoMigrationStoreUnitTests: XCTestCase {
141141
XCTAssertEqual(sessions[0].pickle, pickle)
142142
XCTAssertEqual(sessions[0].senderKey, "XYZ")
143143
XCTAssertFalse(sessions[0].createdUsingFallbackKey)
144-
XCTAssertEqual(sessions[0].creationTime, "123")
145-
XCTAssertEqual(sessions[0].lastUseTime, "123")
144+
XCTAssertEqual(sessions[0].creationTime, 123)
145+
XCTAssertEqual(sessions[0].lastUseTime, 123)
146146
}
147147

148148
func test_extractsMultipleSessionsInBatches() throws {
@@ -235,7 +235,7 @@ class MXCryptoMigrationStoreUnitTests: XCTestCase {
235235
func test_extractsPickeKey() throws {
236236
let pickleKey = "some key".data(using: .ascii)!
237237
let key = try extractData(pickleKey: pickleKey).pickleKey
238-
XCTAssertEqual(key, [UInt8](pickleKey))
238+
XCTAssertEqual(key, pickleKey)
239239
}
240240

241241
func test_extractsCrossSigning() throws {

MatrixSDKTests/Crypto/Verification/Transactions/QRCode/QrCodeStub.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import Foundation
1818

1919
import MatrixSDKCrypto
2020

21-
struct QrCodeStub: QrCodeProtocol {
21+
class QrCodeStub: QrCodeProtocol {
2222
private let _otherUserId: String
2323
private let _otherDeviceId: String
2424
private let _flowId: String

MatrixSDKTests/Crypto/Verification/Transactions/SAS/SasStub.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import Foundation
1818

1919
import MatrixSDKCrypto
2020

21-
struct SasStub: SasProtocol {
21+
class SasStub: SasProtocol {
2222

2323
private let _otherUserId: String
2424
private let _otherDeviceId: String

Podfile

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ abstract_target 'MatrixSDK' do
1616

1717
pod 'Realm', '10.27.0'
1818
pod 'libbase58', '~> 0.1.4'
19-
pod 'MatrixSDKCrypto', "0.3.13", :inhibit_warnings => true
19+
pod 'MatrixSDKCrypto', '0.4.1', :inhibit_warnings => true
2020

2121
target 'MatrixSDK-iOS' do
22-
platform :ios, '11.0'
22+
platform :ios, '13.0'
2323

2424
target 'MatrixSDKTests-iOS' do
2525
inherit! :search_paths
@@ -28,7 +28,7 @@ abstract_target 'MatrixSDK' do
2828
end
2929

3030
target 'MatrixSDK-macOS' do
31-
platform :osx, '10.10'
31+
platform :osx, '10.15'
3232

3333
target 'MatrixSDKTests-macOS' do
3434
inherit! :search_paths
@@ -40,7 +40,7 @@ end
4040
post_install do |installer|
4141
installer.pods_project.targets.each do |target|
4242
target.build_configurations.each do |config|
43-
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
43+
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
4444
end
4545
end
4646
end

Podfile.lock

+7-7
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ PODS:
1414
- AFNetworking/Serialization (4.0.1)
1515
- AFNetworking/UIKit (4.0.1):
1616
- AFNetworking/NSURLSession
17-
- GZIP (1.3.0)
17+
- GZIP (1.3.2)
1818
- libbase58 (0.1.4)
19-
- MatrixSDKCrypto (0.3.13)
19+
- MatrixSDKCrypto (0.4.1)
2020
- OHHTTPStubs (9.1.0):
2121
- OHHTTPStubs/Default (= 9.1.0)
2222
- OHHTTPStubs/Core (9.1.0)
@@ -44,7 +44,7 @@ DEPENDENCIES:
4444
- AFNetworking (~> 4.0.0)
4545
- GZIP (~> 1.3.0)
4646
- libbase58 (~> 0.1.4)
47-
- MatrixSDKCrypto (= 0.3.13)
47+
- MatrixSDKCrypto (= 0.4.1)
4848
- OHHTTPStubs (~> 9.1.0)
4949
- OLMKit (~> 3.2.5)
5050
- Realm (= 10.27.0)
@@ -63,14 +63,14 @@ SPEC REPOS:
6363

6464
SPEC CHECKSUMS:
6565
AFNetworking: 3bd23d814e976cd148d7d44c3ab78017b744cd58
66-
GZIP: 416858efbe66b41b206895ac6dfd5493200d95b3
66+
GZIP: 3c0abf794bfce8c7cb34ea05a1837752416c8868
6767
libbase58: 7c040313537b8c44b6e2d15586af8e21f7354efd
68-
MatrixSDKCrypto: bf08b72f2cd015d8749420a2b8b92fc0536bedf4
68+
MatrixSDKCrypto: da2b8a81f7e1989fc61ff85ed6aad92332beeb40
6969
OHHTTPStubs: 90eac6d8f2c18317baeca36698523dc67c513831
7070
OLMKit: da115f16582e47626616874e20f7bb92222c7a51
7171
Realm: 9ca328bd7e700cc19703799785e37f77d1a130f2
7272
SwiftyBeaver: 84069991dd5dca07d7069100985badaca7f0ce82
7373

74-
PODFILE CHECKSUM: 1bf28f5a19566c567d265232f60ee19a3ae86ed3
74+
PODFILE CHECKSUM: bce6f6e7af7aa0ac9a50d4f6594d923fc00ed168
7575

76-
COCOAPODS: 1.14.3
76+
COCOAPODS: 1.15.2

build.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ pod install
88
if [ $1 == 'xcframework' ] # optionally supports additional arguments for CFBundleShortVersionString and CFBundleVersion
99
then
1010
# archive the framework for iOS, macOS, Catalyst and the Simulator
11-
xcodebuild archive -workspace MatrixSDK.xcworkspace -scheme MatrixSDK-iOS -destination "generic/platform=iOS" -archivePath build/MatrixSDK-iOS SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES IPHONEOS_DEPLOYMENT_TARGET=11.0 GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS=NO MARKETING_VERSION=$2 CURRENT_PROJECT_VERSION=$3
12-
xcodebuild archive -workspace MatrixSDK.xcworkspace -scheme MatrixSDK-iOS -destination "generic/platform=iOS Simulator" -archivePath build/MatrixSDK-iOSSimulator SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES IPHONEOS_DEPLOYMENT_TARGET=11.0 GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS=NO MARKETING_VERSION=$2 CURRENT_PROJECT_VERSION=$3
11+
xcodebuild archive -workspace MatrixSDK.xcworkspace -scheme MatrixSDK-iOS -destination "generic/platform=iOS" -archivePath build/MatrixSDK-iOS SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES IPHONEOS_DEPLOYMENT_TARGET=13.0 GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS=NO MARKETING_VERSION=$2 CURRENT_PROJECT_VERSION=$3
12+
xcodebuild archive -workspace MatrixSDK.xcworkspace -scheme MatrixSDK-iOS -destination "generic/platform=iOS Simulator" -archivePath build/MatrixSDK-iOSSimulator SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES IPHONEOS_DEPLOYMENT_TARGET=13.0 GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS=NO MARKETING_VERSION=$2 CURRENT_PROJECT_VERSION=$3
1313
xcodebuild archive -workspace MatrixSDK.xcworkspace -scheme MatrixSDK-macOS -destination "generic/platform=macOS" -archivePath build/MatrixSDK-macOS SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES MACOSX_DEPLOYMENT_TARGET=10.10 GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS=NO MARKETING_VERSION=$2 CURRENT_PROJECT_VERSION=$3
1414
xcodebuild archive -workspace MatrixSDK.xcworkspace -scheme MatrixSDK-iOS -destination "generic/platform=macOS,variant=Mac Catalyst" -archivePath ./build/MatrixSDK-MacCatalyst SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES IPHONEOS_DEPLOYMENT_TARGET=13.0 GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS=NO MARKETING_VERSION=$2 CURRENT_PROJECT_VERSION=$3
1515

changelog.d/pr-1853.change

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Crypto: Update crypto SDK to 0.4.1

0 commit comments

Comments
 (0)