]> git.saurik.com Git - apple/security.git/blobdiff - SecurityTests/clxutils/threadTest/cssmErrStr.cpp
Security-57031.1.35.tar.gz
[apple/security.git] / SecurityTests / clxutils / threadTest / cssmErrStr.cpp
diff --git a/SecurityTests/clxutils/threadTest/cssmErrStr.cpp b/SecurityTests/clxutils/threadTest/cssmErrStr.cpp
new file mode 100644 (file)
index 0000000..a9f346f
--- /dev/null
@@ -0,0 +1,61 @@
+/* cssmErrorString per-thread basher */
+#include <time.h>
+#include <stdio.h>
+#include "testParams.h"
+#include <Security/SecBasePriv.h>
+#include <Security/cssmerr.h>
+
+/* nothing here for now */
+int cssmErrStrInit(TestParams *tp)
+{
+       return 0;
+}
+
+CSSM_RETURN variousErrors[] = {
+       CSSMERR_CSP_INVALID_CONTEXT,
+       CSSMERR_CSP_INVALID_ALGORITHM,
+       CSSMERR_CSP_INVALID_ATTR_KEY,
+       CSSMERR_CSP_MISSING_ATTR_KEY,
+       CSSMERR_CSP_INVALID_ATTR_INIT_VECTOR,
+       CSSMERR_CSP_MISSING_ATTR_INIT_VECTOR,
+       CSSMERR_CSP_INVALID_ATTR_SALT,
+       CSSMERR_CSP_MISSING_ATTR_SALT,
+       CSSMERR_CSP_INVALID_ATTR_PADDING,
+       CSSMERR_CSP_MISSING_ATTR_PADDING,
+       CSSMERR_CSP_INVALID_ATTR_RANDOM,
+       CSSMERR_CSP_MISSING_ATTR_RANDOM,
+       CSSMERR_CSP_INVALID_ATTR_SEED,
+       CSSMERR_CSP_MISSING_ATTR_SEED,
+       CSSMERR_CSP_INVALID_ATTR_PASSPHRASE,
+       CSSMERR_CSP_MISSING_ATTR_PASSPHRASE,
+       CSSMERR_CSP_INVALID_ATTR_KEY_LENGTH,
+       CSSMERR_CSP_MISSING_ATTR_KEY_LENGTH,
+       CSSMERR_CSP_INVALID_ATTR_BLOCK_SIZE,
+       CSSMERR_CSP_MISSING_ATTR_BLOCK_SIZE,
+       CSSMERR_CSP_INVALID_ATTR_OUTPUT_SIZE,
+       CSSMERR_CSP_MISSING_ATTR_OUTPUT_SIZE,
+       CSSMERR_CSP_INVALID_ATTR_ROUNDS
+};
+#define NUM_ERRORS     (sizeof(variousErrors) / sizeof(variousErrors[0]))
+
+int cssmErrStr(TestParams *testParams)
+{
+       for(unsigned loopNum=0; loopNum<testParams->numLoops; loopNum++) {
+               if(testParams->verbose) {
+                       printf("cssmErrStr loop %d\n", loopNum);
+               }
+               else if(!testParams->quiet) {
+                       printChar(testParams->progressChar);    
+               }
+               
+               for(unsigned dex=0; dex<NUM_ERRORS; dex++) {
+                       unsigned whichErr = (dex + testParams->threadNum) % NUM_ERRORS;
+                       const char *es = cssmErrorString(variousErrors[whichErr]);
+                       if(testParams->verbose) {
+                               printf("..%s..", es);
+                       }
+               }
+       }
+       return 0;
+}
+