Checking the result of SecRandomCopyBytes

Built and verified by @FredericJacobs
pull/1/head
Craig Gidney 10 years ago committed by Frederic Jacobs
parent 02560f8b2f
commit 485748068f

@ -6,13 +6,17 @@
#import "Conversions.h"
#import "EvpMessageDigest.h"
#import "EvpSymetricUtil.h"
#import "SecurityFailure.h"
#import "Util.h"
@implementation CryptoTools
+(NSData*)generateSecureRandomData:(NSUInteger)length {
NSMutableData* d = [NSMutableData dataWithLength:length];
SecRandomCopyBytes(kSecRandomDefault, length, [d mutableBytes]);
int err = SecRandomCopyBytes(kSecRandomDefault, length, [d mutableBytes]);
if (err != 0) {
[SecurityFailure raise:@"SecRandomCopyBytes failed"];
}
return d;
}

Loading…
Cancel
Save