session-ios/SignalServiceKit/src/Security/SecurityUtils.m
Michael Kirk ccb4a88742 Import SSK (and history) into Signal-iOS
git remote add ssk ../SignalServiceKit
git remote update
git merge -s ours --allow-unrelated-histories --no-commit ssk/master
git read-tree --prefix=SignalServiceKit -u ssk/master
git commit
2017-07-21 13:55:01 -04:00

24 lines
695 B
Objective-C

//
// SecurityUtils.m
// TextSecureKit
//
// Created by Frederic Jacobs on 28/10/14.
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
//
#import "SecurityUtils.h"
@implementation SecurityUtils
+ (NSData *)generateRandomBytes:(int)numberBytes {
NSMutableData *randomBytes = [NSMutableData dataWithLength:(NSUInteger)numberBytes];
int err = 0;
err = SecRandomCopyBytes(kSecRandomDefault, (size_t)numberBytes, [randomBytes mutableBytes]);
if (err != noErr) {
@throw [NSException exceptionWithName:@"random problem" reason:@"problem generating the random " userInfo:nil];
}
return randomBytes;
}
@end