OLD | NEW |
1 /* This Source Code Form is subject to the terms of the Mozilla Public | 1 /* This Source Code Form is subject to the terms of the Mozilla Public |
2 * License, v. 2.0. If a copy of the MPL was not distributed with this | 2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 /* | 4 /* |
5 * test_validatechain_NB.c | 5 * test_validatechain_NB.c |
6 * | 6 * |
7 * Test ValidateChain (nonblocking I/O) function | 7 * Test ValidateChain (nonblocking I/O) function |
8 * | 8 * |
9 */ | 9 */ |
10 | 10 |
11 #include "testutil.h" | 11 #include "testutil.h" |
12 #include "testutil_nss.h" | 12 #include "testutil_nss.h" |
13 | 13 |
14 static void *plContext = NULL; | 14 static void *plContext = NULL; |
15 | 15 |
16 static | 16 static void printUsage(void) { |
17 void printUsage(void){ | 17 (void)printf( |
18 (void) printf("\nUSAGE:\ntest_validateChain_NB TestName [ENE|EE] " | 18 "\nUSAGE:\ntest_validateChain_NB TestName [ENE|EE] " |
19 "<certStoreDirectory> <trustedCert> <targetCert>\n\n"); | 19 "<certStoreDirectory> <trustedCert> <targetCert>\n\n"); |
20 (void) printf | 20 (void)printf( |
21 ("Validates a chain of certificates between " | 21 "Validates a chain of certificates between " |
22 "<trustedCert> and <targetCert>\n" | 22 "<trustedCert> and <targetCert>\n" |
23 "using the certs and CRLs in <certStoreDirectory>. " | 23 "using the certs and CRLs in <certStoreDirectory>. " |
24 "If ENE is specified,\n" | 24 "If ENE is specified,\n" |
25 "then an Error is Not Expected. " | 25 "then an Error is Not Expected. " |
26 "If EE is specified, an Error is Expected.\n"); | 26 "If EE is specified, an Error is Expected.\n"); |
27 } | 27 } |
28 | 28 |
29 static | 29 static char *createFullPathName(char *dirName, char *certFile, |
30 char *createFullPathName( | 30 void *plContext) { |
31 char *dirName, | 31 PKIX_UInt32 certFileLen; |
32 char *certFile, | 32 PKIX_UInt32 dirNameLen; |
33 void *plContext) | 33 char *certPathName = NULL; |
34 { | 34 |
35 PKIX_UInt32 certFileLen; | 35 PKIX_TEST_STD_VARS(); |
36 PKIX_UInt32 dirNameLen; | 36 |
37 char *certPathName = NULL; | 37 certFileLen = PL_strlen(certFile); |
38 | 38 dirNameLen = PL_strlen(dirName); |
39 PKIX_TEST_STD_VARS(); | 39 |
40 | 40 PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_Malloc(dirNameLen + certFileLen + 2, |
41 certFileLen = PL_strlen(certFile); | 41 (void **)&certPathName, plContext)); |
42 dirNameLen = PL_strlen(dirName); | 42 |
43 | 43 PL_strcpy(certPathName, dirName); |
44 PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_Malloc | 44 PL_strcat(certPathName, "/"); |
45 (dirNameLen + certFileLen + 2, | 45 PL_strcat(certPathName, certFile); |
46 (void **)&certPathName, | 46 printf("certPathName = %s\n", certPathName); |
47 plContext)); | 47 |
48 | 48 cleanup: |
49 PL_strcpy(certPathName, dirName); | 49 |
50 PL_strcat(certPathName, "/"); | 50 PKIX_TEST_RETURN(); |
51 PL_strcat(certPathName, certFile); | 51 |
52 printf("certPathName = %s\n", certPathName); | 52 return (certPathName); |
53 | 53 } |
54 cleanup: | 54 |
55 | 55 static PKIX_Error *testSetupCertStore(PKIX_ValidateParams *valParams, |
56 PKIX_TEST_RETURN(); | 56 char *ldapName) { |
57 | 57 PKIX_PL_String *dirString = NULL; |
58 return (certPathName); | 58 PKIX_CertStore *certStore = NULL; |
59 } | 59 PKIX_ProcessingParams *procParams = NULL; |
60 | 60 PKIX_PL_LdapDefaultClient *ldapClient = NULL; |
61 static PKIX_Error * | 61 |
62 testSetupCertStore(PKIX_ValidateParams *valParams, char *ldapName) | 62 PKIX_TEST_STD_VARS(); |
63 { | 63 |
64 PKIX_PL_String *dirString = NULL; | 64 subTest("PKIX_PL_CollectionCertStoreContext_Create"); |
65 PKIX_CertStore *certStore = NULL; | 65 |
66 PKIX_ProcessingParams *procParams = NULL; | 66 /* Create LDAPCertStore */ |
67 PKIX_PL_LdapDefaultClient *ldapClient = NULL; | 67 PKIX_TEST_EXPECT_NO_ERROR( |
68 | 68 PKIX_PL_LdapDefaultClient_CreateByName(ldapName, 0, /* timeout */ |
69 PKIX_TEST_STD_VARS(); | 69 NULL, /* bindPtr */ |
70 | 70 &ldapClient, plContext)); |
71 subTest("PKIX_PL_CollectionCertStoreContext_Create"); | 71 |
72 | 72 PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_LdapCertStore_Create( |
73 /* Create LDAPCertStore */ | 73 (PKIX_PL_LdapClient *)ldapClient, &certStore, plContext)); |
74 PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_LdapDefaultClient_CreateByName | 74 |
75 (ldapName, | 75 PKIX_TEST_EXPECT_NO_ERROR(PKIX_ValidateParams_GetProcessingParams( |
76 0, /* timeout */ | 76 valParams, &procParams, plContext)); |
77 NULL, /* bindPtr */ | 77 |
78 &ldapClient, | 78 subTest("PKIX_ProcessingParams_AddCertStore"); |
79 plContext)); | 79 PKIX_TEST_EXPECT_NO_ERROR( |
80 | 80 PKIX_ProcessingParams_AddCertStore(procParams, certStore, plContext)); |
81 PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_LdapCertStore_Create | 81 |
82 ((PKIX_PL_LdapClient *)ldapClient, | 82 subTest("PKIX_ProcessingParams_SetRevocationEnabled"); |
83 &certStore, | 83 PKIX_TEST_EXPECT_NO_ERROR(PKIX_ProcessingParams_SetRevocationEnabled( |
84 plContext)); | 84 procParams, PKIX_TRUE, plContext)); |
85 | 85 |
86 PKIX_TEST_EXPECT_NO_ERROR(PKIX_ValidateParams_GetProcessingParams | 86 cleanup: |
87 (valParams, &procParams, plContext)); | 87 |
88 | 88 PKIX_TEST_DECREF_AC(dirString); |
89 subTest("PKIX_ProcessingParams_AddCertStore"); | 89 PKIX_TEST_DECREF_AC(procParams); |
90 PKIX_TEST_EXPECT_NO_ERROR(PKIX_ProcessingParams_AddCertStore | 90 PKIX_TEST_DECREF_AC(certStore); |
91 (procParams, certStore, plContext)); | 91 PKIX_TEST_DECREF_AC(ldapClient); |
92 | 92 |
93 subTest("PKIX_ProcessingParams_SetRevocationEnabled"); | 93 PKIX_TEST_RETURN(); |
94 PKIX_TEST_EXPECT_NO_ERROR(PKIX_ProcessingParams_SetRevocationEnabled | 94 |
95 (procParams, PKIX_TRUE, plContext)); | 95 return (0); |
96 | 96 } |
97 cleanup: | 97 |
98 | 98 static char *levels[] = {"None", "Fatal Error", "Error", |
99 PKIX_TEST_DECREF_AC(dirString); | 99 "Warning", "Debug", "Trace"}; |
100 PKIX_TEST_DECREF_AC(procParams); | 100 |
101 PKIX_TEST_DECREF_AC(certStore); | 101 static PKIX_Error *loggerCallback(PKIX_Logger *logger, PKIX_PL_String *message, |
102 PKIX_TEST_DECREF_AC(ldapClient); | 102 PKIX_UInt32 logLevel, |
103 | 103 PKIX_ERRORCLASS logComponent, |
104 PKIX_TEST_RETURN(); | 104 void *plContext) { |
105 | |
106 return (0); | |
107 } | |
108 | |
109 static char *levels[] = { | |
110 "None", "Fatal Error", "Error", "Warning", "Debug", "Trace" | |
111 }; | |
112 | |
113 static PKIX_Error *loggerCallback( | |
114 PKIX_Logger *logger, | |
115 PKIX_PL_String *message, | |
116 PKIX_UInt32 logLevel, | |
117 PKIX_ERRORCLASS logComponent, | |
118 void *plContext) | |
119 { | |
120 #define resultSize 150 | 105 #define resultSize 150 |
121 char *msg = NULL; | 106 char *msg = NULL; |
122 char result[resultSize]; | 107 char result[resultSize]; |
123 | 108 |
124 PKIX_TEST_STD_VARS(); | 109 PKIX_TEST_STD_VARS(); |
125 | 110 |
126 msg = PKIX_String2ASCII(message, plContext); | 111 msg = PKIX_String2ASCII(message, plContext); |
127 PR_snprintf(result, resultSize, | 112 PR_snprintf(result, resultSize, "Logging %s (%s): %s", levels[logLevel], |
128 "Logging %s (%s): %s", | 113 PKIX_ERRORCLASSNAMES[logComponent], msg); |
129 levels[logLevel], | 114 subTest(result); |
130 PKIX_ERRORCLASSNAMES[logComponent], | 115 |
131 msg); | 116 cleanup: |
132 subTest(result); | 117 PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_Free(msg, plContext)); |
133 | 118 PKIX_TEST_RETURN(); |
134 cleanup: | 119 } |
135 PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_Free(msg, plContext)); | 120 |
136 PKIX_TEST_RETURN(); | 121 static void testLogErrors(PKIX_ERRORCLASS module, PKIX_UInt32 loggingLevel, |
137 } | 122 PKIX_List *loggers, void *plContext) { |
138 | 123 PKIX_Logger *logger = NULL; |
139 static | 124 PKIX_PL_String *component = NULL; |
140 void testLogErrors( | 125 |
141 PKIX_ERRORCLASS module, | 126 PKIX_TEST_STD_VARS(); |
142 PKIX_UInt32 loggingLevel, | 127 |
143 PKIX_List *loggers, | 128 PKIX_TEST_EXPECT_NO_ERROR( |
144 void *plContext) | 129 PKIX_Logger_Create(loggerCallback, NULL, &logger, plContext)); |
145 { | 130 PKIX_TEST_EXPECT_NO_ERROR( |
146 PKIX_Logger *logger = NULL; | 131 PKIX_Logger_SetLoggingComponent(logger, module, plContext)); |
147 PKIX_PL_String *component = NULL; | 132 PKIX_TEST_EXPECT_NO_ERROR( |
148 | 133 PKIX_Logger_SetMaxLoggingLevel(logger, loggingLevel, plContext)); |
149 PKIX_TEST_STD_VARS(); | 134 PKIX_TEST_EXPECT_NO_ERROR( |
150 | 135 PKIX_List_AppendItem(loggers, (PKIX_PL_Object *)logger, plContext)); |
151 PKIX_TEST_EXPECT_NO_ERROR(PKIX_Logger_Create | 136 |
152 (loggerCallback, NULL, &logger, plContext)); | 137 cleanup: |
153 PKIX_TEST_EXPECT_NO_ERROR(PKIX_Logger_SetLoggingComponent | 138 PKIX_TEST_DECREF_AC(logger); |
154 (logger, module, plContext)); | 139 PKIX_TEST_DECREF_AC(component); |
155 PKIX_TEST_EXPECT_NO_ERROR(PKIX_Logger_SetMaxLoggingLevel | 140 |
156 (logger, loggingLevel, plContext)); | 141 PKIX_TEST_RETURN(); |
157 PKIX_TEST_EXPECT_NO_ERROR(PKIX_List_AppendItem | 142 } |
158 (loggers, (PKIX_PL_Object *) logger, plContext)); | 143 |
159 | 144 int test_validatechain_NB(int argc, char *argv[]) { |
160 cleanup: | 145 |
161 PKIX_TEST_DECREF_AC(logger); | 146 PKIX_ValidateParams *valParams = NULL; |
162 PKIX_TEST_DECREF_AC(component); | 147 PKIX_ValidateResult *valResult = NULL; |
163 | 148 PKIX_UInt32 actualMinorVersion; |
164 PKIX_TEST_RETURN(); | 149 PKIX_UInt32 j = 0; |
165 } | 150 PKIX_UInt32 k = 0; |
166 | 151 PKIX_UInt32 chainLength = 0; |
167 int test_validatechain_NB(int argc, char *argv[]){ | 152 PKIX_Boolean testValid = PKIX_TRUE; |
168 | 153 PKIX_List *chainCerts = NULL; |
169 PKIX_ValidateParams *valParams = NULL; | 154 PKIX_PL_Cert *dirCert = NULL; |
170 PKIX_ValidateResult *valResult = NULL; | 155 char *dirCertName = NULL; |
171 PKIX_UInt32 actualMinorVersion; | 156 char *anchorCertName = NULL; |
172 PKIX_UInt32 j = 0; | 157 char *dirName = NULL; |
173 PKIX_UInt32 k = 0; | 158 PKIX_UInt32 certIndex = 0; |
174 PKIX_UInt32 chainLength = 0; | 159 PKIX_UInt32 anchorIndex = 0; |
175 PKIX_Boolean testValid = PKIX_TRUE; | 160 PKIX_UInt32 checkerIndex = 0; |
176 PKIX_List *chainCerts = NULL; | 161 PKIX_Boolean revChecking = PKIX_FALSE; |
177 PKIX_PL_Cert *dirCert = NULL; | 162 PKIX_List *checkers = NULL; |
178 char *dirCertName = NULL; | 163 PRPollDesc *pollDesc = NULL; |
179 char *anchorCertName = NULL; | 164 PRErrorCode errorCode = 0; |
180 char *dirName = NULL; | 165 PKIX_PL_Socket *socket = NULL; |
181 PKIX_UInt32 certIndex = 0; | 166 char *ldapName = NULL; |
182 PKIX_UInt32 anchorIndex = 0; | 167 PKIX_VerifyNode *verifyTree = NULL; |
183 PKIX_UInt32 checkerIndex = 0; | 168 PKIX_PL_String *verifyString = NULL; |
184 PKIX_Boolean revChecking = PKIX_FALSE; | 169 |
185 PKIX_List *checkers = NULL; | 170 PKIX_List *loggers = NULL; |
186 PRPollDesc *pollDesc = NULL; | 171 PKIX_Logger *logger = NULL; |
187 PRErrorCode errorCode = 0; | 172 char *logging = NULL; |
188 PKIX_PL_Socket *socket = NULL; | 173 PKIX_PL_String *component = NULL; |
189 char *ldapName = NULL; | 174 |
190 PKIX_VerifyNode *verifyTree = NULL; | 175 PKIX_TEST_STD_VARS(); |
191 PKIX_PL_String *verifyString = NULL; | 176 |
192 | 177 if (argc < 5) { |
193 PKIX_List *loggers = NULL; | 178 printUsage(); |
194 PKIX_Logger *logger = NULL; | 179 return (0); |
195 char *logging = NULL; | 180 } |
196 PKIX_PL_String *component = NULL; | 181 |
197 | 182 startTests("ValidateChain_NB"); |
198 PKIX_TEST_STD_VARS(); | 183 |
199 | 184 PKIX_TEST_EXPECT_NO_ERROR( |
200 if (argc < 5) { | 185 PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext)); |
201 printUsage(); | 186 |
202 return (0); | 187 /* ENE = expect no error; EE = expect error */ |
203 } | 188 if (PORT_Strcmp(argv[2 + j], "ENE") == 0) { |
204 | 189 testValid = PKIX_TRUE; |
205 startTests("ValidateChain_NB"); | 190 } else if (PORT_Strcmp(argv[2 + j], "EE") == 0) { |
206 | 191 testValid = PKIX_FALSE; |
207 PKIX_TEST_EXPECT_NO_ERROR( | 192 } else { |
208 PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext)); | 193 printUsage(); |
209 | 194 return (0); |
210 /* ENE = expect no error; EE = expect error */ | 195 } |
211 if (PORT_Strcmp(argv[2+j], "ENE") == 0) { | 196 |
212 testValid = PKIX_TRUE; | 197 subTest(argv[1 + j]); |
213 } else if (PORT_Strcmp(argv[2+j], "EE") == 0) { | 198 |
214 testValid = PKIX_FALSE; | 199 dirName = argv[3 + j]; |
215 } else { | 200 |
216 printUsage(); | 201 chainLength = argc - j - 5; |
217 return (0); | 202 |
218 } | 203 PKIX_TEST_EXPECT_NO_ERROR(PKIX_List_Create(&chainCerts, plContext)); |
219 | 204 |
220 subTest(argv[1+j]); | 205 for (k = 0; k < chainLength; k++) { |
221 | 206 |
222 dirName = argv[3+j]; | 207 dirCert = createCert(dirName, argv[5 + k + j], plContext); |
223 | 208 |
224 chainLength = argc - j - 5; | 209 PKIX_TEST_EXPECT_NO_ERROR( |
225 | 210 PKIX_List_AppendItem(chainCerts, (PKIX_PL_Object *)dirCert, plContext)); |
226 PKIX_TEST_EXPECT_NO_ERROR(PKIX_List_Create(&chainCerts, plContext)); | 211 |
227 | 212 PKIX_TEST_DECREF_BC(dirCert); |
228 for (k = 0; k < chainLength; k++){ | 213 } |
229 | 214 |
230 dirCert = createCert(dirName, argv[5+k+j], plContext); | 215 valParams = createValidateParams(dirName, argv[4 + j], NULL, NULL, NULL, |
231 | 216 PKIX_FALSE, PKIX_FALSE, PKIX_FALSE, |
232 PKIX_TEST_EXPECT_NO_ERROR | 217 PKIX_FALSE, chainCerts, plContext); |
233 (PKIX_List_AppendItem | 218 |
234 (chainCerts, (PKIX_PL_Object *)dirCert, plContext)); | 219 ldapName = PR_GetEnv("LDAP"); |
235 | 220 /* Is LDAP set in the environment? */ |
236 PKIX_TEST_DECREF_BC(dirCert); | 221 if ((ldapName == NULL) || (*ldapName == '\0')) { |
237 } | 222 testError("LDAP not set in environment"); |
238 | 223 goto cleanup; |
239 valParams = createValidateParams | 224 } |
240 (dirName, | 225 |
241 argv[4+j], | 226 pkixTestErrorResult = pkix_pl_Socket_CreateByName( |
242 NULL, | 227 PKIX_FALSE, /* isServer */ |
243 NULL, | 228 PR_SecondsToInterval(30), /* try 30 secs for connect */ |
244 NULL, | 229 ldapName, &errorCode, &socket, plContext); |
245 PKIX_FALSE, | 230 |
246 PKIX_FALSE, | 231 if (pkixTestErrorResult != NULL) { |
247 PKIX_FALSE, | 232 PKIX_PL_Object_DecRef((PKIX_PL_Object *)pkixTestErrorResult, plContext); |
248 PKIX_FALSE, | 233 pkixTestErrorResult = NULL; |
249 chainCerts, | 234 testError("Unable to connect to LDAP Server"); |
250 plContext); | 235 goto cleanup; |
251 | 236 } |
252 ldapName = PR_GetEnv("LDAP"); | 237 |
253 /* Is LDAP set in the environment? */ | 238 PKIX_TEST_DECREF_BC(socket); |
254 if ((ldapName == NULL) || (*ldapName == '\0')) { | 239 |
255 testError("LDAP not set in environment"); | 240 testSetupCertStore(valParams, ldapName); |
256 goto cleanup; | 241 |
257 } | 242 logging = PR_GetEnv("LOGGING"); |
258 | 243 /* Is LOGGING set in the environment? */ |
259 pkixTestErrorResult = pkix_pl_Socket_CreateByName | 244 if ((logging != NULL) && (*logging != '\0')) { |
260 (PKIX_FALSE, /* isServer */ | 245 |
261 PR_SecondsToInterval(30), /* try 30 secs for connect */ | 246 PKIX_TEST_EXPECT_NO_ERROR(PKIX_List_Create(&loggers, plContext)); |
262 ldapName, | 247 |
263 &errorCode, | 248 testLogErrors(PKIX_VALIDATE_ERROR, 2, loggers, plContext); |
264 &socket, | 249 testLogErrors(PKIX_CERTCHAINCHECKER_ERROR, 2, loggers, plContext); |
265 plContext); | 250 testLogErrors(PKIX_LDAPDEFAULTCLIENT_ERROR, 2, loggers, plContext); |
266 | 251 testLogErrors(PKIX_CERTSTORE_ERROR, 2, loggers, plContext); |
267 if (pkixTestErrorResult != NULL) { | 252 |
268 PKIX_PL_Object_DecRef | 253 PKIX_TEST_EXPECT_NO_ERROR(PKIX_SetLoggers(loggers, plContext)); |
269 ((PKIX_PL_Object *)pkixTestErrorResult, plContext); | 254 } |
270 pkixTestErrorResult = NULL; | 255 |
271 testError("Unable to connect to LDAP Server"); | 256 pkixTestErrorResult = PKIX_ValidateChain_NB( |
272 goto cleanup; | 257 valParams, &certIndex, &anchorIndex, &checkerIndex, &revChecking, |
273 } | 258 &checkers, (void **)&pollDesc, &valResult, &verifyTree, plContext); |
274 | 259 |
275 PKIX_TEST_DECREF_BC(socket); | 260 while (pollDesc != NULL) { |
276 | 261 |
277 testSetupCertStore(valParams, ldapName); | 262 if (PR_Poll(pollDesc, 1, 0) < 0) { |
278 | 263 testError("PR_Poll failed"); |
279 logging = PR_GetEnv("LOGGING"); | 264 } |
280 /* Is LOGGING set in the environment? */ | 265 |
281 if ((logging != NULL) && (*logging != '\0')) { | 266 pkixTestErrorResult = PKIX_ValidateChain_NB( |
282 | 267 valParams, &certIndex, &anchorIndex, &checkerIndex, &revChecking, |
283 PKIX_TEST_EXPECT_NO_ERROR | 268 &checkers, (void **)&pollDesc, &valResult, &verifyTree, plContext); |
284 (PKIX_List_Create(&loggers, plContext)); | 269 } |
285 | 270 |
286 testLogErrors | 271 if (pkixTestErrorResult) { |
287 (PKIX_VALIDATE_ERROR, 2, loggers, plContext); | 272 if (testValid == PKIX_FALSE) {/* EE */ |
288 testLogErrors | 273 (void)printf("EXPECTED ERROR RECEIVED!\n"); |
289 (PKIX_CERTCHAINCHECKER_ERROR, 2, loggers, plContext); | 274 } else {/* ENE */ |
290 testLogErrors | 275 testError("UNEXPECTED ERROR RECEIVED"); |
291 (PKIX_LDAPDEFAULTCLIENT_ERROR, 2, loggers, plContext); | 276 } |
292 testLogErrors | 277 PKIX_TEST_DECREF_BC(pkixTestErrorResult); |
293 (PKIX_CERTSTORE_ERROR, 2, loggers, plContext); | 278 } else { |
294 | 279 |
295 PKIX_TEST_EXPECT_NO_ERROR(PKIX_SetLoggers(loggers, plContext)); | 280 if (testValid == PKIX_TRUE) {/* ENE */ |
296 | 281 (void)printf("EXPECTED NON-ERROR RECEIVED!\n"); |
297 } | 282 } else {/* EE */ |
298 | 283 (void)printf("UNEXPECTED NON-ERROR RECEIVED!\n"); |
299 pkixTestErrorResult = PKIX_ValidateChain_NB | 284 } |
300 (valParams, | 285 } |
301 &certIndex, | 286 |
302 &anchorIndex, | 287 cleanup: |
303 &checkerIndex, | 288 |
304 &revChecking, | 289 if (verifyTree) { |
305 &checkers, | 290 PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_Object_ToString( |
306 (void **)&pollDesc, | 291 (PKIX_PL_Object *)verifyTree, &verifyString, plContext)); |
307 &valResult, | 292 (void)printf("verifyTree is\n%s\n", verifyString->escAsciiString); |
308 &verifyTree, | 293 } |
309 plContext); | 294 |
310 | 295 PKIX_TEST_DECREF_AC(verifyString); |
311 while (pollDesc != NULL) { | 296 PKIX_TEST_DECREF_AC(verifyTree); |
312 | 297 PKIX_TEST_DECREF_AC(checkers); |
313 if (PR_Poll(pollDesc, 1, 0) < 0) { | 298 PKIX_TEST_DECREF_AC(chainCerts); |
314 testError("PR_Poll failed"); | 299 PKIX_TEST_DECREF_AC(valParams); |
315 } | 300 PKIX_TEST_DECREF_AC(valResult); |
316 | 301 |
317 pkixTestErrorResult = PKIX_ValidateChain_NB | 302 PKIX_Shutdown(plContext); |
318 (valParams, | 303 |
319 &certIndex, | 304 PKIX_TEST_RETURN(); |
320 &anchorIndex, | 305 |
321 &checkerIndex, | 306 endTests("ValidateChain_NB"); |
322 &revChecking, | 307 |
323 &checkers, | 308 return (0); |
324 (void **)&pollDesc, | 309 } |
325 &valResult, | |
326 &verifyTree, | |
327 plContext); | |
328 } | |
329 | |
330 if (pkixTestErrorResult) { | |
331 if (testValid == PKIX_FALSE) { /* EE */ | |
332 (void) printf("EXPECTED ERROR RECEIVED!\n"); | |
333 } else { /* ENE */ | |
334 testError("UNEXPECTED ERROR RECEIVED"); | |
335 } | |
336 PKIX_TEST_DECREF_BC(pkixTestErrorResult); | |
337 } else { | |
338 | |
339 if (testValid == PKIX_TRUE) { /* ENE */ | |
340 (void) printf("EXPECTED NON-ERROR RECEIVED!\n"); | |
341 } else { /* EE */ | |
342 (void) printf("UNEXPECTED NON-ERROR RECEIVED!\n"); | |
343 } | |
344 } | |
345 | |
346 cleanup: | |
347 | |
348 if (verifyTree) { | |
349 PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_Object_ToString | |
350 ((PKIX_PL_Object*)verifyTree, &verifyString, plContext)); | |
351 (void) printf("verifyTree is\n%s\n", | |
352 verifyString->escAsciiString); | |
353 } | |
354 | |
355 PKIX_TEST_DECREF_AC(verifyString); | |
356 PKIX_TEST_DECREF_AC(verifyTree); | |
357 PKIX_TEST_DECREF_AC(checkers); | |
358 PKIX_TEST_DECREF_AC(chainCerts); | |
359 PKIX_TEST_DECREF_AC(valParams); | |
360 PKIX_TEST_DECREF_AC(valResult); | |
361 | |
362 PKIX_Shutdown(plContext); | |
363 | |
364 PKIX_TEST_RETURN(); | |
365 | |
366 endTests("ValidateChain_NB"); | |
367 | |
368 return (0); | |
369 } | |
OLD | NEW |