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 /* | 5 /* |
6 * Moved from secpkcs7.c | 6 * Moved from secpkcs7.c |
7 */ | 7 */ |
8 | 8 |
9 #include "cert.h" | 9 #include "cert.h" |
10 #include "certi.h" | 10 #include "certi.h" |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 } | 297 } |
298 | 298 |
299 return (SECSuccess); | 299 return (SECSuccess); |
300 } | 300 } |
301 | 301 |
302 /* | 302 /* |
303 * Generate a database key, based on the issuer name from a | 303 * Generate a database key, based on the issuer name from a |
304 * DER crl. | 304 * DER crl. |
305 */ | 305 */ |
306 SECStatus | 306 SECStatus |
307 CERT_KeyFromDERCrl(PRArenaPool *arena, SECItem *derCrl, SECItem *key) | 307 CERT_KeyFromDERCrl(PLArenaPool *arena, SECItem *derCrl, SECItem *key) |
308 { | 308 { |
309 SECStatus rv; | 309 SECStatus rv; |
310 CERTSignedData sd; | 310 CERTSignedData sd; |
311 CERTCrlKey crlkey; | 311 CERTCrlKey crlkey; |
312 PRArenaPool* myArena; | 312 PLArenaPool* myArena; |
313 | 313 |
314 if (!arena) { | 314 if (!arena) { |
315 /* arena needed for QuickDER */ | 315 /* arena needed for QuickDER */ |
316 myArena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); | 316 myArena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); |
317 } else { | 317 } else { |
318 myArena = arena; | 318 myArena = arena; |
319 } | 319 } |
320 PORT_Memset (&sd, 0, sizeof (sd)); | 320 PORT_Memset (&sd, 0, sizeof (sd)); |
321 rv = SEC_QuickDERDecodeItem (myArena, &sd, CERT_SignedDataTemplate, derCrl); | 321 rv = SEC_QuickDERDecodeItem (myArena, &sd, CERT_SignedDataTemplate, derCrl); |
322 if (SECSuccess == rv) { | 322 if (SECSuccess == rv) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 } | 385 } |
386 } | 386 } |
387 return rv; | 387 return rv; |
388 } | 388 } |
389 | 389 |
390 /* | 390 /* |
391 * take a DER CRL and decode it into a CRL structure | 391 * take a DER CRL and decode it into a CRL structure |
392 * allow reusing the input DER without making a copy | 392 * allow reusing the input DER without making a copy |
393 */ | 393 */ |
394 CERTSignedCrl * | 394 CERTSignedCrl * |
395 CERT_DecodeDERCrlWithFlags(PRArenaPool *narena, SECItem *derSignedCrl, | 395 CERT_DecodeDERCrlWithFlags(PLArenaPool *narena, SECItem *derSignedCrl, |
396 int type, PRInt32 options) | 396 int type, PRInt32 options) |
397 { | 397 { |
398 PRArenaPool *arena; | 398 PLArenaPool *arena; |
399 CERTSignedCrl *crl; | 399 CERTSignedCrl *crl; |
400 SECStatus rv; | 400 SECStatus rv; |
401 OpaqueCRLFields* extended = NULL; | 401 OpaqueCRLFields* extended = NULL; |
402 const SEC_ASN1Template* crlTemplate = CERT_SignedCrlTemplate; | 402 const SEC_ASN1Template* crlTemplate = CERT_SignedCrlTemplate; |
403 PRInt32 testOptions = options; | 403 PRInt32 testOptions = options; |
404 | 404 |
405 PORT_Assert(derSignedCrl); | 405 PORT_Assert(derSignedCrl); |
406 if (!derSignedCrl) { | 406 if (!derSignedCrl) { |
407 PORT_SetError(SEC_ERROR_INVALID_ARGS); | 407 PORT_SetError(SEC_ERROR_INVALID_ARGS); |
408 return NULL; | 408 return NULL; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 PORT_FreeArena(arena, PR_FALSE); | 525 PORT_FreeArena(arena, PR_FALSE); |
526 } | 526 } |
527 | 527 |
528 return(0); | 528 return(0); |
529 } | 529 } |
530 | 530 |
531 /* | 531 /* |
532 * take a DER CRL and decode it into a CRL structure | 532 * take a DER CRL and decode it into a CRL structure |
533 */ | 533 */ |
534 CERTSignedCrl * | 534 CERTSignedCrl * |
535 CERT_DecodeDERCrl(PRArenaPool *narena, SECItem *derSignedCrl, int type) | 535 CERT_DecodeDERCrl(PLArenaPool *narena, SECItem *derSignedCrl, int type) |
536 { | 536 { |
537 return CERT_DecodeDERCrlWithFlags(narena, derSignedCrl, type, | 537 return CERT_DecodeDERCrlWithFlags(narena, derSignedCrl, type, |
538 CRL_DECODE_DEFAULT_OPTIONS); | 538 CRL_DECODE_DEFAULT_OPTIONS); |
539 } | 539 } |
540 | 540 |
541 /* | 541 /* |
542 * Lookup a CRL in the databases. We mirror the same fast caching data base | 542 * Lookup a CRL in the databases. We mirror the same fast caching data base |
543 * caching stuff used by certificates....? | 543 * caching stuff used by certificates....? |
544 * return values : | 544 * return values : |
545 * | 545 * |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 retCrl = PK11_ImportCRL(slot, derCrl, url, type, NULL, | 713 retCrl = PK11_ImportCRL(slot, derCrl, url, type, NULL, |
714 CRL_IMPORT_BYPASS_CHECKS, NULL, CRL_DECODE_DEFAULT_OPTIONS); | 714 CRL_IMPORT_BYPASS_CHECKS, NULL, CRL_DECODE_DEFAULT_OPTIONS); |
715 PK11_FreeSlot(slot); | 715 PK11_FreeSlot(slot); |
716 | 716 |
717 return retCrl; | 717 return retCrl; |
718 } | 718 } |
719 | 719 |
720 CERTSignedCrl * | 720 CERTSignedCrl * |
721 SEC_FindCrlByDERCert(CERTCertDBHandle *handle, SECItem *derCrl, int type) | 721 SEC_FindCrlByDERCert(CERTCertDBHandle *handle, SECItem *derCrl, int type) |
722 { | 722 { |
723 PRArenaPool *arena; | 723 PLArenaPool *arena; |
724 SECItem crlKey; | 724 SECItem crlKey; |
725 SECStatus rv; | 725 SECStatus rv; |
726 CERTSignedCrl *crl = NULL; | 726 CERTSignedCrl *crl = NULL; |
727 | 727 |
728 /* create a scratch arena */ | 728 /* create a scratch arena */ |
729 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); | 729 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); |
730 if ( arena == NULL ) { | 730 if ( arena == NULL ) { |
731 return(NULL); | 731 return(NULL); |
732 } | 732 } |
733 | 733 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 return SECSuccess; | 774 return SECSuccess; |
775 } else { | 775 } else { |
776 return SECFailure; | 776 return SECFailure; |
777 } | 777 } |
778 } | 778 } |
779 | 779 |
780 SECStatus | 780 SECStatus |
781 SEC_LookupCrls(CERTCertDBHandle *handle, CERTCrlHeadNode **nodes, int type) | 781 SEC_LookupCrls(CERTCertDBHandle *handle, CERTCrlHeadNode **nodes, int type) |
782 { | 782 { |
783 CERTCrlHeadNode *head; | 783 CERTCrlHeadNode *head; |
784 PRArenaPool *arena = NULL; | 784 PLArenaPool *arena = NULL; |
785 SECStatus rv; | 785 SECStatus rv; |
786 | 786 |
787 *nodes = NULL; | 787 *nodes = NULL; |
788 | 788 |
789 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); | 789 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); |
790 if ( arena == NULL ) { | 790 if ( arena == NULL ) { |
791 return SECFailure; | 791 return SECFailure; |
792 } | 792 } |
793 | 793 |
794 /* build a head structure */ | 794 /* build a head structure */ |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
952 } | 952 } |
953 if (PreAllocator->arena) | 953 if (PreAllocator->arena) |
954 { | 954 { |
955 PORT_FreeArena(PreAllocator->arena, PR_TRUE); | 955 PORT_FreeArena(PreAllocator->arena, PR_TRUE); |
956 } | 956 } |
957 } | 957 } |
958 | 958 |
959 /* constructor for PreAllocator object */ | 959 /* constructor for PreAllocator object */ |
960 PreAllocator* PreAllocator_Create(PRSize size) | 960 PreAllocator* PreAllocator_Create(PRSize size) |
961 { | 961 { |
962 PRArenaPool* arena = NULL; | 962 PLArenaPool* arena = NULL; |
963 PreAllocator* prebuffer = NULL; | 963 PreAllocator* prebuffer = NULL; |
964 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); | 964 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); |
965 if (!arena) | 965 if (!arena) |
966 { | 966 { |
967 return NULL; | 967 return NULL; |
968 } | 968 } |
969 prebuffer = (PreAllocator*)PORT_ArenaZAlloc(arena, | 969 prebuffer = (PreAllocator*)PORT_ArenaZAlloc(arena, |
970 sizeof(PreAllocator)); | 970 sizeof(PreAllocator)); |
971 if (!prebuffer) | 971 if (!prebuffer) |
972 { | 972 { |
(...skipping 2389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3362 to CERT_CacheCRL previously. That API takes a SECItem*, thus, we | 3362 to CERT_CacheCRL previously. That API takes a SECItem*, thus, we |
3363 just do a pointer comparison here. | 3363 just do a pointer comparison here. |
3364 */ | 3364 */ |
3365 if (b->crl->derCrl == a->crl->derCrl) | 3365 if (b->crl->derCrl == a->crl->derCrl) |
3366 { | 3366 { |
3367 *isDupe = PR_TRUE; | 3367 *isDupe = PR_TRUE; |
3368 } | 3368 } |
3369 } | 3369 } |
3370 return SECSuccess; | 3370 return SECSuccess; |
3371 } | 3371 } |
OLD | NEW |