Mercurial > trustbridge > nss-cmake-static
comparison nss/lib/libpkix/pkix/params/pkix_valparams.c @ 0:1e5118fa0cb1
This is NSS with a Cmake Buildsyste
To compile a static NSS library for Windows we've used the
Chromium-NSS fork and added a Cmake buildsystem to compile
it statically for Windows. See README.chromium for chromium
changes and README.trustbridge for our modifications.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Mon, 28 Jul 2014 10:47:06 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:1e5118fa0cb1 |
---|---|
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 | |
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | |
4 /* | |
5 * pkix_valparams.c | |
6 * | |
7 * Validate Params Object Functions | |
8 * | |
9 */ | |
10 | |
11 #include "pkix_valparams.h" | |
12 | |
13 /* --Private-Functions-------------------------------------------- */ | |
14 | |
15 /* | |
16 * FUNCTION: pkix_ValidateParams_Destroy | |
17 * (see comments for PKIX_PL_DestructorCallback in pkix_pl_system.h) | |
18 */ | |
19 static PKIX_Error * | |
20 pkix_ValidateParams_Destroy( | |
21 PKIX_PL_Object *object, | |
22 void *plContext) | |
23 { | |
24 PKIX_ValidateParams *params = NULL; | |
25 | |
26 PKIX_ENTER(VALIDATEPARAMS, "pkix_ValidateParams_Destroy"); | |
27 PKIX_NULLCHECK_ONE(object); | |
28 | |
29 /* Check that this object is a validate params object */ | |
30 PKIX_CHECK(pkix_CheckType(object, PKIX_VALIDATEPARAMS_TYPE, plContext), | |
31 PKIX_OBJECTNOTVALIDATEPARAMS); | |
32 | |
33 params = (PKIX_ValidateParams *)object; | |
34 | |
35 PKIX_DECREF(params->procParams); | |
36 PKIX_DECREF(params->chain); | |
37 | |
38 cleanup: | |
39 | |
40 PKIX_RETURN(VALIDATEPARAMS); | |
41 } | |
42 | |
43 /* | |
44 * FUNCTION: pkix_ValidateParams_Equals | |
45 * (see comments for PKIX_PL_EqualsCallback in pkix_pl_system.h) | |
46 */ | |
47 static PKIX_Error * | |
48 pkix_ValidateParams_Equals( | |
49 PKIX_PL_Object *first, | |
50 PKIX_PL_Object *second, | |
51 PKIX_Boolean *pResult, | |
52 void *plContext) | |
53 { | |
54 PKIX_UInt32 secondType; | |
55 PKIX_Boolean cmpResult; | |
56 PKIX_ValidateParams *firstValParams = NULL; | |
57 PKIX_ValidateParams *secondValParams = NULL; | |
58 | |
59 PKIX_ENTER(VALIDATEPARAMS, "pkix_ValidateParams_Equals"); | |
60 PKIX_NULLCHECK_THREE(first, second, pResult); | |
61 | |
62 PKIX_CHECK(pkix_CheckType(first, PKIX_VALIDATEPARAMS_TYPE, plContext), | |
63 PKIX_FIRSTOBJECTNOTVALIDATEPARAMS); | |
64 | |
65 PKIX_CHECK(PKIX_PL_Object_GetType(second, &secondType, plContext), | |
66 PKIX_COULDNOTGETTYPEOFSECONDARGUMENT); | |
67 | |
68 *pResult = PKIX_FALSE; | |
69 | |
70 if (secondType != PKIX_VALIDATEPARAMS_TYPE) goto cleanup; | |
71 | |
72 firstValParams = (PKIX_ValidateParams *)first; | |
73 secondValParams = (PKIX_ValidateParams *)second; | |
74 | |
75 PKIX_CHECK(PKIX_PL_Object_Equals | |
76 ((PKIX_PL_Object *)firstValParams->procParams, | |
77 (PKIX_PL_Object *)secondValParams->procParams, | |
78 &cmpResult, | |
79 plContext), | |
80 PKIX_OBJECTEQUALSFAILED); | |
81 | |
82 if (!cmpResult) goto cleanup; | |
83 | |
84 PKIX_CHECK(PKIX_PL_Object_Equals | |
85 ((PKIX_PL_Object *)firstValParams->chain, | |
86 (PKIX_PL_Object *)secondValParams->chain, | |
87 &cmpResult, | |
88 plContext), | |
89 PKIX_OBJECTEQUALSFAILED); | |
90 | |
91 if (!cmpResult) goto cleanup; | |
92 | |
93 *pResult = cmpResult; | |
94 | |
95 cleanup: | |
96 | |
97 PKIX_RETURN(VALIDATEPARAMS); | |
98 } | |
99 | |
100 /* | |
101 * FUNCTION: pkix_ValidateParams_Hashcode | |
102 * (see comments for PKIX_PL_HashcodeCallback in pkix_pl_system.h) | |
103 */ | |
104 static PKIX_Error * | |
105 pkix_ValidateParams_Hashcode( | |
106 PKIX_PL_Object *object, | |
107 PKIX_UInt32 *pHashcode, | |
108 void *plContext) | |
109 { | |
110 PKIX_ValidateParams *valParams = NULL; | |
111 PKIX_UInt32 hash = 0; | |
112 PKIX_UInt32 procParamsHash = 0; | |
113 PKIX_UInt32 chainHash = 0; | |
114 | |
115 PKIX_ENTER(VALIDATEPARAMS, "pkix_ValidateParams_Hashcode"); | |
116 PKIX_NULLCHECK_TWO(object, pHashcode); | |
117 | |
118 PKIX_CHECK(pkix_CheckType(object, PKIX_VALIDATEPARAMS_TYPE, plContext), | |
119 PKIX_OBJECTNOTVALIDATEPARAMS); | |
120 | |
121 valParams = (PKIX_ValidateParams*)object; | |
122 | |
123 PKIX_CHECK(PKIX_PL_Object_Hashcode | |
124 ((PKIX_PL_Object *)valParams->procParams, | |
125 &procParamsHash, | |
126 plContext), | |
127 PKIX_OBJECTHASHCODEFAILED); | |
128 | |
129 PKIX_CHECK(PKIX_PL_Object_Hashcode | |
130 ((PKIX_PL_Object *)valParams->chain, | |
131 &chainHash, | |
132 plContext), | |
133 PKIX_OBJECTHASHCODEFAILED); | |
134 | |
135 hash = 31 * procParamsHash + chainHash; | |
136 | |
137 *pHashcode = hash; | |
138 | |
139 cleanup: | |
140 | |
141 PKIX_RETURN(VALIDATEPARAMS); | |
142 } | |
143 | |
144 /* | |
145 * FUNCTION: pkix_ValidateParams_ToString | |
146 * (see comments for PKIX_PL_ToStringCallback in pkix_pl_system.h) | |
147 */ | |
148 static PKIX_Error * | |
149 pkix_ValidateParams_ToString( | |
150 PKIX_PL_Object *object, | |
151 PKIX_PL_String **pString, | |
152 void *plContext) | |
153 { | |
154 PKIX_ValidateParams *valParams = NULL; | |
155 char *asciiFormat = NULL; | |
156 PKIX_PL_String *formatString = NULL; | |
157 PKIX_PL_String *valParamsString = NULL; | |
158 | |
159 PKIX_PL_String *procParamsString = NULL; | |
160 PKIX_PL_String *chainString = NULL; | |
161 | |
162 PKIX_ENTER(VALIDATEPARAMS, "pkix_ValidateParams_ToString"); | |
163 PKIX_NULLCHECK_TWO(object, pString); | |
164 | |
165 PKIX_CHECK(pkix_CheckType(object, PKIX_VALIDATEPARAMS_TYPE, plContext), | |
166 PKIX_OBJECTNOTVALIDATEPARAMS); | |
167 | |
168 asciiFormat = | |
169 "[\n" | |
170 "\tProcessing Params: \n" | |
171 "\t********BEGIN PROCESSING PARAMS********\n" | |
172 "\t\t%s\n" | |
173 "\t********END PROCESSING PARAMS********\n" | |
174 "\tChain: \t\t%s\n" | |
175 "]\n"; | |
176 | |
177 PKIX_CHECK(PKIX_PL_String_Create | |
178 (PKIX_ESCASCII, | |
179 asciiFormat, | |
180 0, | |
181 &formatString, | |
182 plContext), | |
183 PKIX_STRINGCREATEFAILED); | |
184 | |
185 valParams = (PKIX_ValidateParams*)object; | |
186 | |
187 PKIX_CHECK(PKIX_PL_Object_ToString | |
188 ((PKIX_PL_Object*)valParams->procParams, | |
189 &procParamsString, | |
190 plContext), | |
191 PKIX_OBJECTTOSTRINGFAILED); | |
192 | |
193 PKIX_CHECK(PKIX_PL_Object_ToString | |
194 ((PKIX_PL_Object *)valParams->chain, | |
195 &chainString, | |
196 plContext), | |
197 PKIX_OBJECTTOSTRINGFAILED); | |
198 | |
199 PKIX_CHECK(PKIX_PL_Sprintf | |
200 (&valParamsString, | |
201 plContext, | |
202 formatString, | |
203 procParamsString, | |
204 chainString), | |
205 PKIX_SPRINTFFAILED); | |
206 | |
207 *pString = valParamsString; | |
208 | |
209 cleanup: | |
210 | |
211 PKIX_DECREF(formatString); | |
212 PKIX_DECREF(procParamsString); | |
213 PKIX_DECREF(chainString); | |
214 | |
215 PKIX_RETURN(VALIDATEPARAMS); | |
216 } | |
217 | |
218 /* | |
219 * FUNCTION: pkix_ValidateParams_RegisterSelf | |
220 * DESCRIPTION: | |
221 * Registers PKIX_VALIDATEPARAMS_TYPE and its related functions with | |
222 * systemClasses[] | |
223 * THREAD SAFETY: | |
224 * Not Thread Safe - for performance and complexity reasons | |
225 * | |
226 * Since this function is only called by PKIX_PL_Initialize, which should | |
227 * only be called once, it is acceptable that this function is not | |
228 * thread-safe. | |
229 */ | |
230 PKIX_Error * | |
231 pkix_ValidateParams_RegisterSelf(void *plContext) | |
232 { | |
233 | |
234 extern pkix_ClassTable_Entry systemClasses[PKIX_NUMTYPES]; | |
235 pkix_ClassTable_Entry entry; | |
236 | |
237 PKIX_ENTER(VALIDATEPARAMS, "pkix_ValidateParams_RegisterSelf"); | |
238 | |
239 entry.description = "ValidateParams"; | |
240 entry.objCounter = 0; | |
241 entry.typeObjectSize = sizeof(PKIX_ValidateParams); | |
242 entry.destructor = pkix_ValidateParams_Destroy; | |
243 entry.equalsFunction = pkix_ValidateParams_Equals; | |
244 entry.hashcodeFunction = pkix_ValidateParams_Hashcode; | |
245 entry.toStringFunction = pkix_ValidateParams_ToString; | |
246 entry.comparator = NULL; | |
247 entry.duplicateFunction = NULL; | |
248 | |
249 systemClasses[PKIX_VALIDATEPARAMS_TYPE] = entry; | |
250 | |
251 PKIX_RETURN(VALIDATEPARAMS); | |
252 } | |
253 | |
254 /* --Public-Functions--------------------------------------------- */ | |
255 | |
256 /* | |
257 * FUNCTION: PKIX_ValidateParams_Create (see comments in pkix_params.h) | |
258 */ | |
259 PKIX_Error * | |
260 PKIX_ValidateParams_Create( | |
261 PKIX_ProcessingParams *procParams, | |
262 PKIX_List *chain, | |
263 PKIX_ValidateParams **pParams, | |
264 void *plContext) | |
265 { | |
266 PKIX_ValidateParams *params = NULL; | |
267 | |
268 PKIX_ENTER(VALIDATEPARAMS, "PKIX_ValidateParams_Create"); | |
269 PKIX_NULLCHECK_THREE(procParams, chain, pParams); | |
270 | |
271 PKIX_CHECK(PKIX_PL_Object_Alloc | |
272 (PKIX_VALIDATEPARAMS_TYPE, | |
273 sizeof (PKIX_ValidateParams), | |
274 (PKIX_PL_Object **)¶ms, | |
275 plContext), | |
276 PKIX_COULDNOTCREATEVALIDATEPARAMSOBJECT); | |
277 | |
278 /* initialize fields */ | |
279 PKIX_INCREF(procParams); | |
280 params->procParams = procParams; | |
281 | |
282 PKIX_INCREF(chain); | |
283 params->chain = chain; | |
284 | |
285 *pParams = params; | |
286 params = NULL; | |
287 | |
288 cleanup: | |
289 | |
290 PKIX_DECREF(params); | |
291 | |
292 PKIX_RETURN(VALIDATEPARAMS); | |
293 | |
294 } | |
295 | |
296 /* | |
297 * FUNCTION: PKIX_ValidateParams_GetProcessingParams | |
298 * (see comments in pkix_params.h) | |
299 */ | |
300 PKIX_Error * | |
301 PKIX_ValidateParams_GetProcessingParams( | |
302 PKIX_ValidateParams *valParams, | |
303 PKIX_ProcessingParams **pProcParams, | |
304 void *plContext) | |
305 { | |
306 PKIX_ENTER(VALIDATEPARAMS, "PKIX_ValidateParams_GetProcessingParams"); | |
307 PKIX_NULLCHECK_TWO(valParams, pProcParams); | |
308 | |
309 PKIX_INCREF(valParams->procParams); | |
310 | |
311 *pProcParams = valParams->procParams; | |
312 | |
313 cleanup: | |
314 PKIX_RETURN(VALIDATEPARAMS); | |
315 } | |
316 | |
317 /* | |
318 * FUNCTION: PKIX_ValidateParams_GetCertChain (see comments in pkix_params.h) | |
319 */ | |
320 PKIX_Error * | |
321 PKIX_ValidateParams_GetCertChain( | |
322 PKIX_ValidateParams *valParams, | |
323 PKIX_List **pChain, | |
324 void *plContext) | |
325 { | |
326 PKIX_ENTER(VALIDATEPARAMS, "PKIX_ValidateParams_GetCertChain"); | |
327 PKIX_NULLCHECK_TWO(valParams, pChain); | |
328 | |
329 PKIX_INCREF(valParams->chain); | |
330 | |
331 *pChain = valParams->chain; | |
332 | |
333 cleanup: | |
334 PKIX_RETURN(VALIDATEPARAMS); | |
335 } |