]> git.saurik.com Git - apple/security.git/blob - KeychainCircle/NSData+SecRandom.m
Security-59754.41.1.tar.gz
[apple/security.git] / KeychainCircle / NSData+SecRandom.m
1 //
2 // NSData+SecRandom.m
3 // Security
4 //
5 // Created by Mitch Adler on 4/15/16.
6 //
7 //
8
9 #import <Foundation/Foundation.h>
10 #import <NSData+SecRandom.h>
11
12 #include <Security/SecRandom.h>
13
14 @implementation NSMutableData (SecRandom)
15
16 + (instancetype) dataWithRandomBytes: (int) length {
17
18 NSMutableData* result = [NSMutableData dataWithLength: length];
19
20 if (0 != SecRandomCopyBytes(kSecRandomDefault, result.length, result.mutableBytes))
21 return nil;
22
23 return result;
24 }
25
26 @end