Return immutable data from generateSecureRandomData:length and use OSStatus to check the status of SecRandomCopyBytes. (#1306)

pull/1/head
James Barclay 9 years ago committed by Michael Kirk
parent b29174a374
commit f8a0be4c70

@ -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 {

Loading…
Cancel
Save