]> git.saurik.com Git - apple/security.git/blob - SecurityTests/clxutils/threadTest/cssmErrStr.cpp
Security-57031.10.10.tar.gz
[apple/security.git] / SecurityTests / clxutils / threadTest / cssmErrStr.cpp
1 /* cssmErrorString per-thread basher */
2 #include <time.h>
3 #include <stdio.h>
4 #include "testParams.h"
5 #include <Security/SecBasePriv.h>
6 #include <Security/cssmerr.h>
7
8 /* nothing here for now */
9 int cssmErrStrInit(TestParams *tp)
10 {
11 return 0;
12 }
13
14 CSSM_RETURN variousErrors[] = {
15 CSSMERR_CSP_INVALID_CONTEXT,
16 CSSMERR_CSP_INVALID_ALGORITHM,
17 CSSMERR_CSP_INVALID_ATTR_KEY,
18 CSSMERR_CSP_MISSING_ATTR_KEY,
19 CSSMERR_CSP_INVALID_ATTR_INIT_VECTOR,
20 CSSMERR_CSP_MISSING_ATTR_INIT_VECTOR,
21 CSSMERR_CSP_INVALID_ATTR_SALT,
22 CSSMERR_CSP_MISSING_ATTR_SALT,
23 CSSMERR_CSP_INVALID_ATTR_PADDING,
24 CSSMERR_CSP_MISSING_ATTR_PADDING,
25 CSSMERR_CSP_INVALID_ATTR_RANDOM,
26 CSSMERR_CSP_MISSING_ATTR_RANDOM,
27 CSSMERR_CSP_INVALID_ATTR_SEED,
28 CSSMERR_CSP_MISSING_ATTR_SEED,
29 CSSMERR_CSP_INVALID_ATTR_PASSPHRASE,
30 CSSMERR_CSP_MISSING_ATTR_PASSPHRASE,
31 CSSMERR_CSP_INVALID_ATTR_KEY_LENGTH,
32 CSSMERR_CSP_MISSING_ATTR_KEY_LENGTH,
33 CSSMERR_CSP_INVALID_ATTR_BLOCK_SIZE,
34 CSSMERR_CSP_MISSING_ATTR_BLOCK_SIZE,
35 CSSMERR_CSP_INVALID_ATTR_OUTPUT_SIZE,
36 CSSMERR_CSP_MISSING_ATTR_OUTPUT_SIZE,
37 CSSMERR_CSP_INVALID_ATTR_ROUNDS
38 };
39 #define NUM_ERRORS (sizeof(variousErrors) / sizeof(variousErrors[0]))
40
41 int cssmErrStr(TestParams *testParams)
42 {
43 for(unsigned loopNum=0; loopNum<testParams->numLoops; loopNum++) {
44 if(testParams->verbose) {
45 printf("cssmErrStr loop %d\n", loopNum);
46 }
47 else if(!testParams->quiet) {
48 printChar(testParams->progressChar);
49 }
50
51 for(unsigned dex=0; dex<NUM_ERRORS; dex++) {
52 unsigned whichErr = (dex + testParams->threadNum) % NUM_ERRORS;
53 const char *es = cssmErrorString(variousErrors[whichErr]);
54 if(testParams->verbose) {
55 printf("..%s..", es);
56 }
57 }
58 }
59 return 0;
60 }
61