Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 0.27.17 #1893

Merged
merged 9 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## Changes in 0.27.17 (2024-12-10)

No significant changes.


## Changes in 0.27.16 (2024-11-12)

No significant changes.
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ GEM
concurrent-ruby (~> 1.0)
uber (0.1.0)
unicode-display_width (2.5.0)
webrick (1.8.1)
webrick (1.9.0)
word_wrap (1.0.0)
xcode-install (2.8.1)
claide (>= 0.9.1)
Expand Down
2 changes: 1 addition & 1 deletion MatrixSDK.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

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

s.description = <<-DESC
Expand Down
108 changes: 108 additions & 0 deletions MatrixSDK/Crypto/SecretStorage/MXSecretStorage.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@

#import "MXSession.h"
#import "MXTools.h"
#import "MXKeyBackupPassword.h"
#import "MXRecoveryKey.h"
#import "MXHkdfSha256.h"
#import "MXAesHmacSha2.h"
#import "MXBase64Tools.h"
#import "MXEncryptedSecretContent.h"

#import <Security/Security.h>

#pragma mark - Constants

Expand Down Expand Up @@ -126,6 +128,112 @@ - (MXHTTPOperation*)createKeyWithKeyId:(nullable NSString*)keyId
return operation;
}

- (MXHTTPOperation*)createKeyWithKeyId:(nullable NSString*)keyId
keyName:(nullable NSString*)keyName
passphrase:(nullable NSString*)passphrase
success:(void (^)(MXSecretStorageKeyCreationInfo *keyCreationInfo))success
failure:(void (^)(NSError *error))failure
{
MXLogDebug(@"[MXSecretStorage] createKeyWithKeyId: Creating new key with passphrase");
keyId = keyId ?: [[NSUUID UUID] UUIDString];

MXHTTPOperation *operation = [MXHTTPOperation new];

MXWeakify(self);
dispatch_async(processingQueue, ^{
MXStrongifyAndReturnIfNil(self);

NSError *error;

NSData *privateKey;
MXSecretStoragePassphrase *passphraseInfo;

if (passphrase)
{
// Generate a private key from the passphrase
NSString *salt;
NSUInteger iterations;
privateKey = [MXKeyBackupPassword generatePrivateKeyWithPassword:passphrase
salt:&salt
iterations:&iterations
error:&error];
if (!error)
{
passphraseInfo = [MXSecretStoragePassphrase new];
passphraseInfo.algorithm = @"m.pbkdf2";
passphraseInfo.salt = salt;
passphraseInfo.iterations = iterations;
}
}
else
{
uint8_t randomBytes[32];
OSStatus status = SecRandomCopyBytes(kSecRandomDefault, sizeof(randomBytes), randomBytes);

if (status == errSecSuccess)
{
privateKey = [NSData dataWithBytes:randomBytes length:sizeof(randomBytes)];
}
else
{
MXLogDebug(@"Failed to generate random bytes with error: %d", (int)status);
}
}

if (error)
{
dispatch_async(dispatch_get_main_queue(), ^{
MXLogDebug(@"[MXSecretStorage] createKeyWithKeyId: Failed to create a new key - %@", error);
failure(error);
});
return;
}

// Build iv and mac
MXEncryptedSecretContent *encryptedZeroString = [self encryptedZeroStringWithPrivateKey:privateKey iv:nil error:&error];
if (error)
{
dispatch_async(dispatch_get_main_queue(), ^{
MXLogDebug(@"[MXSecretStorage] createKeyWithKeyId: Failed to create a new key - %@", error);
failure(error);
});
return;
}

MXSecretStorageKeyContent *ssssKeyContent = [MXSecretStorageKeyContent new];
ssssKeyContent.name = keyName;
ssssKeyContent.algorithm = MXSecretStorageKeyAlgorithm.aesHmacSha2;
ssssKeyContent.passphrase = passphraseInfo;
ssssKeyContent.iv = encryptedZeroString.iv;
ssssKeyContent.mac = encryptedZeroString.mac;

NSString *accountDataId = [self storageKeyIdForKey:keyId];
MXHTTPOperation *operation2 = [self setAccountData:ssssKeyContent.JSONDictionary forType:accountDataId success:^{

MXSecretStorageKeyCreationInfo *keyCreationInfo = [MXSecretStorageKeyCreationInfo new];
keyCreationInfo.keyId = keyId;
keyCreationInfo.content = ssssKeyContent;
keyCreationInfo.privateKey = privateKey;
keyCreationInfo.recoveryKey = [MXRecoveryKey encode:privateKey];

dispatch_async(dispatch_get_main_queue(), ^{
MXLogDebug(@"[MXSecretStorage] createKeyWithKeyId: Successfully created a new key");
success(keyCreationInfo);
});

} failure:^(NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
MXLogDebug(@"[MXSecretStorage] createKeyWithKeyId: Failed to create a new key - %@", error);
failure(error);
});
}];

[operation mutateTo:operation2];
});

return operation;
}

- (MXHTTPOperation*)deleteKeyWithKeyId:(nullable NSString*)keyId
success:(void (^)(void))success
failure:(void (^)(NSError *error))failure
Expand Down
2 changes: 1 addition & 1 deletion MatrixSDK/MXRestClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -3103,7 +3103,7 @@ -(MXHTTPOperation *)reportRoom:(NSString *)roomId
success:(void (^)(void))success
failure:(void (^)(NSError *))failure
{
NSString *path = [NSString stringWithFormat:@"%@/org.matrix.msc4151/rooms/%@/report", kMXAPIPrefixPathUnstable, roomId];
NSString *path = [NSString stringWithFormat:@"%@/rooms/%@/report", kMXAPIPrefixPathV3, roomId];

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

Expand Down
2 changes: 1 addition & 1 deletion MatrixSDK/MatrixSDKVersion.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@

#import <Foundation/Foundation.h>

NSString *const MatrixSDKVersion = @"0.27.16";
NSString *const MatrixSDKVersion = @"0.27.17";
Loading