]> git.saurik.com Git - apple/security.git/blobdiff - SecurityTests/clxutils/threadTest/digestClient.cpp
Security-57031.1.35.tar.gz
[apple/security.git] / SecurityTests / clxutils / threadTest / digestClient.cpp
diff --git a/SecurityTests/clxutils/threadTest/digestClient.cpp b/SecurityTests/clxutils/threadTest/digestClient.cpp
new file mode 100644 (file)
index 0000000..92f1001
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * digestClient.cpp
+ */
+#include "testParams.h"
+#include <Security/Security.h>
+#include <security_cdsa_client/cspclient.h>
+
+/* for malloc debug */
+#define DO_PAUSE       0
+
+int digestClientInit(TestParams *testParams)
+{
+       return 0;
+}
+
+using namespace Security;
+using namespace CssmClient;
+
+int digestClient(TestParams *testParams)
+{
+       unsigned loopNum;
+       
+       for(loopNum=0; loopNum<testParams->numLoops; loopNum++) {
+               if(testParams->verbose) {
+                       printf("secTrustEval loop %d\n", loopNum);
+               }
+               else if(!testParams->quiet) {
+                       printChar(testParams->progressChar);
+               }
+               try {
+                       CSP *csp = new CSP(gGuidAppleCSP);
+                       uint8 digData[20];
+                       Digest *digest = new Digest(*csp, CSSM_ALGID_SHA1);
+                       CssmData ptext((char *)"test", 4);
+                       CssmData dig(digData, sizeof(digData));
+                       digest->digest(ptext, dig);
+                       if(dig.Length != 20) {
+                               printf("***digest length error\n");
+                               return 1;
+                       }
+                       delete digest;
+                       delete csp;
+               }
+               catch(...) {
+                       printf("***CSP/Digest client threw exeption\n");
+                       return 1;
+               }
+
+               #if     DO_PAUSE
+               fpurge(stdin);
+               printf("Hit CR to continue: ");
+               getchar();
+               #endif
+       }       /* outer loop */
+       #if HOLD_SEARCH_LIST
+       CFRelease(sl);
+       #endif
+       return 0;
+}