Skip to content

Commit 15fe3fb

Browse files
committed
Bump rust crypto sdk version 0.4.1
1 parent 30d49a6 commit 15fe3fb

File tree

5 files changed

+21
-16
lines changed

5 files changed

+21
-16
lines changed

MatrixSDK.podspec

Lines changed: 1 addition & 1 deletion
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

Lines changed: 7 additions & 2 deletions
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

Lines changed: 9 additions & 9 deletions
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

Lines changed: 2 additions & 2 deletions
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,

Podfile

Lines changed: 2 additions & 2 deletions
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

0 commit comments

Comments
 (0)