diff --git a/Signal/src/crypto/CryptoTools.m b/Signal/src/crypto/CryptoTools.m index 9bd3f6e26..7df5f43dc 100644 --- a/Signal/src/crypto/CryptoTools.m +++ b/Signal/src/crypto/CryptoTools.m @@ -10,11 +10,11 @@ + (NSData *)generateSecureRandomData:(NSUInteger)length { NSMutableData *d = [NSMutableData dataWithLength:length]; - int err = SecRandomCopyBytes(kSecRandomDefault, length, [d mutableBytes]); - if (err != 0) { + OSStatus status = SecRandomCopyBytes(kSecRandomDefault, length, [d mutableBytes]); + if (status != noErr) { [SecurityFailure raise:@"SecRandomCopyBytes failed"]; } - return d; + return [d copy]; } + (uint16_t)generateSecureRandomUInt16 {