|
|
@ -6,13 +6,17 @@
|
|
|
|
#import "Conversions.h"
|
|
|
|
#import "Conversions.h"
|
|
|
|
#import "EvpMessageDigest.h"
|
|
|
|
#import "EvpMessageDigest.h"
|
|
|
|
#import "EvpSymetricUtil.h"
|
|
|
|
#import "EvpSymetricUtil.h"
|
|
|
|
|
|
|
|
#import "SecurityFailure.h"
|
|
|
|
#import "Util.h"
|
|
|
|
#import "Util.h"
|
|
|
|
|
|
|
|
|
|
|
|
@implementation CryptoTools
|
|
|
|
@implementation CryptoTools
|
|
|
|
|
|
|
|
|
|
|
|
+(NSData*)generateSecureRandomData:(NSUInteger)length {
|
|
|
|
+(NSData*)generateSecureRandomData:(NSUInteger)length {
|
|
|
|
NSMutableData* d = [NSMutableData dataWithLength: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;
|
|
|
|
return d;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|