olm/xcode/OLMKit/OLMUtility.m

26 lines
492 B
Mathematica
Raw Normal View History

2016-04-09 02:24:41 +02:00
//
// OLMUtility.m
// olm
//
// Created by Chris Ballinger on 4/8/16.
//
//
#import "OLMUtility.h"
@implementation OLMUtility
2016-04-09 23:00:30 +02:00
+ (NSMutableData*) randomBytesOfLength:(NSUInteger)length {
NSMutableData *randomData = [NSMutableData dataWithLength:length];
if (!randomData) {
2016-04-09 02:24:41 +02:00
return nil;
}
2016-04-09 23:00:30 +02:00
int result = SecRandomCopyBytes(kSecRandomDefault, randomData.length, randomData.mutableBytes);
2016-04-09 02:24:41 +02:00
if (result != 0) {
return nil;
}
2016-04-09 23:00:30 +02:00
return randomData;
2016-04-09 02:24:41 +02:00
}
@end