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

Create MXSecretStorage to support SSSS #851

Merged
merged 21 commits into from
May 18, 2020
Merged

Create MXSecretStorage to support SSSS #851

merged 21 commits into from
May 18, 2020

Conversation

manuroe
Copy link
Contributor

@manuroe manuroe commented May 15, 2020

Fix element-hq/element-ios#2926

Spec: ([MSC1946(]matrix-org/matrix-spec-proposals#1946)

This module will be used for bootstrap and account keys recovery.

image

#pragma mark - Constants

FOUNDATION_EXPORT NSString *const MXSecretStorageErrorDomain;
typedef enum : NSUInteger
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer typedef NS_ENUM(NSUInteger, MXSecretStorageErrorCode) { for Swift usage.

*/
- (MXHTTPOperation *)storeSecret:(NSString*)unpaddedBase64Secret
withSecretId:(nullable NSString*)secretId
withSecretStorageKeys:(NSDictionary<NSString*, NSData*> *)keys
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with prefix can be replaced by and or removed.

@param failure A block object called when the operation fails.
*/
- (void)secretWithSecretId:(NSString*)secretId
withSecretStorageKeyId:(nullable NSString*)keyId
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with prefix can be removed.

Copy link
Contributor Author

@manuroe manuroe May 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why? SecretId and SecretStorageKeyId are 2 different things. This makes a sentence in objc.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only the second one

dispatch_async(processingQueue, ^{
MXStrongifyAndReturnIfNil(self);

NSData *iv = [MXBase64Tools dataFromBase64:key.iv];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MXSecretStorageKeyContent.iv is nullable. Crash can occurs here.

Comment on lines 190 to 191
NSData *keyMac = [MXBase64Tools dataFromBase64:key.mac];
NSData *encryptedZeroStringMac = [MXBase64Tools dataFromBase64:encryptedZeroString.mac];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MXSecretStorageKeyContent.mac is nullable. Crash can occurs here.


NSData *iv = secretContent.iv ? [MXBase64Tools dataFromBase64:secretContent.iv] : [NSMutableData dataWithLength:16];

NSData *hmac = [MXBase64Tools dataFromBase64:secretContent.mac];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MXEncryptedSecretContent.mac is nullable. Crash can occurs here.

return nil;
}

NSData *cipher = [MXBase64Tools dataFromBase64:secretContent.ciphertext];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MXEncryptedSecretContent.cipherText is nullable. Crash can occurs here.

@manuroe manuroe merged commit 376e4d2 into develop May 18, 2020
@manuroe manuroe deleted the riot_2926 branch May 18, 2020 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SSSS: Support in SDK
2 participants