Created
November 6, 2014 16:56
-
-
Save landonf/843ba6de37d9d0e24a11 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#include <stdio.h> | |
#include <CommonCrypto/CommonKeyDerivation.h> | |
#include <CommonCrypto/CommonCryptor.h> | |
#include <assert.h> | |
#include <dispatch/dispatch.h> | |
int main (int argc, char *argv[]) { | |
uint64_t salt = 0; | |
dispatch_group_t group = dispatch_group_create(); | |
for (int i = 0; i <= 9999; i++) { | |
char *pass; | |
asprintf(&pass, "%d", i); | |
dispatch_group_async(group, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{ | |
uint8_t result[1024]; | |
int ret = CCKeyDerivationPBKDF(kCCPBKDF2, pass, strlen(pass), (const uint8_t *) &salt, sizeof(salt), kCCPRFHmacAlgSHA256, 10000, result, sizeof(result)); | |
assert(ret == kCCSuccess); | |
free(pass); | |
if (i > 0 && i % 1000 == 0) { | |
printf(": Derived first %d keys\n", i); | |
} else if (i > 0 && i % 100 == 0) { | |
printf("."); | |
fflush(stdout); | |
} | |
}); | |
} | |
dispatch_group_notify(group, dispatch_get_main_queue(), ^{ | |
printf(": Completed PBKDF2-HMAC-SHA256 (10K rounds) for all pins (0 - 9999)\n"); | |
exit(1); | |
}); | |
dispatch_main(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment