Created
June 23, 2016 18:17
-
-
Save jevinskie/40df60e3e9d76ad05304be9bd550d6ad to your computer and use it in GitHub Desktop.
iOS 10 kernel decryption benchmark
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// main.m | |
// kern-dec-bench | |
// | |
// Created by Jevin Sweval on 6/23/16. | |
// Copyright © 2016 Arxan Technologies, Inc. All rights reserved. | |
// | |
#import <UIKit/UIKit.h> | |
#import "AppDelegate.h" | |
#import <CommonCrypto/CommonCrypto.h> | |
int main(int argc, char * argv[]) { | |
@autoreleasepool { | |
NSString *kernpath = [NSBundle.mainBundle pathForResource:@"kernelcache.release" ofType:@"n66"]; | |
NSLog(@"kernpath: %@", kernpath); | |
NSMutableData *kerndata = [NSMutableData dataWithContentsOfFile:kernpath]; | |
NSMutableData *key = [NSMutableData dataWithLength:32]; | |
NSMutableData *iv = [NSMutableData dataWithLength:16]; | |
size_t outLength; | |
NSMutableData *kerndec = [NSMutableData dataWithLength:kerndata.length + kCCBlockSizeAES128]; | |
CFTimeInterval start = CACurrentMediaTime(); | |
for (int i = 0; i < 16; ++i) { | |
CCCryptorStatus | |
result = CCCrypt(kCCEncrypt, // operation | |
kCCAlgorithmAES128, // Algorithm | |
kCCOptionPKCS7Padding, // options | |
key.bytes, // key | |
key.length, // keylength | |
iv.bytes,// iv | |
kerndata.bytes, // dataIn | |
kerndata.length, // dataInLength, | |
kerndec.mutableBytes, // dataOut | |
kerndec.length, // dataOutAvailable | |
&outLength); // dataOutMoved | |
assert(result == kCCSuccess); | |
} | |
CFTimeInterval stop = CACurrentMediaTime(); | |
NSLog(@"start: %f stop: %f diff: %f", start, stop, stop - start); | |
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment