Skip to content

Commit 75fe517

Browse files
committed
Merge branch 'release/0.27.17/master'
2 parents da0adff + de3f7a8 commit 75fe517

File tree

7 files changed

+118
-5
lines changed

7 files changed

+118
-5
lines changed

CHANGES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## Changes in 0.27.17 (2024-12-10)
2+
3+
No significant changes.
4+
5+
16
## Changes in 0.27.16 (2024-11-12)
27

38
No significant changes.

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ GEM
275275
concurrent-ruby (~> 1.0)
276276
uber (0.1.0)
277277
unicode-display_width (2.5.0)
278-
webrick (1.8.1)
278+
webrick (1.9.0)
279279
word_wrap (1.0.0)
280280
xcode-install (2.8.1)
281281
claide (>= 0.9.1)

MatrixSDK.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22

33
s.name = "MatrixSDK"
4-
s.version = "0.27.16"
4+
s.version = "0.27.17"
55
s.summary = "The iOS SDK to build apps compatible with Matrix (https://www.matrix.org)"
66

77
s.description = <<-DESC

MatrixSDK/Crypto/SecretStorage/MXSecretStorage.m

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@
1818

1919
#import "MXSession.h"
2020
#import "MXTools.h"
21+
#import "MXKeyBackupPassword.h"
2122
#import "MXRecoveryKey.h"
2223
#import "MXHkdfSha256.h"
2324
#import "MXAesHmacSha2.h"
2425
#import "MXBase64Tools.h"
2526
#import "MXEncryptedSecretContent.h"
2627

28+
#import <Security/Security.h>
2729

2830
#pragma mark - Constants
2931

@@ -126,6 +128,112 @@ - (MXHTTPOperation*)createKeyWithKeyId:(nullable NSString*)keyId
126128
return operation;
127129
}
128130

131+
- (MXHTTPOperation*)createKeyWithKeyId:(nullable NSString*)keyId
132+
keyName:(nullable NSString*)keyName
133+
passphrase:(nullable NSString*)passphrase
134+
success:(void (^)(MXSecretStorageKeyCreationInfo *keyCreationInfo))success
135+
failure:(void (^)(NSError *error))failure
136+
{
137+
MXLogDebug(@"[MXSecretStorage] createKeyWithKeyId: Creating new key with passphrase");
138+
keyId = keyId ?: [[NSUUID UUID] UUIDString];
139+
140+
MXHTTPOperation *operation = [MXHTTPOperation new];
141+
142+
MXWeakify(self);
143+
dispatch_async(processingQueue, ^{
144+
MXStrongifyAndReturnIfNil(self);
145+
146+
NSError *error;
147+
148+
NSData *privateKey;
149+
MXSecretStoragePassphrase *passphraseInfo;
150+
151+
if (passphrase)
152+
{
153+
// Generate a private key from the passphrase
154+
NSString *salt;
155+
NSUInteger iterations;
156+
privateKey = [MXKeyBackupPassword generatePrivateKeyWithPassword:passphrase
157+
salt:&salt
158+
iterations:&iterations
159+
error:&error];
160+
if (!error)
161+
{
162+
passphraseInfo = [MXSecretStoragePassphrase new];
163+
passphraseInfo.algorithm = @"m.pbkdf2";
164+
passphraseInfo.salt = salt;
165+
passphraseInfo.iterations = iterations;
166+
}
167+
}
168+
else
169+
{
170+
uint8_t randomBytes[32];
171+
OSStatus status = SecRandomCopyBytes(kSecRandomDefault, sizeof(randomBytes), randomBytes);
172+
173+
if (status == errSecSuccess)
174+
{
175+
privateKey = [NSData dataWithBytes:randomBytes length:sizeof(randomBytes)];
176+
}
177+
else
178+
{
179+
MXLogDebug(@"Failed to generate random bytes with error: %d", (int)status);
180+
}
181+
}
182+
183+
if (error)
184+
{
185+
dispatch_async(dispatch_get_main_queue(), ^{
186+
MXLogDebug(@"[MXSecretStorage] createKeyWithKeyId: Failed to create a new key - %@", error);
187+
failure(error);
188+
});
189+
return;
190+
}
191+
192+
// Build iv and mac
193+
MXEncryptedSecretContent *encryptedZeroString = [self encryptedZeroStringWithPrivateKey:privateKey iv:nil error:&error];
194+
if (error)
195+
{
196+
dispatch_async(dispatch_get_main_queue(), ^{
197+
MXLogDebug(@"[MXSecretStorage] createKeyWithKeyId: Failed to create a new key - %@", error);
198+
failure(error);
199+
});
200+
return;
201+
}
202+
203+
MXSecretStorageKeyContent *ssssKeyContent = [MXSecretStorageKeyContent new];
204+
ssssKeyContent.name = keyName;
205+
ssssKeyContent.algorithm = MXSecretStorageKeyAlgorithm.aesHmacSha2;
206+
ssssKeyContent.passphrase = passphraseInfo;
207+
ssssKeyContent.iv = encryptedZeroString.iv;
208+
ssssKeyContent.mac = encryptedZeroString.mac;
209+
210+
NSString *accountDataId = [self storageKeyIdForKey:keyId];
211+
MXHTTPOperation *operation2 = [self setAccountData:ssssKeyContent.JSONDictionary forType:accountDataId success:^{
212+
213+
MXSecretStorageKeyCreationInfo *keyCreationInfo = [MXSecretStorageKeyCreationInfo new];
214+
keyCreationInfo.keyId = keyId;
215+
keyCreationInfo.content = ssssKeyContent;
216+
keyCreationInfo.privateKey = privateKey;
217+
keyCreationInfo.recoveryKey = [MXRecoveryKey encode:privateKey];
218+
219+
dispatch_async(dispatch_get_main_queue(), ^{
220+
MXLogDebug(@"[MXSecretStorage] createKeyWithKeyId: Successfully created a new key");
221+
success(keyCreationInfo);
222+
});
223+
224+
} failure:^(NSError *error) {
225+
dispatch_async(dispatch_get_main_queue(), ^{
226+
MXLogDebug(@"[MXSecretStorage] createKeyWithKeyId: Failed to create a new key - %@", error);
227+
failure(error);
228+
});
229+
}];
230+
231+
[operation mutateTo:operation2];
232+
});
233+
234+
return operation;
235+
}
236+
129237
- (MXHTTPOperation*)deleteKeyWithKeyId:(nullable NSString*)keyId
130238
success:(void (^)(void))success
131239
failure:(void (^)(NSError *error))failure

MatrixSDK/MXRestClient.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3103,7 +3103,7 @@ -(MXHTTPOperation *)reportRoom:(NSString *)roomId
31033103
success:(void (^)(void))success
31043104
failure:(void (^)(NSError *))failure
31053105
{
3106-
NSString *path = [NSString stringWithFormat:@"%@/org.matrix.msc4151/rooms/%@/report", kMXAPIPrefixPathUnstable, roomId];
3106+
NSString *path = [NSString stringWithFormat:@"%@/rooms/%@/report", kMXAPIPrefixPathV3, roomId];
31073107

31083108
NSDictionary *parameters = @{ @"reason": reason.length > 0 ? reason : @"" };
31093109

MatrixSDK/MatrixSDKVersion.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616

1717
#import <Foundation/Foundation.h>
1818

19-
NSString *const MatrixSDKVersion = @"0.27.16";
19+
NSString *const MatrixSDKVersion = @"0.27.17";

Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,4 @@ SPEC CHECKSUMS:
6565

6666
PODFILE CHECKSUM: a2fe7b4dcd95b04f52989dc47cded48c782c02a4
6767

68-
COCOAPODS: 1.15.2
68+
COCOAPODS: 1.14.3

0 commit comments

Comments
 (0)