1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/security/nss/lib/libpkix/pkix/crlsel/pkix_comcrlselparams.c Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,826 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 +/* 1.8 + * pkix_comcrlselparams.c 1.9 + * 1.10 + * ComCRLSelParams Function Definitions 1.11 + * 1.12 + */ 1.13 + 1.14 +#include "pkix_comcrlselparams.h" 1.15 + 1.16 +/* --ComCRLSelParams-Private-Functions------------------------------------ */ 1.17 + 1.18 +/* 1.19 + * FUNCTION: pkix_ComCrlSelParams_Destroy 1.20 + * (see comments for PKIX_PL_DestructorCallback in pkix_pl_system.h) 1.21 + */ 1.22 +static PKIX_Error * 1.23 +pkix_ComCRLSelParams_Destroy( 1.24 + PKIX_PL_Object *object, 1.25 + void *plContext) 1.26 +{ 1.27 + PKIX_ComCRLSelParams *params = NULL; 1.28 + 1.29 + PKIX_ENTER(COMCRLSELPARAMS, "pkix_ComCRLSelParams_Destroy"); 1.30 + PKIX_NULLCHECK_ONE(object); 1.31 + 1.32 + PKIX_CHECK(pkix_CheckType 1.33 + (object, PKIX_COMCRLSELPARAMS_TYPE, plContext), 1.34 + PKIX_OBJECTNOTCOMCRLSELPARAMS); 1.35 + 1.36 + params = (PKIX_ComCRLSelParams *)object; 1.37 + 1.38 + PKIX_DECREF(params->issuerNames); 1.39 + PKIX_DECREF(params->cert); 1.40 + PKIX_DECREF(params->date); 1.41 + PKIX_DECREF(params->maxCRLNumber); 1.42 + PKIX_DECREF(params->minCRLNumber); 1.43 + PKIX_DECREF(params->crldpList); 1.44 + 1.45 +cleanup: 1.46 + 1.47 + PKIX_RETURN(COMCRLSELPARAMS); 1.48 +} 1.49 + 1.50 +/* 1.51 + * FUNCTION: pkix_ComCRLSelParams_ToString_Helper 1.52 + * DESCRIPTION: 1.53 + * 1.54 + * Helper function that creates a string representation of ComCRLSelParams 1.55 + * pointed to by "crlParams" and stores the result at "pString". 1.56 + * 1.57 + * PARAMETERS 1.58 + * "crlParams" 1.59 + * Address of ComCRLSelParams whose string representation is desired. 1.60 + * Must be non-NULL. 1.61 + * "pString" 1.62 + * Address of object pointer's destination. Must be non-NULL. 1.63 + * "plContext" - Platform-specific context pointer. 1.64 + * 1.65 + * THREAD SAFETY: 1.66 + * Conditionally Thread Safe 1.67 + * (see Thread Safety Definitions in Programmer's Guide) 1.68 + * 1.69 + * RETURNS: 1.70 + * Returns NULL if the function succeeds. 1.71 + * Returns a CRLEntry Error if the function fails in a non-fatal way. 1.72 + * Returns a Fatal Error if the function fails in an unrecoverable way. 1.73 + */ 1.74 +static PKIX_Error * 1.75 +pkix_ComCRLSelParams_ToString_Helper( 1.76 + PKIX_ComCRLSelParams *crlParams, 1.77 + PKIX_PL_String **pString, 1.78 + void *plContext) 1.79 +{ 1.80 + PKIX_PL_String *crlIssuerNamesString = NULL; 1.81 + PKIX_PL_String *crlDateString = NULL; 1.82 + PKIX_PL_String *crlMaxCRLNumberString = NULL; 1.83 + PKIX_PL_String *crlMinCRLNumberString = NULL; 1.84 + PKIX_PL_String *crlCertString = NULL; 1.85 + PKIX_PL_String *crlParamsString = NULL; 1.86 + char *asciiFormat = NULL; 1.87 + PKIX_PL_String *formatString = NULL; 1.88 + 1.89 + PKIX_ENTER(COMCRLSELPARAMS, "pkix_ComCRLSelParams_ToString_Helper"); 1.90 + PKIX_NULLCHECK_TWO(crlParams, pString); 1.91 + 1.92 + asciiFormat = 1.93 + "\n\t[\n" 1.94 + "\tIssuerNames: %s\n" 1.95 + "\tDate: %s\n" 1.96 + "\tmaxCRLNumber: %s\n" 1.97 + "\tminCRLNumber: %s\n" 1.98 + "\tCertificate: %s\n" 1.99 + "\t]\n"; 1.100 + 1.101 + PKIX_CHECK(PKIX_PL_String_Create 1.102 + (PKIX_ESCASCII, 1.103 + asciiFormat, 1.104 + 0, 1.105 + &formatString, 1.106 + plContext), 1.107 + PKIX_STRINGCREATEFAILED); 1.108 + 1.109 + PKIX_TOSTRING 1.110 + (crlParams->issuerNames, &crlIssuerNamesString, plContext, 1.111 + PKIX_LISTTOSTRINGFAILED); 1.112 + 1.113 + PKIX_TOSTRING(crlParams->date, &crlDateString, plContext, 1.114 + PKIX_DATETOSTRINGFAILED); 1.115 + 1.116 + PKIX_TOSTRING 1.117 + (crlParams->maxCRLNumber, &crlMaxCRLNumberString, plContext, 1.118 + PKIX_BIGINTTOSTRINGFAILED); 1.119 + 1.120 + PKIX_TOSTRING 1.121 + (crlParams->minCRLNumber, &crlMinCRLNumberString, plContext, 1.122 + PKIX_BIGINTTOSTRINGFAILED); 1.123 + 1.124 + PKIX_TOSTRING(crlParams->cert, &crlCertString, plContext, 1.125 + PKIX_CERTTOSTRINGFAILED); 1.126 + 1.127 + PKIX_CHECK(PKIX_PL_Sprintf 1.128 + (&crlParamsString, 1.129 + plContext, 1.130 + formatString, 1.131 + crlIssuerNamesString, 1.132 + crlDateString, 1.133 + crlMaxCRLNumberString, 1.134 + crlMinCRLNumberString, 1.135 + crlCertString), 1.136 + PKIX_SPRINTFFAILED); 1.137 + 1.138 + *pString = crlParamsString; 1.139 + 1.140 +cleanup: 1.141 + 1.142 + PKIX_DECREF(crlIssuerNamesString); 1.143 + PKIX_DECREF(crlDateString); 1.144 + PKIX_DECREF(crlMaxCRLNumberString); 1.145 + PKIX_DECREF(crlMinCRLNumberString); 1.146 + PKIX_DECREF(crlCertString); 1.147 + PKIX_DECREF(formatString); 1.148 + 1.149 + PKIX_RETURN(COMCRLSELPARAMS); 1.150 +} 1.151 + 1.152 +/* 1.153 + * FUNCTION: pkix_ComCRLSelParams_ToString 1.154 + * (see comments for PKIX_PL_ToStringCallback in pkix_pl_system.h) 1.155 + */ 1.156 +static PKIX_Error * 1.157 +pkix_ComCRLSelParams_ToString( 1.158 + PKIX_PL_Object *object, 1.159 + PKIX_PL_String **pString, 1.160 + void *plContext) 1.161 +{ 1.162 + PKIX_PL_String *crlParamsString = NULL; 1.163 + PKIX_ComCRLSelParams *crlParams = NULL; 1.164 + 1.165 + PKIX_ENTER(COMCRLSELPARAMS, "pkix_ComCRLSelParams_ToString"); 1.166 + PKIX_NULLCHECK_TWO(object, pString); 1.167 + 1.168 + PKIX_CHECK(pkix_CheckType(object, PKIX_COMCRLSELPARAMS_TYPE, plContext), 1.169 + PKIX_OBJECTNOTCOMCRLSELPARAMS); 1.170 + 1.171 + crlParams = (PKIX_ComCRLSelParams *) object; 1.172 + 1.173 + PKIX_CHECK(pkix_ComCRLSelParams_ToString_Helper 1.174 + (crlParams, &crlParamsString, plContext), 1.175 + PKIX_COMCRLSELPARAMSTOSTRINGHELPERFAILED); 1.176 + 1.177 + *pString = crlParamsString; 1.178 + 1.179 +cleanup: 1.180 + 1.181 + PKIX_RETURN(COMCRLSELPARAMS); 1.182 +} 1.183 + 1.184 +/* 1.185 + * FUNCTION: pkix_ComCRLSelParams_Hashcode 1.186 + * (see comments for PKIX_PL_HashcodeCallback in pkix_pl_system.h) 1.187 + */ 1.188 +static PKIX_Error * 1.189 +pkix_ComCRLSelParams_Hashcode( 1.190 + PKIX_PL_Object *object, 1.191 + PKIX_UInt32 *pHashcode, 1.192 + void *plContext) 1.193 +{ 1.194 + PKIX_ComCRLSelParams *crlParams = NULL; 1.195 + PKIX_UInt32 namesHash = 0; 1.196 + PKIX_UInt32 certHash = 0; 1.197 + PKIX_UInt32 dateHash = 0; 1.198 + PKIX_UInt32 maxCRLNumberHash = 0; 1.199 + PKIX_UInt32 minCRLNumberHash = 0; 1.200 + PKIX_UInt32 hash = 0; 1.201 + 1.202 + PKIX_ENTER(COMCRLSELPARAMS, "pkix_ComCRLSelParams_Hashcode"); 1.203 + PKIX_NULLCHECK_TWO(object, pHashcode); 1.204 + 1.205 + PKIX_CHECK(pkix_CheckType(object, PKIX_COMCRLSELPARAMS_TYPE, plContext), 1.206 + PKIX_OBJECTNOTCOMCRLSELPARAMS); 1.207 + 1.208 + crlParams = (PKIX_ComCRLSelParams *)object; 1.209 + 1.210 + PKIX_HASHCODE(crlParams->issuerNames, &namesHash, plContext, 1.211 + PKIX_OBJECTHASHCODEFAILED); 1.212 + 1.213 + PKIX_HASHCODE(crlParams->cert, &certHash, plContext, 1.214 + PKIX_OBJECTHASHCODEFAILED); 1.215 + 1.216 + PKIX_HASHCODE(crlParams->date, &dateHash, plContext, 1.217 + PKIX_OBJECTHASHCODEFAILED); 1.218 + 1.219 + PKIX_HASHCODE(crlParams->maxCRLNumber, &maxCRLNumberHash, plContext, 1.220 + PKIX_OBJECTHASHCODEFAILED); 1.221 + 1.222 + PKIX_HASHCODE(crlParams->minCRLNumber, &minCRLNumberHash, plContext, 1.223 + PKIX_OBJECTHASHCODEFAILED); 1.224 + 1.225 + 1.226 + hash = (((namesHash << 3) + certHash) << 3) + dateHash; 1.227 + hash = (hash << 3) + maxCRLNumberHash + minCRLNumberHash; 1.228 + 1.229 + *pHashcode = hash; 1.230 + 1.231 +cleanup: 1.232 + 1.233 + PKIX_RETURN(COMCRLSELPARAMS); 1.234 +} 1.235 + 1.236 +/* 1.237 + * FUNCTION: pkix_ComCRLSelParams_Equals 1.238 + * (see comments for PKIX_PL_Equals_Callback in pkix_pl_system.h) 1.239 + */ 1.240 +static PKIX_Error * 1.241 +pkix_ComCRLSelParams_Equals( 1.242 + PKIX_PL_Object *firstObject, 1.243 + PKIX_PL_Object *secondObject, 1.244 + PKIX_Boolean *pResult, 1.245 + void *plContext) 1.246 +{ 1.247 + PKIX_ComCRLSelParams *firstCrlParams = NULL; 1.248 + PKIX_ComCRLSelParams *secondCrlParams = NULL; 1.249 + PKIX_UInt32 secondType; 1.250 + PKIX_Boolean cmpResult = PKIX_FALSE; 1.251 + 1.252 + PKIX_ENTER(COMCRLSELPARAMS, "pkix_ComCRLSelParams_Equals"); 1.253 + PKIX_NULLCHECK_THREE(firstObject, secondObject, pResult); 1.254 + 1.255 + /* test that firstObject is a ComCRLSelParams */ 1.256 + PKIX_CHECK(pkix_CheckType 1.257 + (firstObject, PKIX_COMCRLSELPARAMS_TYPE, plContext), 1.258 + PKIX_FIRSTOBJECTNOTCOMCRLSELPARAMS); 1.259 + 1.260 + firstCrlParams = (PKIX_ComCRLSelParams *)firstObject; 1.261 + secondCrlParams = (PKIX_ComCRLSelParams *)secondObject; 1.262 + 1.263 + /* 1.264 + * Since we know firstObject is a ComCRLSelParams, if both references 1.265 + * are identical, they must be equal 1.266 + */ 1.267 + if (firstCrlParams == secondCrlParams){ 1.268 + *pResult = PKIX_TRUE; 1.269 + goto cleanup; 1.270 + } 1.271 + 1.272 + /* 1.273 + * If secondComCRLSelParams isn't a ComCRLSelParams, we don't 1.274 + * throw an error. We simply return a Boolean result of FALSE 1.275 + */ 1.276 + *pResult = PKIX_FALSE; 1.277 + PKIX_CHECK(PKIX_PL_Object_GetType 1.278 + ((PKIX_PL_Object *)secondCrlParams, &secondType, plContext), 1.279 + PKIX_COULDNOTGETTYPEOFSECONDARGUMENT); 1.280 + 1.281 + if (secondType != PKIX_COMCRLSELPARAMS_TYPE) { 1.282 + goto cleanup; 1.283 + } 1.284 + 1.285 + /* Compare Issuer Names */ 1.286 + PKIX_EQUALS 1.287 + (firstCrlParams->issuerNames, 1.288 + secondCrlParams->issuerNames, 1.289 + &cmpResult, 1.290 + plContext, 1.291 + PKIX_LISTEQUALSFAILED); 1.292 + 1.293 + if (cmpResult != PKIX_TRUE) { 1.294 + goto cleanup; 1.295 + } 1.296 + 1.297 + /* Compare Date */ 1.298 + PKIX_EQUALS 1.299 + (firstCrlParams->date, 1.300 + secondCrlParams->date, 1.301 + &cmpResult, 1.302 + plContext, 1.303 + PKIX_DATEEQUALSFAILED); 1.304 + 1.305 + if (cmpResult != PKIX_TRUE) { 1.306 + goto cleanup; 1.307 + } 1.308 + 1.309 + /* Compare Max CRL Number */ 1.310 + PKIX_EQUALS 1.311 + (firstCrlParams->maxCRLNumber, 1.312 + secondCrlParams->maxCRLNumber, 1.313 + &cmpResult, 1.314 + plContext, 1.315 + PKIX_BIGINTEQUALSFAILED); 1.316 + 1.317 + if (cmpResult != PKIX_TRUE) { 1.318 + goto cleanup; 1.319 + } 1.320 + 1.321 + /* Compare Min CRL Number */ 1.322 + PKIX_EQUALS 1.323 + (firstCrlParams->minCRLNumber, 1.324 + secondCrlParams->minCRLNumber, 1.325 + &cmpResult, 1.326 + plContext, 1.327 + PKIX_BIGINTEQUALSFAILED); 1.328 + 1.329 + if (cmpResult != PKIX_TRUE) { 1.330 + goto cleanup; 1.331 + } 1.332 + 1.333 + /* Compare Cert */ 1.334 + PKIX_EQUALS 1.335 + (firstCrlParams->cert, 1.336 + secondCrlParams->cert, 1.337 + &cmpResult, 1.338 + plContext, 1.339 + PKIX_CERTEQUALSFAILED); 1.340 + 1.341 + *pResult = cmpResult; 1.342 + 1.343 +cleanup: 1.344 + 1.345 + PKIX_RETURN(COMCRLSELPARAMS); 1.346 +} 1.347 + 1.348 +/* 1.349 + * FUNCTION: pkix_ComCRLSelParams_Duplicate 1.350 + * (see comments for PKIX_PL_Duplicate_Callback in pkix_pl_system.h) 1.351 + */ 1.352 +static PKIX_Error * 1.353 +pkix_ComCRLSelParams_Duplicate( 1.354 + PKIX_PL_Object *object, 1.355 + PKIX_PL_Object **pNewObject, 1.356 + void *plContext) 1.357 +{ 1.358 + PKIX_ComCRLSelParams *old; 1.359 + PKIX_ComCRLSelParams *new = NULL; 1.360 + 1.361 + PKIX_ENTER(COMCRLSELPARAMS, "pkix_ComCRLSelParams_Duplicate"); 1.362 + PKIX_NULLCHECK_TWO(object, pNewObject); 1.363 + 1.364 + PKIX_CHECK(pkix_CheckType(object, PKIX_COMCRLSELPARAMS_TYPE, plContext), 1.365 + PKIX_OBJECTNOTCOMCRLSELPARAMS); 1.366 + 1.367 + old = (PKIX_ComCRLSelParams *)object; 1.368 + 1.369 + PKIX_CHECK(PKIX_PL_Object_Alloc 1.370 + (PKIX_COMCRLSELPARAMS_TYPE, 1.371 + (PKIX_UInt32)(sizeof (PKIX_ComCRLSelParams)), 1.372 + (PKIX_PL_Object **)&new, 1.373 + plContext), 1.374 + PKIX_OBJECTALLOCFAILED); 1.375 + 1.376 + PKIX_DUPLICATE(old->cert, &new->cert, plContext, 1.377 + PKIX_OBJECTDUPLICATECERTFAILED); 1.378 + 1.379 + PKIX_DUPLICATE(old->crldpList, &new->crldpList, plContext, 1.380 + PKIX_OBJECTDUPLICATECERTFAILED); 1.381 + 1.382 + PKIX_DUPLICATE(old->issuerNames, &new->issuerNames, plContext, 1.383 + PKIX_OBJECTDUPLICATEISSUERNAMESFAILED); 1.384 + 1.385 + PKIX_DUPLICATE(old->date, &new->date, plContext, 1.386 + PKIX_OBJECTDUPLICATEDATEFAILED); 1.387 + 1.388 + PKIX_DUPLICATE(old->maxCRLNumber, &new->maxCRLNumber, plContext, 1.389 + PKIX_OBJECTDUPLICATEMAXCRLNUMBERFAILED); 1.390 + 1.391 + PKIX_DUPLICATE(old->minCRLNumber, &new->minCRLNumber, plContext, 1.392 + PKIX_OBJECTDUPLICATEMINCRLNUMBERFAILED); 1.393 + 1.394 + *pNewObject = (PKIX_PL_Object *)new; 1.395 + 1.396 +cleanup: 1.397 + 1.398 + if (PKIX_ERROR_RECEIVED){ 1.399 + PKIX_DECREF(new); 1.400 + } 1.401 + 1.402 + PKIX_RETURN(COMCRLSELPARAMS); 1.403 +} 1.404 + 1.405 +/* 1.406 + * FUNCTION: pkix_ComCrlSelParams_RegisterSelf 1.407 + * DESCRIPTION: 1.408 + * Registers PKIX_COMCRLSELPARAMS_TYPE and its related functions with 1.409 + * systemClasses[] 1.410 + * THREAD SAFETY: 1.411 + * Not Thread Safe - for performance and complexity reasons 1.412 + * 1.413 + * Since this function is only called by PKIX_PL_Initialize, which should 1.414 + * only be called once, it is acceptable that this function is not 1.415 + * thread-safe. 1.416 + */ 1.417 +PKIX_Error * 1.418 +pkix_ComCRLSelParams_RegisterSelf(void *plContext) 1.419 +{ 1.420 + extern pkix_ClassTable_Entry systemClasses[PKIX_NUMTYPES]; 1.421 + pkix_ClassTable_Entry entry; 1.422 + 1.423 + PKIX_ENTER(COMCRLSELPARAMS, "pkix_ComCRLSelParams_RegisterSelf"); 1.424 + 1.425 + entry.description = "ComCRLSelParams"; 1.426 + entry.objCounter = 0; 1.427 + entry.typeObjectSize = sizeof(PKIX_ComCRLSelParams); 1.428 + entry.destructor = pkix_ComCRLSelParams_Destroy; 1.429 + entry.equalsFunction = pkix_ComCRLSelParams_Equals; 1.430 + entry.hashcodeFunction = pkix_ComCRLSelParams_Hashcode; 1.431 + entry.toStringFunction = pkix_ComCRLSelParams_ToString; 1.432 + entry.comparator = NULL; 1.433 + entry.duplicateFunction = pkix_ComCRLSelParams_Duplicate; 1.434 + 1.435 + systemClasses[PKIX_COMCRLSELPARAMS_TYPE] = entry; 1.436 + 1.437 + PKIX_RETURN(COMCRLSELPARAMS); 1.438 +} 1.439 + 1.440 +/* --ComCRLSelParams-Public-Functions------------------------------------- */ 1.441 + 1.442 +/* 1.443 + * FUNCTION: PKIX_ComCRLSelParams_Create (see comments in pkix_crlsel.h) 1.444 + */ 1.445 +PKIX_Error * 1.446 +PKIX_ComCRLSelParams_Create( 1.447 + PKIX_ComCRLSelParams **pParams, 1.448 + void *plContext) 1.449 +{ 1.450 + PKIX_ComCRLSelParams *params = NULL; 1.451 + 1.452 + PKIX_ENTER(COMCRLSELPARAMS, "PKIX_ComCRLSelParams_Create"); 1.453 + PKIX_NULLCHECK_ONE(pParams); 1.454 + 1.455 + PKIX_CHECK(PKIX_PL_Object_Alloc 1.456 + (PKIX_COMCRLSELPARAMS_TYPE, 1.457 + sizeof (PKIX_ComCRLSelParams), 1.458 + (PKIX_PL_Object **)¶ms, 1.459 + plContext), 1.460 + PKIX_COULDNOTCREATECOMMONCRLSELECTORPARAMSOBJECT); 1.461 + 1.462 + /* initialize fields */ 1.463 + params->issuerNames = NULL; 1.464 + params->cert = NULL; 1.465 + params->crldpList = NULL; 1.466 + params->date = NULL; 1.467 + params->nistPolicyEnabled = PKIX_TRUE; 1.468 + params->maxCRLNumber = NULL; 1.469 + params->minCRLNumber = NULL; 1.470 + 1.471 + *pParams = params; 1.472 + 1.473 +cleanup: 1.474 + 1.475 + PKIX_RETURN(COMCRLSELPARAMS); 1.476 +} 1.477 + 1.478 +/* 1.479 + * FUNCTION: PKIX_ComCRLSelParams_GetIssuerNames (see comments in pkix_crlsel.h) 1.480 + */ 1.481 +PKIX_Error * 1.482 +PKIX_ComCRLSelParams_GetIssuerNames( 1.483 + PKIX_ComCRLSelParams *params, 1.484 + PKIX_List **pIssuerNames, 1.485 + void *plContext) 1.486 +{ 1.487 + PKIX_ENTER(COMCRLSELPARAMS, "PKIX_ComCRLSelParams_GetIssuerNames"); 1.488 + PKIX_NULLCHECK_TWO(params, pIssuerNames); 1.489 + 1.490 + PKIX_INCREF(params->issuerNames); 1.491 + 1.492 + *pIssuerNames = params->issuerNames; 1.493 + 1.494 +cleanup: 1.495 + PKIX_RETURN(COMCRLSELPARAMS); 1.496 +} 1.497 + 1.498 +/* 1.499 + * FUNCTION: PKIX_ComCRLSelParams_SetIssuerNames (see comments in pkix_crlsel.h) 1.500 + */ 1.501 +PKIX_Error * 1.502 +PKIX_ComCRLSelParams_SetIssuerNames( 1.503 + PKIX_ComCRLSelParams *params, 1.504 + PKIX_List *names, 1.505 + void *plContext) 1.506 +{ 1.507 + PKIX_ENTER(COMCRLSELPARAMS, "PKIX_ComCRLSelParams_SetIssuerNames"); 1.508 + PKIX_NULLCHECK_ONE(params); /* allows null for names from spec */ 1.509 + 1.510 + PKIX_DECREF(params->issuerNames); 1.511 + 1.512 + PKIX_INCREF(names); /* if NULL, allows to reset for no action */ 1.513 + 1.514 + params->issuerNames = names; 1.515 + 1.516 + PKIX_CHECK(PKIX_PL_Object_InvalidateCache 1.517 + ((PKIX_PL_Object *)params, plContext), 1.518 + PKIX_OBJECTINVALIDATECACHEFAILED); 1.519 + 1.520 +cleanup: 1.521 + 1.522 + PKIX_RETURN(COMCRLSELPARAMS); 1.523 +} 1.524 + 1.525 +/* 1.526 + * FUNCTION: PKIX_ComCRLSelParams_AddIssuerName (see comments in pkix_crlsel.h) 1.527 + */ 1.528 +PKIX_Error * 1.529 +PKIX_ComCRLSelParams_AddIssuerName( 1.530 + PKIX_ComCRLSelParams *params, 1.531 + PKIX_PL_X500Name *name, 1.532 + void *plContext) 1.533 +{ 1.534 + PKIX_List *list = NULL; 1.535 + 1.536 + PKIX_ENTER(COMCRLSELPARAMS, "PKIX_ComCRLSelParams_AddIssuerName"); 1.537 + PKIX_NULLCHECK_ONE(params); 1.538 + 1.539 + if (name != NULL) { 1.540 + 1.541 + if (params->issuerNames == NULL) { 1.542 + 1.543 + PKIX_CHECK(PKIX_List_Create(&list, plContext), 1.544 + PKIX_LISTCREATEFAILED); 1.545 + params->issuerNames = list; 1.546 + } 1.547 + 1.548 + PKIX_CHECK(PKIX_List_AppendItem 1.549 + (params->issuerNames, (PKIX_PL_Object *)name, plContext), 1.550 + PKIX_LISTAPPENDITEMFAILED); 1.551 + 1.552 + PKIX_CHECK(PKIX_PL_Object_InvalidateCache 1.553 + ((PKIX_PL_Object *)params, plContext), 1.554 + PKIX_OBJECTINVALIDATECACHEFAILED); 1.555 + 1.556 + } 1.557 + 1.558 +cleanup: 1.559 + 1.560 + PKIX_RETURN(COMCRLSELPARAMS); 1.561 +} 1.562 + 1.563 + 1.564 +/* 1.565 + * FUNCTION: PKIX_ComCRLSelParams_GetCertificateChecking 1.566 + * (see comments in pkix_crlsel.h) 1.567 + */ 1.568 +PKIX_Error * 1.569 +PKIX_ComCRLSelParams_GetCertificateChecking( 1.570 + PKIX_ComCRLSelParams *params, 1.571 + PKIX_PL_Cert **pCert, 1.572 + void *plContext) 1.573 +{ 1.574 + PKIX_ENTER(COMCRLSELPARAMS, 1.575 + "PKIX_ComCRLSelParams_GetCertificateChecking"); 1.576 + PKIX_NULLCHECK_TWO(params, pCert); 1.577 + 1.578 + PKIX_INCREF(params->cert); 1.579 + 1.580 + *pCert = params->cert; 1.581 + 1.582 +cleanup: 1.583 + PKIX_RETURN(COMCRLSELPARAMS); 1.584 +} 1.585 + 1.586 +/* 1.587 + * FUNCTION: PKIX_ComCRLSelParams_SetCertificateChecking 1.588 + * (see comments in pkix_crlsel.h) 1.589 + */ 1.590 +PKIX_Error * 1.591 +PKIX_ComCRLSelParams_SetCertificateChecking( 1.592 + PKIX_ComCRLSelParams *params, 1.593 + PKIX_PL_Cert *cert, 1.594 + void *plContext) 1.595 +{ 1.596 + PKIX_ENTER(COMCRLSELPARAMS, 1.597 + "PKIX_ComCRLSelParams_SetCertificateChecking"); 1.598 + PKIX_NULLCHECK_ONE(params); /* allows cert to be NULL from spec */ 1.599 + 1.600 + PKIX_DECREF(params->cert); 1.601 + 1.602 + PKIX_INCREF(cert); 1.603 + 1.604 + params->cert = cert; 1.605 + 1.606 + PKIX_CHECK(PKIX_PL_Object_InvalidateCache 1.607 + ((PKIX_PL_Object *)params, plContext), 1.608 + PKIX_OBJECTINVALIDATECACHEFAILED); 1.609 + 1.610 +cleanup: 1.611 + 1.612 + PKIX_RETURN(COMCRLSELPARAMS); 1.613 +} 1.614 + 1.615 + 1.616 +/* 1.617 + * FUNCTION: PKIX_ComCRLSelParams_GetDateAndTime (see comments in pkix_crlsel.h) 1.618 + */ 1.619 +PKIX_Error * 1.620 +PKIX_ComCRLSelParams_GetDateAndTime( 1.621 + PKIX_ComCRLSelParams *params, 1.622 + PKIX_PL_Date **pDate, 1.623 + void *plContext) 1.624 +{ 1.625 + PKIX_ENTER(COMCRLSELPARAMS, 1.626 + "PKIX_ComCRLSelParams_GetDateAndTime"); 1.627 + PKIX_NULLCHECK_TWO(params, pDate); 1.628 + 1.629 + PKIX_INCREF(params->date); 1.630 + 1.631 + *pDate = params->date; 1.632 + 1.633 +cleanup: 1.634 + PKIX_RETURN(COMCRLSELPARAMS); 1.635 +} 1.636 + 1.637 +/* 1.638 + * FUNCTION: PKIX_ComCRLSelParams_SetDateAndTime (see comments in pkix_crlsel.h) 1.639 + */ 1.640 +PKIX_Error * 1.641 +PKIX_ComCRLSelParams_SetDateAndTime( 1.642 + PKIX_ComCRLSelParams *params, 1.643 + PKIX_PL_Date *date, 1.644 + void *plContext) 1.645 +{ 1.646 + PKIX_ENTER(COMCRLSELPARAMS, 1.647 + "PKIX_ComCRLSelParams_SetDateAndTime"); 1.648 + PKIX_NULLCHECK_ONE(params); /* allows date to be NULL from spec */ 1.649 + 1.650 + PKIX_DECREF (params->date); 1.651 + 1.652 + PKIX_INCREF(date); 1.653 + 1.654 + params->date = date; 1.655 + 1.656 + PKIX_CHECK(PKIX_PL_Object_InvalidateCache 1.657 + ((PKIX_PL_Object *)params, plContext), 1.658 + PKIX_OBJECTINVALIDATECACHEFAILED); 1.659 + 1.660 +cleanup: 1.661 + 1.662 + PKIX_RETURN(COMCRLSELPARAMS); 1.663 +} 1.664 + 1.665 +/* 1.666 + * FUNCTION: PKIX_ComCRLSelParams_GetDateAndTime (see comments in pkix_crlsel.h) 1.667 + */ 1.668 +PKIX_Error * 1.669 +PKIX_ComCRLSelParams_GetNISTPolicyEnabled( 1.670 + PKIX_ComCRLSelParams *params, 1.671 + PKIX_Boolean *pEnabled, 1.672 + void *plContext) 1.673 +{ 1.674 + PKIX_ENTER(COMCRLSELPARAMS, 1.675 + "PKIX_ComCRLSelParams_GetNISTPolicyEnabled"); 1.676 + PKIX_NULLCHECK_TWO(params, pEnabled); 1.677 + 1.678 + *pEnabled = params->nistPolicyEnabled; 1.679 + 1.680 + PKIX_RETURN(COMCRLSELPARAMS); 1.681 +} 1.682 + 1.683 +/* 1.684 + * FUNCTION: PKIX_ComCRLSelParams_SetDateAndTime (see comments in pkix_crlsel.h) 1.685 + */ 1.686 +PKIX_Error * 1.687 +PKIX_ComCRLSelParams_SetNISTPolicyEnabled( 1.688 + PKIX_ComCRLSelParams *params, 1.689 + PKIX_Boolean enabled, 1.690 + void *plContext) 1.691 +{ 1.692 + PKIX_ENTER(COMCRLSELPARAMS, 1.693 + "PKIX_ComCRLSelParams_SetNISTPolicyEnabled"); 1.694 + PKIX_NULLCHECK_ONE(params); /* allows date to be NULL from spec */ 1.695 + 1.696 + params->nistPolicyEnabled = enabled; 1.697 + 1.698 + PKIX_CHECK(PKIX_PL_Object_InvalidateCache 1.699 + ((PKIX_PL_Object *)params, plContext), 1.700 + PKIX_OBJECTINVALIDATECACHEFAILED); 1.701 + 1.702 +cleanup: 1.703 + 1.704 + PKIX_RETURN(COMCRLSELPARAMS); 1.705 +} 1.706 + 1.707 +/* 1.708 + * FUNCTION: PKIX_ComCRLSelParams_GetMaxCRLNumber 1.709 + * (see comments in pkix_crlsel.h) 1.710 + */ 1.711 +PKIX_Error * 1.712 +PKIX_ComCRLSelParams_GetMaxCRLNumber( 1.713 + PKIX_ComCRLSelParams *params, 1.714 + PKIX_PL_BigInt **pMaxCRLNumber, 1.715 + void *plContext) 1.716 +{ 1.717 + PKIX_ENTER(COMCRLSELPARAMS, 1.718 + "PKIX_ComCRLSelParams_GetMaxCRLNumber"); 1.719 + PKIX_NULLCHECK_TWO(params, pMaxCRLNumber); 1.720 + 1.721 + PKIX_INCREF(params->maxCRLNumber); 1.722 + 1.723 + *pMaxCRLNumber = params->maxCRLNumber; 1.724 + 1.725 +cleanup: 1.726 + PKIX_RETURN(COMCRLSELPARAMS); 1.727 +} 1.728 + 1.729 +/* 1.730 + * FUNCTION: PKIX_ComCRLSelParams_SetMaxCRLNumber 1.731 + * (see comments in pkix_crlsel.h) 1.732 + */ 1.733 +PKIX_Error * 1.734 +PKIX_ComCRLSelParams_SetMaxCRLNumber( 1.735 + PKIX_ComCRLSelParams *params, 1.736 + PKIX_PL_BigInt *maxCRLNumber, 1.737 + void *plContext) 1.738 +{ 1.739 + PKIX_ENTER(COMCRLSELPARAMS, 1.740 + "PKIX_ComCRLSelParams_SetMaxCRLNumber"); 1.741 + PKIX_NULLCHECK_ONE(params); /* maxCRLNumber can be NULL - from spec */ 1.742 + 1.743 + PKIX_DECREF(params->maxCRLNumber); 1.744 + 1.745 + PKIX_INCREF(maxCRLNumber); 1.746 + 1.747 + params->maxCRLNumber = maxCRLNumber; 1.748 + 1.749 + PKIX_CHECK(PKIX_PL_Object_InvalidateCache 1.750 + ((PKIX_PL_Object *)params, plContext), 1.751 + PKIX_OBJECTINVALIDATECACHEFAILED); 1.752 + 1.753 +cleanup: 1.754 + 1.755 + PKIX_RETURN(COMCRLSELPARAMS); 1.756 +} 1.757 + 1.758 + 1.759 +/* 1.760 + * FUNCTION: PKIX_ComCRLSelParams_GetMinCRLNumber 1.761 + * (see comments in pkix_crlsel.h) 1.762 + */ 1.763 +PKIX_Error * 1.764 +PKIX_ComCRLSelParams_GetMinCRLNumber( 1.765 + PKIX_ComCRLSelParams *params, 1.766 + PKIX_PL_BigInt **pMinCRLNumber, 1.767 + void *plContext) 1.768 +{ 1.769 + PKIX_ENTER(COMCRLSELPARAMS, 1.770 + "PKIX_ComCRLSelParams_GetMinCRLNumber"); 1.771 + PKIX_NULLCHECK_TWO(params, pMinCRLNumber); 1.772 + 1.773 + PKIX_INCREF(params->minCRLNumber); 1.774 + 1.775 + *pMinCRLNumber = params->minCRLNumber; 1.776 + 1.777 +cleanup: 1.778 + PKIX_RETURN(COMCRLSELPARAMS); 1.779 +} 1.780 + 1.781 +/* 1.782 + * FUNCTION: PKIX_ComCRLSelParams_SetMinCRLNumber 1.783 + * (see comments in pkix_crlsel.h) 1.784 + */ 1.785 +PKIX_Error * 1.786 +PKIX_ComCRLSelParams_SetMinCRLNumber( 1.787 + PKIX_ComCRLSelParams *params, 1.788 + PKIX_PL_BigInt *minCRLNumber, 1.789 + void *plContext) 1.790 +{ 1.791 + PKIX_ENTER(COMCRLSELPARAMS, 1.792 + "PKIX_ComCRLSelParams_SetMinCRLNumber"); 1.793 + PKIX_NULLCHECK_ONE(params); /* minCRLNumber can be NULL - from spec */ 1.794 + 1.795 + PKIX_DECREF(params->minCRLNumber); 1.796 + 1.797 + PKIX_INCREF(minCRLNumber); 1.798 + 1.799 + params->minCRLNumber = minCRLNumber; 1.800 + 1.801 + PKIX_CHECK(PKIX_PL_Object_InvalidateCache 1.802 + ((PKIX_PL_Object *)params, plContext), 1.803 + PKIX_OBJECTINVALIDATECACHEFAILED); 1.804 + 1.805 +cleanup: 1.806 + 1.807 + PKIX_RETURN(COMCRLSELPARAMS); 1.808 +} 1.809 + 1.810 + 1.811 +PKIX_Error* 1.812 +PKIX_ComCRLSelParams_SetCrlDp( 1.813 + PKIX_ComCRLSelParams *params, 1.814 + PKIX_List *crldpList, 1.815 + void *plContext) 1.816 +{ 1.817 + PKIX_ENTER(COMCRLSELPARAMS, "PKIX_ComCRLSelParams_SetCrlDp"); 1.818 + PKIX_NULLCHECK_ONE(params); /* minCRLNumber can be NULL - from spec */ 1.819 + 1.820 + PKIX_INCREF(crldpList); 1.821 + params->crldpList = crldpList; 1.822 + 1.823 + PKIX_CHECK(PKIX_PL_Object_InvalidateCache 1.824 + ((PKIX_PL_Object *)params, plContext), 1.825 + PKIX_OBJECTINVALIDATECACHEFAILED); 1.826 +cleanup: 1.827 + 1.828 + PKIX_RETURN(COMCRLSELPARAMS); 1.829 +}