X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/b04fe171f0375ecd5d8a24747ca1dff85720a0ca..6b200bc335dc93c5516ccb52f14bd896d8c7fad7:/SecurityTests/cspxutils/keyHash/keyHash.c diff --git a/SecurityTests/cspxutils/keyHash/keyHash.c b/SecurityTests/cspxutils/keyHash/keyHash.c deleted file mode 100644 index 9895bb34..00000000 --- a/SecurityTests/cspxutils/keyHash/keyHash.c +++ /dev/null @@ -1,249 +0,0 @@ -/* - * keyHash.c - simple test of CSSM_APPLECSP_KEYDIGEST passthrough - */ - -#include -#include -#include -#include -#include -#include "cspwrap.h" -#include "common.h" -#include "cspdlTesting.h" - -#define USAGE_NAME "noUsage" -#define USAGE_NAME_LEN (strlen(USAGE_NAME)) -#define LOOPS_DEF 10 - -static void usage(char **argv) -{ - printf("usage: %s [options]\n", argv[0]); - printf("Options:\n"); - printf(" l=loops (default=%d; 0=forever)\n", LOOPS_DEF); - printf(" D (CSP/DL; default = bare CSP)\n"); - printf(" p(ause on each loop)\n"); - printf(" q(uiet)\n"); - printf(" v(erbose))\n"); - exit(1); -} - -static void dumpBuf(uint8 *buf, - unsigned len) -{ - unsigned i; - - printf(" "); - for(i=0; iKeyHeader.BlobType != CSSM_KEYBLOB_REFERENCE) { - printf("Hey! this only works on ref keys!!\n"); - exit(1); - } - - /* get raw key */ - crtn = cspWrapKey(cspHand, - refKey, - NULL, // wrappingKey - CSSM_ALGID_NONE, - CSSM_ALGMODE_NONE, - CSSM_KEYBLOB_WRAPPED_FORMAT_NONE, - CSSM_PADDING_NONE, - NULL, // iv - NULL, // descData - &rawKey); - if(crtn) { - return testError(quiet); - } - - /* hash of both keys */ - crtn = cspKeyHash(cspHand, refKey, &refHash); - if(crtn) { - return testError(quiet); - } - else { - if(verbose) { - printf(" ...Ref key hash:\n "); - dumpBuf(refHash->Data, refHash->Length); - } - } - crtn = cspKeyHash(rawCspHand, &rawKey, &rawHash); - if(crtn) { - return testError(quiet); - } - else { - if(verbose) { - printf(" ...Raw key hash:\n "); - dumpBuf(rawHash->Data, rawHash->Length); - } - } - if(!appCompareCssmData(refHash, rawHash)) { - printf("***Key Hash Miscompare!\n"); - return testError(quiet); - } - appFreeCssmData(refHash, CSSM_TRUE); - appFreeCssmData(rawHash, CSSM_TRUE); - cspFreeKey(cspHand, &rawKey); - return 0; -} - -int main(int argc, char **argv) -{ - int arg; - char *argp; - unsigned loop; - CSSM_CSP_HANDLE cspHand; - CSSM_CSP_HANDLE rawCspHand; - int rtn = 0; - CSSM_KEY pubKey; - CSSM_KEY privKey; - CSSM_KEY_PTR symKey; - int i; - - /* - * User-spec'd params - */ - unsigned loops = LOOPS_DEF; - CSSM_BOOL verbose = CSSM_FALSE; - CSSM_BOOL quiet = CSSM_FALSE; - CSSM_BOOL bareCsp = CSSM_TRUE; - CSSM_BOOL doPause = CSSM_FALSE; - - for(arg=1; arg