diff --git a/MatrixSDK/Crypto/SecretStorage/MXSecretStorage.m b/MatrixSDK/Crypto/SecretStorage/MXSecretStorage.m index 3ffb6c6de..014c15215 100644 --- a/MatrixSDK/Crypto/SecretStorage/MXSecretStorage.m +++ b/MatrixSDK/Crypto/SecretStorage/MXSecretStorage.m @@ -25,6 +25,7 @@ #import "MXBase64Tools.h" #import "MXEncryptedSecretContent.h" +#import #pragma mark - Constants @@ -166,9 +167,14 @@ - (MXHTTPOperation*)createKeyWithKeyId:(nullable NSString*)keyId } else { - OLMPkDecryption *decryption = [OLMPkDecryption new]; - [decryption generateKey:&error]; - privateKey = decryption.privateKey; + 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)