1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
14 * The Original Code is the PKIX-C library.
16 * The Initial Developer of the Original Code is
17 * Sun Microsystems, Inc.
18 * Portions created by the Initial Developer are
19 * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
22 * Sun Microsystems, Inc.
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
40 * Test ValidateParams Type
45 #include "testutil_nss.h"
47 static void *plContext = NULL;
50 testDestroy(void *goodObject, void *equalObject, void *diffObject)
54 subTest("PKIX_ValidateParams_Destroy");
56 PKIX_TEST_DECREF_BC(goodObject);
57 PKIX_TEST_DECREF_BC(equalObject);
58 PKIX_TEST_DECREF_BC(diffObject);
67 void testGetProcParams(
68 PKIX_ValidateParams *goodObject,
69 PKIX_ValidateParams *equalObject){
71 PKIX_ProcessingParams *goodProcParams = NULL;
72 PKIX_ProcessingParams *equalProcParams = NULL;
75 subTest("PKIX_ValidateParams_GetProcessingParams");
77 PKIX_TEST_EXPECT_NO_ERROR(PKIX_ValidateParams_GetProcessingParams
78 (goodObject, &goodProcParams, plContext));
80 PKIX_TEST_EXPECT_NO_ERROR(PKIX_ValidateParams_GetProcessingParams
81 (equalObject, &equalProcParams, plContext));
84 ((PKIX_PL_Object *)goodProcParams,
85 (PKIX_PL_Object *)equalProcParams,
91 PKIX_TEST_DECREF_AC(goodProcParams);
92 PKIX_TEST_DECREF_AC(equalProcParams);
99 void testGetCertChain(
100 PKIX_ValidateParams *goodObject,
101 PKIX_ValidateParams *equalObject){
103 PKIX_List *goodChain = NULL;
104 PKIX_List *equalChain = NULL;
106 PKIX_TEST_STD_VARS();
107 subTest("PKIX_ValidateParams_GetCertChain");
109 PKIX_TEST_EXPECT_NO_ERROR(PKIX_ValidateParams_GetCertChain
110 (goodObject, &goodChain, plContext));
112 PKIX_TEST_EXPECT_NO_ERROR(PKIX_ValidateParams_GetCertChain
113 (equalObject, &equalChain, plContext));
116 ((PKIX_PL_Object *)goodChain,
117 (PKIX_PL_Object *)equalChain,
123 PKIX_TEST_DECREF_AC(goodChain);
124 PKIX_TEST_DECREF_AC(equalChain);
130 void printUsage(char *pName){
131 printf("\nUSAGE: %s <central-data-dir>\n\n", pName);
134 int test_valparams(int argc, char *argv[]) {
136 PKIX_ValidateParams *goodObject = NULL;
137 PKIX_ValidateParams *equalObject = NULL;
138 PKIX_ValidateParams *diffObject = NULL;
139 PKIX_List *chain = NULL;
140 PKIX_UInt32 actualMinorVersion;
142 char *dirName = NULL;
144 char *goodInput = "yassir2yassir";
145 char *diffInput = "yassir2bcn";
147 char *expectedAscii =
149 "\tProcessing Params: \n"
150 "\t********BEGIN PROCESSING PARAMS********\n"
153 "\tTrust Anchors: \n"
154 "\t********BEGIN LIST OF TRUST ANCHORS********\n"
157 "\tTrusted CA Name: "
158 "CN=yassir,OU=bcn,OU=east,O=sun,C=us\n"
159 "\tTrusted CA PublicKey: ANSI X9.57 DSA Signature\n"
160 "\tInitial Name Constraints:(null)\n"
163 "\tTrusted CA Name: OU=bcn,OU=east,O=sun,C=us\n"
164 "\tTrusted CA PublicKey: ANSI X9.57 DSA Signature\n"
165 "\tInitial Name Constraints:(null)\n"
168 "\t********END LIST OF TRUST ANCHORS********\n"
169 "\tDate: \t\t(null)\n"
170 "\tTarget Constraints: (null)\n"
171 "\tInitial Policies: (null)\n"
172 "\tQualifiers Rejected: FALSE\n"
173 "\tCert Stores: (EMPTY)\n"
174 "\tCRL Checking Enabled: 0\n"
177 "\t********END PROCESSING PARAMS********\n"
181 "\tSerialNumber: 37bc66ec\n"
182 "\tIssuer: CN=yassir,OU=bcn,OU=east,O=sun,C=us\n"
183 "\tSubject: OU=bcn,OU=east,O=sun,C=us\n"
184 "\tValidity: [From: Thu Aug 19 16:19:56 1999\n"
185 "\t To: Fri Aug 18 16:19:56 2000]\n"
186 "\tSubjectAltNames: (null)\n"
187 "\tAuthorityKeyId: (null)\n"
188 "\tSubjectKeyId: (null)\n"
189 "\tSubjPubKeyAlgId: ANSI X9.57 DSA Signature\n"
190 "\tCritExtOIDs: (2.5.29.15, 2.5.29.19)\n"
191 "\tExtKeyUsages: (null)\n"
192 "\tBasicConstraint: CA(0)\n"
193 "\tCertPolicyInfo: (null)\n"
194 "\tPolicyMappings: (null)\n"
195 "\tExplicitPolicy: -1\n"
196 "\tInhibitMapping: -1\n"
197 "\tInhibitAnyPolicy:-1\n"
198 "\tNameConstraints: (null)\n"
202 "\tSerialNumber: 37bc65af\n"
203 "\tIssuer: CN=yassir,OU=bcn,OU=east,O=sun,C=us\n"
204 "\tSubject: CN=yassir,OU=bcn,OU=east,O=sun,C=us\n"
205 "\tValidity: [From: Thu Aug 19 16:14:39 1999\n"
206 "\t To: Fri Aug 18 16:14:39 2000]\n"
207 "\tSubjectAltNames: (null)\n"
208 "\tAuthorityKeyId: (null)\n"
209 "\tSubjectKeyId: (null)\n"
210 "\tSubjPubKeyAlgId: ANSI X9.57 DSA Signature\n"
211 "\tCritExtOIDs: (2.5.29.15, 2.5.29.19)\n"
212 "\tExtKeyUsages: (null)\n"
213 "\tBasicConstraint: CA(0)\n"
214 "\tCertPolicyInfo: (null)\n"
215 "\tPolicyMappings: (null)\n"
216 "\tExplicitPolicy: -1\n"
217 "\tInhibitMapping: -1\n"
218 "\tInhibitAnyPolicy:-1\n"
219 "\tNameConstraints: (null)\n"
224 PKIX_TEST_STD_VARS();
226 startTests("ValidateParams");
228 PKIX_TEST_EXPECT_NO_ERROR(
229 PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
238 subTest("PKIX_ValidateParams_Create");
239 chain = createCertChain(dirName, diffInput, goodInput, plContext);
240 goodObject = createValidateParams
252 equalObject = createValidateParams
264 diffObject = createValidateParams
277 testGetProcParams(goodObject, equalObject);
278 testGetCertChain(goodObject, equalObject);
280 PKIX_TEST_EQ_HASH_TOSTR_DUP
284 NULL, /* expectedAscii, */
288 testDestroy(goodObject, equalObject, diffObject);
292 PKIX_TEST_DECREF_AC(chain);
294 PKIX_Shutdown(plContext);
298 endTests("ValidateParams");