]> git.saurik.com Git - apple/security.git/blob - SecurityTests/clxutils/threadTest/digestClient.cpp
Security-57336.1.9.tar.gz
[apple/security.git] / SecurityTests / clxutils / threadTest / digestClient.cpp
1 /*
2 * digestClient.cpp
3 */
4 #include "testParams.h"
5 #include <Security/Security.h>
6 #include <security_cdsa_client/cspclient.h>
7
8 /* for malloc debug */
9 #define DO_PAUSE 0
10
11 int digestClientInit(TestParams *testParams)
12 {
13 return 0;
14 }
15
16 using namespace Security;
17 using namespace CssmClient;
18
19 int digestClient(TestParams *testParams)
20 {
21 unsigned loopNum;
22
23 for(loopNum=0; loopNum<testParams->numLoops; loopNum++) {
24 if(testParams->verbose) {
25 printf("secTrustEval loop %d\n", loopNum);
26 }
27 else if(!testParams->quiet) {
28 printChar(testParams->progressChar);
29 }
30 try {
31 CSP *csp = new CSP(gGuidAppleCSP);
32 uint8 digData[20];
33 Digest *digest = new Digest(*csp, CSSM_ALGID_SHA1);
34 CssmData ptext((char *)"test", 4);
35 CssmData dig(digData, sizeof(digData));
36 digest->digest(ptext, dig);
37 if(dig.Length != 20) {
38 printf("***digest length error\n");
39 return 1;
40 }
41 delete digest;
42 delete csp;
43 }
44 catch(...) {
45 printf("***CSP/Digest client threw exeption\n");
46 return 1;
47 }
48
49 #if DO_PAUSE
50 fpurge(stdin);
51 printf("Hit CR to continue: ");
52 getchar();
53 #endif
54 } /* outer loop */
55 #if HOLD_SEARCH_LIST
56 CFRelease(sl);
57 #endif
58 return 0;
59 }