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 #ifndef PKIM_H | 5 #ifndef PKIM_H |
6 #include "pkim.h" | 6 #include "pkim.h" |
7 #endif /* PKIM_H */ | 7 #endif /* PKIM_H */ |
8 | 8 |
9 #ifndef PKI_H | 9 #ifndef PKI_H |
10 #include "pki.h" | 10 #include "pki.h" |
11 #endif /* PKI_H */ | 11 #endif /* PKI_H */ |
12 | 12 |
13 #ifndef NSSPKI_H | 13 #ifndef NSSPKI_H |
14 #include "nsspki.h" | 14 #include "nsspki.h" |
15 #endif /* NSSPKI_H */ | 15 #endif /* NSSPKI_H */ |
16 | 16 |
17 #ifndef BASE_H | 17 #ifndef BASE_H |
18 #include "base.h" | 18 #include "base.h" |
19 #endif /* BASE_H */ | 19 #endif /* BASE_H */ |
20 | 20 |
21 #ifndef PKISTORE_H | 21 #ifndef PKISTORE_H |
22 #include "pkistore.h" | 22 #include "pkistore.h" |
23 #endif /* PKISTORE_H */ | 23 #endif /* PKISTORE_H */ |
24 | 24 |
25 #include "cert.h" | 25 #include "cert.h" |
| 26 #include "pki3hack.h" |
26 | 27 |
27 #include "prbit.h" | 28 #include "prbit.h" |
28 | 29 |
29 /* | 30 /* |
30 * Certificate Store | 31 * Certificate Store |
31 * | 32 * |
32 * This differs from the cache in that it is a true storage facility. Items | 33 * This differs from the cache in that it is a true storage facility. Items |
33 * stay in until they are explicitly removed. It is only used by crypto | 34 * stay in until they are explicitly removed. It is only used by crypto |
34 * contexts at this time, but may be more generally useful... | 35 * contexts at this time, but may be more generally useful... |
35 * | 36 * |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 { | 548 { |
548 NSSCertificate *rvCert = NULL; | 549 NSSCertificate *rvCert = NULL; |
549 | 550 |
550 PZ_Lock(store->lock); | 551 PZ_Lock(store->lock); |
551 rvCert = nssCertStore_FindCertByIssuerAndSerialNumberLocked ( | 552 rvCert = nssCertStore_FindCertByIssuerAndSerialNumberLocked ( |
552 store, issuer, serial); | 553 store, issuer, serial); |
553 PZ_Unlock(store->lock); | 554 PZ_Unlock(store->lock); |
554 return rvCert; | 555 return rvCert; |
555 } | 556 } |
556 | 557 |
557 static PRStatus | |
558 issuer_and_serial_from_encoding ( | |
559 NSSBER *encoding, | |
560 NSSDER *issuer, | |
561 NSSDER *serial | |
562 ) | |
563 { | |
564 SECItem derCert, derIssuer, derSerial; | |
565 SECStatus secrv; | |
566 derCert.data = (unsigned char *)encoding->data; | |
567 derCert.len = encoding->size; | |
568 secrv = CERT_IssuerNameFromDERCert(&derCert, &derIssuer); | |
569 if (secrv != SECSuccess) { | |
570 return PR_FAILURE; | |
571 } | |
572 secrv = CERT_SerialNumberFromDERCert(&derCert, &derSerial); | |
573 if (secrv != SECSuccess) { | |
574 PORT_Free(derIssuer.data); | |
575 return PR_FAILURE; | |
576 } | |
577 issuer->data = derIssuer.data; | |
578 issuer->size = derIssuer.len; | |
579 serial->data = derSerial.data; | |
580 serial->size = derSerial.len; | |
581 return PR_SUCCESS; | |
582 } | |
583 | |
584 NSS_IMPLEMENT NSSCertificate * | 558 NSS_IMPLEMENT NSSCertificate * |
585 nssCertificateStore_FindCertificateByEncodedCertificate ( | 559 nssCertificateStore_FindCertificateByEncodedCertificate ( |
586 nssCertificateStore *store, | 560 nssCertificateStore *store, |
587 NSSDER *encoding | 561 NSSDER *encoding |
588 ) | 562 ) |
589 { | 563 { |
590 PRStatus nssrv = PR_FAILURE; | 564 PRStatus nssrv = PR_FAILURE; |
591 NSSDER issuer, serial; | 565 NSSDER issuer, serial; |
592 NSSCertificate *rvCert = NULL; | 566 NSSCertificate *rvCert = NULL; |
593 nssrv = issuer_and_serial_from_encoding(encoding, &issuer, &serial); | 567 nssrv = nssPKIX509_GetIssuerAndSerialFromDER(encoding, &issuer, &serial); |
594 if (nssrv != PR_SUCCESS) { | 568 if (nssrv != PR_SUCCESS) { |
595 return NULL; | 569 return NULL; |
596 } | 570 } |
597 rvCert = nssCertificateStore_FindCertificateByIssuerAndSerialNumber(store, | 571 rvCert = nssCertificateStore_FindCertificateByIssuerAndSerialNumber(store, |
598 &issuer, | 572 &issuer, |
599 &serial); | 573 &serial); |
600 PORT_Free(issuer.data); | 574 PORT_Free(issuer.data); |
601 PORT_Free(serial.data); | 575 PORT_Free(serial.data); |
602 return rvCert; | 576 return rvCert; |
603 } | 577 } |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 nssCertificateStore *store, | 704 nssCertificateStore *store, |
731 void (* cert_dump_iter)(const void *, void *, void *), | 705 void (* cert_dump_iter)(const void *, void *, void *), |
732 void *arg | 706 void *arg |
733 ) | 707 ) |
734 { | 708 { |
735 PZ_Lock(store->lock); | 709 PZ_Lock(store->lock); |
736 nssHash_Iterate(store->issuer_and_serial, cert_dump_iter, arg); | 710 nssHash_Iterate(store->issuer_and_serial, cert_dump_iter, arg); |
737 PZ_Unlock(store->lock); | 711 PZ_Unlock(store->lock); |
738 } | 712 } |
739 | 713 |
OLD | NEW |