]> git.saurik.com Git - apple/security.git/blob - SecurityTests/clxutils/threadTest/trustSettings.cpp
Security-57031.10.10.tar.gz
[apple/security.git] / SecurityTests / clxutils / threadTest / trustSettings.cpp
1 /*
2 * trustSettings.cpp - multi threaded TP evaluate with Trust Settings enabled
3 */
4 #include "testParams.h"
5 #include <Security/cssm.h>
6 #include <utilLib/common.h>
7 #include <utilLib/cspwrap.h>
8 #include <clAppUtils/BlobList.h>
9 #include <clAppUtils/certVerify.h>
10 #include <security_cdsa_utils/cuFileIo.h>
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <time.h>
14 #include <string.h>
15 #include <Security/Security.h>
16
17 #define HOLD_SEARCH_LIST 0
18
19 /* for malloc debug */
20 #define DO_PAUSE 0
21
22 static const char *CERT_FILE0 = "amazon_v3.100.cer";
23 static const char *CERT_FILE1 = "amazon_v3.101.cer";
24
25 /* common data, our known good cert, shared by all threads */
26 static BlobList blobList;
27 static BlobList emptyRootList;
28
29 /* read in our known good cert file, just once */
30 int trustSettingsInit(TestParams *testParams)
31 {
32 if(testParams->verbose) {
33 printf("trustSettingsInit thread %d: reading cert files %s and %s...\n",
34 testParams->threadNum, CERT_FILE0, CERT_FILE1);
35 }
36 if(blobList.addFile(CERT_FILE0)) {
37 printf("Error reading %s; aborting\n", CERT_FILE0);
38 printf("***This test must be run from the clxutils/threadTest directory.\n");
39 return 1;
40 }
41 if(blobList.addFile(CERT_FILE1)) {
42 printf("Error reading %s; aborting\n", CERT_FILE1);
43 printf("***This test must be run from the clxutils/threadTest directory.\n");
44 return 1;
45 }
46 return 0;
47 }
48
49
50 int trustSettingsEval(TestParams *testParams)
51 {
52 unsigned loopNum;
53
54 #if HOLD_SEARCH_LIST
55 CFArrayRef sl;
56 ortn = SecKeychainCopySearchList(&sl);
57 if(ortn) {
58 cssmPerror("SecPolicySearchCreate", ortn);
59 return (int)ortn;
60 }
61 #endif
62
63 for(loopNum=0; loopNum<testParams->numLoops; loopNum++) {
64 if(testParams->verbose) {
65 printf("trustSettingsEval loop %d\n", loopNum);
66 }
67 else if(!testParams->quiet) {
68 printChar(testParams->progressChar);
69 }
70 int rtn = certVerifySimple(testParams->tpHand,
71 testParams->clHand,
72 testParams->cspHand,
73 blobList,
74 emptyRootList,
75 CSSM_TRUE, /* useSystemAnchors */
76 CSSM_FALSE, /* leafCertIsCA */
77 CSSM_FALSE,
78 CVP_Basic,
79 NULL, CSSM_FALSE, NULL,
80 0,
81 NULL, /* expectedErrStr */
82 0, NULL, /* certErrors */
83 0, NULL, /* certStatus */
84 CSSM_TRUE, /* TrustSettings */
85 CSSM_TRUE, CSSM_FALSE);
86 if(rtn) {
87 printf("Cert Eval failed\n");
88 return rtn;
89 }
90
91 #if DO_PAUSE
92 fpurge(stdin);
93 printf("Hit CR to continue: ");
94 getchar();
95 #endif
96 } /* outer loop */
97 #if HOLD_SEARCH_LIST
98 CFRelease(sl);
99 #endif
100 return 0;
101 }