File tree 1 file changed +9
-3
lines changed
MatrixSDK/Crypto/SecretStorage
1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 25
25
#import " MXBase64Tools.h"
26
26
#import " MXEncryptedSecretContent.h"
27
27
28
+ #import < Security/Security.h>
28
29
29
30
#pragma mark - Constants
30
31
@@ -166,9 +167,14 @@ - (MXHTTPOperation*)createKeyWithKeyId:(nullable NSString*)keyId
166
167
}
167
168
else
168
169
{
169
- OLMPkDecryption *decryption = [OLMPkDecryption new ];
170
- [decryption generateKey: &error];
171
- privateKey = decryption.privateKey ;
170
+ uint8_t randomBytes[32 ];
171
+ OSStatus status = SecRandomCopyBytes (kSecRandomDefault , sizeof (randomBytes), randomBytes);
172
+
173
+ if (status == errSecSuccess) {
174
+ privateKey = [NSData dataWithBytes: randomBytes length: sizeof (randomBytes)];
175
+ } else {
176
+ MXLogDebug (@" Failed to generate random bytes with error: %d " , (int )status);
177
+ }
172
178
}
173
179
174
180
if (error)
You can’t perform that action at this time.
0 commit comments