X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/b04fe171f0375ecd5d8a24747ca1dff85720a0ca..6b200bc335dc93c5516ccb52f14bd896d8c7fad7:/SecurityTests/cspxutils/sha2Time/sha2Time.cpp diff --git a/SecurityTests/cspxutils/sha2Time/sha2Time.cpp b/SecurityTests/cspxutils/sha2Time/sha2Time.cpp deleted file mode 100644 index 6b9f6bb5..00000000 --- a/SecurityTests/cspxutils/sha2Time/sha2Time.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Measure performance of SHA using raw CommonCrypto digests. - * Use hashTime to measure performance thru the CSP. - */ - -#include -#include -#include -#include -#include "cputime.h" -#include "common.h" - -static void usage(char **argv) -{ - printf("Usage: %s bytecount [q(uiet)]\n", argv[0]); - exit(1); -} - -#define BUFSIZE (8 * 1024) - -int main(int argc, char **argv) -{ - bool quiet = false; - unsigned byteCount; - - if(argc < 2) { - usage(argv); - } - byteCount = atoi(argv[1]); - for(int arg=2; arg BUFSIZE) { - thisMove = BUFSIZE; - } - else { - thisMove = toMove; - } - toMove -= thisMove; - CC_SHA1_Update(&ctx1, text, thisMove); - } while(toMove); - CC_SHA1_Final(dig1, &ctx1); - timeSpentMs = CPUTimeDeltaMs(startTime, CPUTimeRead()); - printf("SHA1: Digest %u bytes : %.2f ms\n", byteCount, timeSpentMs); - - /* SHA256 */ - if(!quiet) { - printf("...testing SHA256\n"); - } - - CC_SHA256_CTX ctx256; - unsigned char dig256[CC_SHA256_DIGEST_LENGTH]; - toMove = byteCount; - CC_SHA256_Init(&ctx256); - - /* start critical timing loop */ - startTime = CPUTimeRead(); - do { - if(toMove > BUFSIZE) { - thisMove = BUFSIZE; - } - else { - thisMove = toMove; - } - toMove -= thisMove; - CC_SHA256_Update(&ctx256, text, thisMove); - } while(toMove); - CC_SHA256_Final(dig256, &ctx256); - timeSpentMs = CPUTimeDeltaMs(startTime, CPUTimeRead()); - printf("SHA256: Digest %u bytes : %.2f ms\n", byteCount, timeSpentMs); - - /* SHA256 */ - if(!quiet) { - printf("...testing SHA512\n"); - } - - CC_SHA512_CTX ctx512; - unsigned char dig512[CC_SHA512_DIGEST_LENGTH]; - toMove = byteCount; - CC_SHA512_Init(&ctx512); - - /* start critical timing loop */ - startTime = CPUTimeRead(); - do { - if(toMove > BUFSIZE) { - thisMove = BUFSIZE; - } - else { - thisMove = toMove; - } - toMove -= thisMove; - CC_SHA512_Update(&ctx512, text, thisMove); - } while(toMove); - CC_SHA512_Final(dig512, &ctx512); - timeSpentMs = CPUTimeDeltaMs(startTime, CPUTimeRead()); - printf("SHA512: Digest %u bytes : %.2f ms\n", byteCount, timeSpentMs); - - return 0; -}