session-ios/Signal/src/crypto/CryptoTools.m
2017-03-30 11:00:28 -04:00

19 lines
459 B
Objective-C

//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "CryptoTools.h"
@implementation CryptoTools
+ (NSData *)generateSecureRandomData:(NSUInteger)length {
NSMutableData *d = [NSMutableData dataWithLength:length];
OSStatus status = SecRandomCopyBytes(kSecRandomDefault, length, [d mutableBytes]);
if (status != noErr) {
[SecurityFailure raise:@"SecRandomCopyBytes failed"];
}
return [d copy];
}
@end