mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
0b49037179
// FREEBIE
18 lines
459 B
Objective-C
18 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
|