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 * Implementation of OCSP services, for both client and server. | 6 * Implementation of OCSP services, for both client and server. |
7 * (XXX, really, mostly just for client right now, but intended to do both.) | 7 * (XXX, really, mostly just for client right now, but intended to do both.) |
8 */ | 8 */ |
9 | 9 |
10 #include "prerror.h" | 10 #include "prerror.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 OCSPCacheItem *lessRecent; | 50 OCSPCacheItem *lessRecent; |
51 | 51 |
52 /* key */ | 52 /* key */ |
53 CERTOCSPCertID *certID; | 53 CERTOCSPCertID *certID; |
54 /* CertID's arena also used to allocate "this" cache item */ | 54 /* CertID's arena also used to allocate "this" cache item */ |
55 | 55 |
56 /* cache control information */ | 56 /* cache control information */ |
57 PRTime nextFetchAttemptTime; | 57 PRTime nextFetchAttemptTime; |
58 | 58 |
59 /* Cached contents. Use a separate arena, because lifetime is different */ | 59 /* Cached contents. Use a separate arena, because lifetime is different */ |
60 PRArenaPool *certStatusArena; /* NULL means: no cert status cached */ | 60 PLArenaPool *certStatusArena; /* NULL means: no cert status cached */ |
61 ocspCertStatus certStatus; | 61 ocspCertStatus certStatus; |
62 | 62 |
63 /* This may contain an error code when no OCSP response is available. */ | 63 /* This may contain an error code when no OCSP response is available. */ |
64 SECErrorCodes missingResponseError; | 64 SECErrorCodes missingResponseError; |
65 | 65 |
66 PRPackedBool haveThisUpdate; | 66 PRPackedBool haveThisUpdate; |
67 PRPackedBool haveNextUpdate; | 67 PRPackedBool haveNextUpdate; |
68 PRTime thisUpdate; | 68 PRTime thisUpdate; |
69 PRTime nextUpdate; | 69 PRTime nextUpdate; |
70 }; | 70 }; |
(...skipping 23 matching lines...) Expand all Loading... |
94 DEFAULT_OSCP_TIMEOUT_SECONDS, | 94 DEFAULT_OSCP_TIMEOUT_SECONDS, |
95 {NULL, 0, NULL, NULL}, | 95 {NULL, 0, NULL, NULL}, |
96 ocspMode_FailureIsVerificationFailure, | 96 ocspMode_FailureIsVerificationFailure, |
97 NULL | 97 NULL |
98 }; | 98 }; |
99 | 99 |
100 | 100 |
101 | 101 |
102 /* Forward declarations */ | 102 /* Forward declarations */ |
103 static SECItem * | 103 static SECItem * |
104 ocsp_GetEncodedOCSPResponseFromRequest(PRArenaPool *arena, | 104 ocsp_GetEncodedOCSPResponseFromRequest(PLArenaPool *arena, |
105 CERTOCSPRequest *request, | 105 CERTOCSPRequest *request, |
106 const char *location, int64 time, | 106 const char *location, PRTime time, |
107 PRBool addServiceLocator, | 107 PRBool addServiceLocator, |
108 void *pwArg, | 108 void *pwArg, |
109 CERTOCSPRequest **pRequest); | 109 CERTOCSPRequest **pRequest); |
110 static SECStatus | 110 static SECStatus |
111 ocsp_GetOCSPStatusFromNetwork(CERTCertDBHandle *handle, | 111 ocsp_GetOCSPStatusFromNetwork(CERTCertDBHandle *handle, |
112 CERTOCSPCertID *certID, | 112 CERTOCSPCertID *certID, |
113 CERTCertificate *cert, | 113 CERTCertificate *cert, |
114 int64 time, | 114 PRTime time, |
115 void *pwArg, | 115 void *pwArg, |
116 PRBool *certIDWasConsumed, | 116 PRBool *certIDWasConsumed, |
117 SECStatus *rv_ocsp); | 117 SECStatus *rv_ocsp); |
118 | 118 |
119 static SECStatus | 119 static SECStatus |
120 ocsp_CacheEncodedOCSPResponse(CERTCertDBHandle *handle, | 120 ocsp_CacheEncodedOCSPResponse(CERTCertDBHandle *handle, |
121 CERTOCSPCertID *certID, | 121 CERTOCSPCertID *certID, |
122 CERTCertificate *cert, | 122 CERTCertificate *cert, |
123 » » » int64 time, | 123 » » » PRTime time, |
124 void *pwArg, | 124 void *pwArg, |
125 const SECItem *encodedResponse, | 125 const SECItem *encodedResponse, |
126 PRBool cacheInvalid, | 126 PRBool cacheInvalid, |
127 PRBool *certIDWasConsumed, | 127 PRBool *certIDWasConsumed, |
128 SECStatus *rv_ocsp); | 128 SECStatus *rv_ocsp); |
129 | 129 |
130 static SECStatus | 130 static SECStatus |
131 ocsp_GetVerifiedSingleResponseForCertID(CERTCertDBHandle *handle, | 131 ocsp_GetVerifiedSingleResponseForCertID(CERTCertDBHandle *handle, |
132 CERTOCSPResponse *response, | 132 CERTOCSPResponse *response, |
133 CERTOCSPCertID *certID, | 133 CERTOCSPCertID *certID, |
134 CERTCertificate *signerCert, | 134 CERTCertificate *signerCert, |
135 int64 time, | 135 PRTime time, |
136 CERTOCSPSingleResponse **pSingleResponse
); | 136 CERTOCSPSingleResponse **pSingleResponse
); |
137 | 137 |
138 static SECStatus | 138 static SECStatus |
139 ocsp_CertRevokedAfter(ocspRevokedInfo *revokedInfo, int64 time); | 139 ocsp_CertRevokedAfter(ocspRevokedInfo *revokedInfo, PRTime time); |
140 | 140 |
141 static CERTOCSPCertID * | 141 static CERTOCSPCertID * |
142 cert_DupOCSPCertID(CERTOCSPCertID *src); | 142 cert_DupOCSPCertID(CERTOCSPCertID *src); |
143 | 143 |
144 #ifndef DEBUG | 144 #ifndef DEBUG |
145 #define OCSP_TRACE(msg) | 145 #define OCSP_TRACE(msg) |
146 #define OCSP_TRACE_TIME(msg, time) | 146 #define OCSP_TRACE_TIME(msg, time) |
147 #define OCSP_TRACE_CERT(cert) | 147 #define OCSP_TRACE_CERT(cert) |
148 #define OCSP_TRACE_CERTID(certid) | 148 #define OCSP_TRACE_CERTID(certid) |
149 #else | 149 #else |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 | 182 |
183 if (!wantOcspTrace()) | 183 if (!wantOcspTrace()) |
184 return; | 184 return; |
185 va_start(args, format); | 185 va_start(args, format); |
186 PR_vsnprintf(buf, sizeof(buf), format, args); | 186 PR_vsnprintf(buf, sizeof(buf), format, args); |
187 va_end(args); | 187 va_end(args); |
188 PR_LogPrint("%s", buf); | 188 PR_LogPrint("%s", buf); |
189 } | 189 } |
190 | 190 |
191 static void | 191 static void |
192 ocsp_dumpStringWithTime(const char *str, int64 time) | 192 ocsp_dumpStringWithTime(const char *str, PRTime time) |
193 { | 193 { |
194 PRExplodedTime timePrintable; | 194 PRExplodedTime timePrintable; |
195 char timestr[256]; | 195 char timestr[256]; |
196 | 196 |
197 if (!wantOcspTrace()) | 197 if (!wantOcspTrace()) |
198 return; | 198 return; |
199 PR_ExplodeTime(time, PR_GMTParameters, &timePrintable); | 199 PR_ExplodeTime(time, PR_GMTParameters, &timePrintable); |
200 if (PR_FormatTime(timestr, 256, "%a %b %d %H:%M:%S %Y", &timePrintable)) { | 200 if (PR_FormatTime(timestr, 256, "%a %b %d %H:%M:%S %Y", &timePrintable)) { |
201 ocsp_Trace("OCSP %s %s\n", str, timestr); | 201 ocsp_Trace("OCSP %s %s\n", str, timestr); |
202 } | 202 } |
(...skipping 20 matching lines...) Expand all Loading... |
223 | 223 |
224 static void | 224 static void |
225 dumpCertificate(CERTCertificate *cert) | 225 dumpCertificate(CERTCertificate *cert) |
226 { | 226 { |
227 if (!wantOcspTrace()) | 227 if (!wantOcspTrace()) |
228 return; | 228 return; |
229 | 229 |
230 ocsp_Trace("OCSP ----------------\n"); | 230 ocsp_Trace("OCSP ----------------\n"); |
231 ocsp_Trace("OCSP ## SUBJECT: %s\n", cert->subjectName); | 231 ocsp_Trace("OCSP ## SUBJECT: %s\n", cert->subjectName); |
232 { | 232 { |
233 int64 timeBefore, timeAfter; | 233 PRTime timeBefore, timeAfter; |
234 PRExplodedTime beforePrintable, afterPrintable; | 234 PRExplodedTime beforePrintable, afterPrintable; |
235 char beforestr[256], afterstr[256]; | 235 char beforestr[256], afterstr[256]; |
236 PRStatus rv1, rv2; | 236 PRStatus rv1, rv2; |
237 DER_DecodeTimeChoice(&timeBefore, &cert->validity.notBefore); | 237 DER_DecodeTimeChoice(&timeBefore, &cert->validity.notBefore); |
238 DER_DecodeTimeChoice(&timeAfter, &cert->validity.notAfter); | 238 DER_DecodeTimeChoice(&timeAfter, &cert->validity.notAfter); |
239 PR_ExplodeTime(timeBefore, PR_GMTParameters, &beforePrintable); | 239 PR_ExplodeTime(timeBefore, PR_GMTParameters, &beforePrintable); |
240 PR_ExplodeTime(timeAfter, PR_GMTParameters, &afterPrintable); | 240 PR_ExplodeTime(timeAfter, PR_GMTParameters, &afterPrintable); |
241 rv1 = PR_FormatTime(beforestr, 256, "%a %b %d %H:%M:%S %Y", | 241 rv1 = PR_FormatTime(beforestr, 256, "%a %b %d %H:%M:%S %Y", |
242 &beforePrintable); | 242 &beforePrintable); |
243 rv2 = PR_FormatTime(afterstr, 256, "%a %b %d %H:%M:%S %Y", | 243 rv2 = PR_FormatTime(afterstr, 256, "%a %b %d %H:%M:%S %Y", |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 | 328 |
329 return (SECEqual == SECITEM_CompareItem(&cid1->issuerNameHash, | 329 return (SECEqual == SECITEM_CompareItem(&cid1->issuerNameHash, |
330 &cid2->issuerNameHash) | 330 &cid2->issuerNameHash) |
331 && SECEqual == SECITEM_CompareItem(&cid1->issuerKeyHash, | 331 && SECEqual == SECITEM_CompareItem(&cid1->issuerKeyHash, |
332 &cid2->issuerKeyHash) | 332 &cid2->issuerKeyHash) |
333 && SECEqual == SECITEM_CompareItem(&cid1->serialNumber, | 333 && SECEqual == SECITEM_CompareItem(&cid1->serialNumber, |
334 &cid2->serialNumber)); | 334 &cid2->serialNumber)); |
335 } | 335 } |
336 | 336 |
337 static SECStatus | 337 static SECStatus |
338 ocsp_CopyRevokedInfo(PRArenaPool *arena, ocspCertStatus *dest, | 338 ocsp_CopyRevokedInfo(PLArenaPool *arena, ocspCertStatus *dest, |
339 ocspRevokedInfo *src) | 339 ocspRevokedInfo *src) |
340 { | 340 { |
341 SECStatus rv = SECFailure; | 341 SECStatus rv = SECFailure; |
342 void *mark; | 342 void *mark; |
343 | 343 |
344 mark = PORT_ArenaMark(arena); | 344 mark = PORT_ArenaMark(arena); |
345 | 345 |
346 dest->certStatusInfo.revokedInfo = | 346 dest->certStatusInfo.revokedInfo = |
347 (ocspRevokedInfo *) PORT_ArenaZAlloc(arena, sizeof(ocspRevokedInfo)); | 347 (ocspRevokedInfo *) PORT_ArenaZAlloc(arena, sizeof(ocspRevokedInfo)); |
348 if (!dest->certStatusInfo.revokedInfo) { | 348 if (!dest->certStatusInfo.revokedInfo) { |
(...skipping 19 matching lines...) Expand all Loading... |
368 | 368 |
369 PORT_ArenaUnmark(arena, mark); | 369 PORT_ArenaUnmark(arena, mark); |
370 return SECSuccess; | 370 return SECSuccess; |
371 | 371 |
372 loser: | 372 loser: |
373 PORT_ArenaRelease(arena, mark); | 373 PORT_ArenaRelease(arena, mark); |
374 return SECFailure; | 374 return SECFailure; |
375 } | 375 } |
376 | 376 |
377 static SECStatus | 377 static SECStatus |
378 ocsp_CopyCertStatus(PRArenaPool *arena, ocspCertStatus *dest, | 378 ocsp_CopyCertStatus(PLArenaPool *arena, ocspCertStatus *dest, |
379 ocspCertStatus*src) | 379 ocspCertStatus*src) |
380 { | 380 { |
381 SECStatus rv = SECFailure; | 381 SECStatus rv = SECFailure; |
382 dest->certStatusType = src->certStatusType; | 382 dest->certStatusType = src->certStatusType; |
383 | 383 |
384 switch (src->certStatusType) { | 384 switch (src->certStatusType) { |
385 case ocspCertStatus_good: | 385 case ocspCertStatus_good: |
386 dest->certStatusInfo.goodInfo = | 386 dest->certStatusInfo.goodInfo = |
387 SECITEM_ArenaDupItem(arena, src->certStatusInfo.goodInfo); | 387 SECITEM_ArenaDupItem(arena, src->certStatusInfo.goodInfo); |
388 if (dest->certStatusInfo.goodInfo != NULL) { | 388 if (dest->certStatusInfo.goodInfo != NULL) { |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 } | 603 } |
604 PR_ExitMonitor(OCSP_Global.monitor); | 604 PR_ExitMonitor(OCSP_Global.monitor); |
605 return SECSuccess; | 605 return SECSuccess; |
606 } | 606 } |
607 | 607 |
608 static SECStatus | 608 static SECStatus |
609 ocsp_CreateCacheItemAndConsumeCertID(OCSPCacheData *cache, | 609 ocsp_CreateCacheItemAndConsumeCertID(OCSPCacheData *cache, |
610 CERTOCSPCertID *certID, | 610 CERTOCSPCertID *certID, |
611 OCSPCacheItem **pCacheItem) | 611 OCSPCacheItem **pCacheItem) |
612 { | 612 { |
613 PRArenaPool *arena; | 613 PLArenaPool *arena; |
614 void *mark; | 614 void *mark; |
615 PLHashEntry *new_hash_entry; | 615 PLHashEntry *new_hash_entry; |
616 OCSPCacheItem *item; | 616 OCSPCacheItem *item; |
617 | 617 |
618 PORT_Assert(pCacheItem != NULL); | 618 PORT_Assert(pCacheItem != NULL); |
619 *pCacheItem = NULL; | 619 *pCacheItem = NULL; |
620 | 620 |
621 PR_EnterMonitor(OCSP_Global.monitor); | 621 PR_EnterMonitor(OCSP_Global.monitor); |
622 arena = certID->poolp; | 622 arena = certID->poolp; |
623 mark = PORT_ArenaMark(arena); | 623 mark = PORT_ArenaMark(arena); |
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1435 | 1435 |
1436 /* | 1436 /* |
1437 * REQUEST SUPPORT FUNCTIONS (encode/create/decode/destroy): | 1437 * REQUEST SUPPORT FUNCTIONS (encode/create/decode/destroy): |
1438 */ | 1438 */ |
1439 | 1439 |
1440 /* | 1440 /* |
1441 * FUNCTION: CERT_EncodeOCSPRequest | 1441 * FUNCTION: CERT_EncodeOCSPRequest |
1442 * DER encodes an OCSP Request, possibly adding a signature as well. | 1442 * DER encodes an OCSP Request, possibly adding a signature as well. |
1443 * XXX Signing is not yet supported, however; see comments in code. | 1443 * XXX Signing is not yet supported, however; see comments in code. |
1444 * INPUTS: | 1444 * INPUTS: |
1445 * PRArenaPool *arena | 1445 * PLArenaPool *arena |
1446 * The return value is allocated from here. | 1446 * The return value is allocated from here. |
1447 * If a NULL is passed in, allocation is done from the heap instead. | 1447 * If a NULL is passed in, allocation is done from the heap instead. |
1448 * CERTOCSPRequest *request | 1448 * CERTOCSPRequest *request |
1449 * The request to be encoded. | 1449 * The request to be encoded. |
1450 * void *pwArg | 1450 * void *pwArg |
1451 * Pointer to argument for password prompting, if needed. (Definitely | 1451 * Pointer to argument for password prompting, if needed. (Definitely |
1452 * not needed if not signing.) | 1452 * not needed if not signing.) |
1453 * RETURN: | 1453 * RETURN: |
1454 * Returns a NULL on error and a pointer to the SECItem with the | 1454 * Returns a NULL on error and a pointer to the SECItem with the |
1455 * encoded value otherwise. Any error is likely to be low-level | 1455 * encoded value otherwise. Any error is likely to be low-level |
1456 * (e.g. no memory). | 1456 * (e.g. no memory). |
1457 */ | 1457 */ |
1458 SECItem * | 1458 SECItem * |
1459 CERT_EncodeOCSPRequest(PRArenaPool *arena, CERTOCSPRequest *request, | 1459 CERT_EncodeOCSPRequest(PLArenaPool *arena, CERTOCSPRequest *request, |
1460 void *pwArg) | 1460 void *pwArg) |
1461 { | 1461 { |
1462 ocspTBSRequest *tbsRequest; | 1462 ocspTBSRequest *tbsRequest; |
1463 SECStatus rv; | 1463 SECStatus rv; |
1464 | 1464 |
1465 /* XXX All of these should generate errors if they fail. */ | 1465 /* XXX All of these should generate errors if they fail. */ |
1466 PORT_Assert(request); | 1466 PORT_Assert(request); |
1467 PORT_Assert(request->tbsRequest); | 1467 PORT_Assert(request->tbsRequest); |
1468 | 1468 |
1469 tbsRequest = request->tbsRequest; | 1469 tbsRequest = request->tbsRequest; |
(...skipping 26 matching lines...) Expand all Loading... |
1496 * SECItem *src | 1496 * SECItem *src |
1497 * Pointer to a SECItem holding DER encoded OCSP Request. | 1497 * Pointer to a SECItem holding DER encoded OCSP Request. |
1498 * RETURN: | 1498 * RETURN: |
1499 * Returns a pointer to a CERTOCSPRequest containing the decoded request. | 1499 * Returns a pointer to a CERTOCSPRequest containing the decoded request. |
1500 * On error, returns NULL. Most likely error is trouble decoding | 1500 * On error, returns NULL. Most likely error is trouble decoding |
1501 * (SEC_ERROR_OCSP_MALFORMED_REQUEST), or low-level problem (no memory). | 1501 * (SEC_ERROR_OCSP_MALFORMED_REQUEST), or low-level problem (no memory). |
1502 */ | 1502 */ |
1503 CERTOCSPRequest * | 1503 CERTOCSPRequest * |
1504 CERT_DecodeOCSPRequest(const SECItem *src) | 1504 CERT_DecodeOCSPRequest(const SECItem *src) |
1505 { | 1505 { |
1506 PRArenaPool *arena = NULL; | 1506 PLArenaPool *arena = NULL; |
1507 SECStatus rv = SECFailure; | 1507 SECStatus rv = SECFailure; |
1508 CERTOCSPRequest *dest = NULL; | 1508 CERTOCSPRequest *dest = NULL; |
1509 int i; | 1509 int i; |
1510 SECItem newSrc; | 1510 SECItem newSrc; |
1511 | 1511 |
1512 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); | 1512 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); |
1513 if (arena == NULL) { | 1513 if (arena == NULL) { |
1514 goto loser; | 1514 goto loser; |
1515 } | 1515 } |
1516 dest = (CERTOCSPRequest *) PORT_ArenaZAlloc(arena, | 1516 dest = (CERTOCSPRequest *) PORT_ArenaZAlloc(arena, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1564 | 1564 |
1565 /* | 1565 /* |
1566 * Digest data using the specified algorithm. | 1566 * Digest data using the specified algorithm. |
1567 * The necessary storage for the digest data is allocated. If "fill" is | 1567 * The necessary storage for the digest data is allocated. If "fill" is |
1568 * non-null, the data is put there, otherwise a SECItem is allocated. | 1568 * non-null, the data is put there, otherwise a SECItem is allocated. |
1569 * Allocation from "arena" if it is non-null, heap otherwise. Any problem | 1569 * Allocation from "arena" if it is non-null, heap otherwise. Any problem |
1570 * results in a NULL being returned (and an appropriate error set). | 1570 * results in a NULL being returned (and an appropriate error set). |
1571 */ | 1571 */ |
1572 | 1572 |
1573 SECItem * | 1573 SECItem * |
1574 ocsp_DigestValue(PRArenaPool *arena, SECOidTag digestAlg, | 1574 ocsp_DigestValue(PLArenaPool *arena, SECOidTag digestAlg, |
1575 SECItem *fill, const SECItem *src) | 1575 SECItem *fill, const SECItem *src) |
1576 { | 1576 { |
1577 const SECHashObject *digestObject; | 1577 const SECHashObject *digestObject; |
1578 SECItem *result = NULL; | 1578 SECItem *result = NULL; |
1579 void *mark = NULL; | 1579 void *mark = NULL; |
1580 void *digestBuff = NULL; | 1580 void *digestBuff = NULL; |
1581 | 1581 |
1582 if ( arena != NULL ) { | 1582 if ( arena != NULL ) { |
1583 mark = PORT_ArenaMark(arena); | 1583 mark = PORT_ArenaMark(arena); |
1584 } | 1584 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1628 } | 1628 } |
1629 | 1629 |
1630 /* | 1630 /* |
1631 * Digest the cert's subject public key using the specified algorithm. | 1631 * Digest the cert's subject public key using the specified algorithm. |
1632 * The necessary storage for the digest data is allocated. If "fill" is | 1632 * The necessary storage for the digest data is allocated. If "fill" is |
1633 * non-null, the data is put there, otherwise a SECItem is allocated. | 1633 * non-null, the data is put there, otherwise a SECItem is allocated. |
1634 * Allocation from "arena" if it is non-null, heap otherwise. Any problem | 1634 * Allocation from "arena" if it is non-null, heap otherwise. Any problem |
1635 * results in a NULL being returned (and an appropriate error set). | 1635 * results in a NULL being returned (and an appropriate error set). |
1636 */ | 1636 */ |
1637 SECItem * | 1637 SECItem * |
1638 CERT_GetSPKIDigest(PRArenaPool *arena, const CERTCertificate *cert, | 1638 CERT_GetSPKIDigest(PLArenaPool *arena, const CERTCertificate *cert, |
1639 SECOidTag digestAlg, SECItem *fill) | 1639 SECOidTag digestAlg, SECItem *fill) |
1640 { | 1640 { |
1641 SECItem spk; | 1641 SECItem spk; |
1642 | 1642 |
1643 /* | 1643 /* |
1644 * Copy just the length and data pointer (nothing needs to be freed) | 1644 * Copy just the length and data pointer (nothing needs to be freed) |
1645 * of the subject public key so we can convert the length from bits | 1645 * of the subject public key so we can convert the length from bits |
1646 * to bytes, which is what the digest function expects. | 1646 * to bytes, which is what the digest function expects. |
1647 */ | 1647 */ |
1648 spk = cert->subjectPublicKeyInfo.subjectPublicKey; | 1648 spk = cert->subjectPublicKeyInfo.subjectPublicKey; |
1649 DER_ConvertBitString(&spk); | 1649 DER_ConvertBitString(&spk); |
1650 | 1650 |
1651 return ocsp_DigestValue(arena, digestAlg, fill, &spk); | 1651 return ocsp_DigestValue(arena, digestAlg, fill, &spk); |
1652 } | 1652 } |
1653 | 1653 |
1654 /* | 1654 /* |
1655 * Digest the cert's subject name using the specified algorithm. | 1655 * Digest the cert's subject name using the specified algorithm. |
1656 */ | 1656 */ |
1657 static SECItem * | 1657 static SECItem * |
1658 cert_GetSubjectNameDigest(PRArenaPool *arena, const CERTCertificate *cert, | 1658 cert_GetSubjectNameDigest(PLArenaPool *arena, const CERTCertificate *cert, |
1659 SECOidTag digestAlg, SECItem *fill) | 1659 SECOidTag digestAlg, SECItem *fill) |
1660 { | 1660 { |
1661 SECItem name; | 1661 SECItem name; |
1662 | 1662 |
1663 /* | 1663 /* |
1664 * Copy just the length and data pointer (nothing needs to be freed) | 1664 * Copy just the length and data pointer (nothing needs to be freed) |
1665 * of the subject name | 1665 * of the subject name |
1666 */ | 1666 */ |
1667 name = cert->derSubject; | 1667 name = cert->derSubject; |
1668 | 1668 |
1669 return ocsp_DigestValue(arena, digestAlg, fill, &name); | 1669 return ocsp_DigestValue(arena, digestAlg, fill, &name); |
1670 } | 1670 } |
1671 | 1671 |
1672 /* | 1672 /* |
1673 * Create and fill-in a CertID. This function fills in the hash values | 1673 * Create and fill-in a CertID. This function fills in the hash values |
1674 * (issuerNameHash and issuerKeyHash), and is hardwired to use SHA1. | 1674 * (issuerNameHash and issuerKeyHash), and is hardwired to use SHA1. |
1675 * Someday it might need to be more flexible about hash algorithm, but | 1675 * Someday it might need to be more flexible about hash algorithm, but |
1676 * for now we have no intention/need to create anything else. | 1676 * for now we have no intention/need to create anything else. |
1677 * | 1677 * |
1678 * Error causes a null to be returned; most likely cause is trouble | 1678 * Error causes a null to be returned; most likely cause is trouble |
1679 * finding the certificate issuer (SEC_ERROR_UNKNOWN_ISSUER). | 1679 * finding the certificate issuer (SEC_ERROR_UNKNOWN_ISSUER). |
1680 * Other errors are low-level problems (no memory, bad database, etc.). | 1680 * Other errors are low-level problems (no memory, bad database, etc.). |
1681 */ | 1681 */ |
1682 static CERTOCSPCertID * | 1682 static CERTOCSPCertID * |
1683 ocsp_CreateCertID(PRArenaPool *arena, CERTCertificate *cert, int64 time) | 1683 ocsp_CreateCertID(PLArenaPool *arena, CERTCertificate *cert, PRTime time) |
1684 { | 1684 { |
1685 CERTOCSPCertID *certID; | 1685 CERTOCSPCertID *certID; |
1686 CERTCertificate *issuerCert = NULL; | 1686 CERTCertificate *issuerCert = NULL; |
1687 void *mark = PORT_ArenaMark(arena); | 1687 void *mark = PORT_ArenaMark(arena); |
1688 SECStatus rv; | 1688 SECStatus rv; |
1689 | 1689 |
1690 PORT_Assert(arena != NULL); | 1690 PORT_Assert(arena != NULL); |
1691 | 1691 |
1692 certID = PORT_ArenaZNew(arena, CERTOCSPCertID); | 1692 certID = PORT_ArenaZNew(arena, CERTOCSPCertID); |
1693 if (certID == NULL) { | 1693 if (certID == NULL) { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1753 | 1753 |
1754 loser: | 1754 loser: |
1755 if (issuerCert != NULL) { | 1755 if (issuerCert != NULL) { |
1756 CERT_DestroyCertificate(issuerCert); | 1756 CERT_DestroyCertificate(issuerCert); |
1757 } | 1757 } |
1758 PORT_ArenaRelease(arena, mark); | 1758 PORT_ArenaRelease(arena, mark); |
1759 return NULL; | 1759 return NULL; |
1760 } | 1760 } |
1761 | 1761 |
1762 CERTOCSPCertID* | 1762 CERTOCSPCertID* |
1763 CERT_CreateOCSPCertID(CERTCertificate *cert, int64 time) | 1763 CERT_CreateOCSPCertID(CERTCertificate *cert, PRTime time) |
1764 { | 1764 { |
1765 PRArenaPool *arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); | 1765 PLArenaPool *arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); |
1766 CERTOCSPCertID *certID; | 1766 CERTOCSPCertID *certID; |
1767 PORT_Assert(arena != NULL); | 1767 PORT_Assert(arena != NULL); |
1768 if (!arena) | 1768 if (!arena) |
1769 return NULL; | 1769 return NULL; |
1770 | 1770 |
1771 certID = ocsp_CreateCertID(arena, cert, time); | 1771 certID = ocsp_CreateCertID(arena, cert, time); |
1772 if (!certID) { | 1772 if (!certID) { |
1773 PORT_FreeArena(arena, PR_FALSE); | 1773 PORT_FreeArena(arena, PR_FALSE); |
1774 return NULL; | 1774 return NULL; |
1775 } | 1775 } |
1776 certID->poolp = arena; | 1776 certID->poolp = arena; |
1777 return certID; | 1777 return certID; |
1778 } | 1778 } |
1779 | 1779 |
1780 static CERTOCSPCertID * | 1780 static CERTOCSPCertID * |
1781 cert_DupOCSPCertID(CERTOCSPCertID *src) | 1781 cert_DupOCSPCertID(CERTOCSPCertID *src) |
1782 { | 1782 { |
1783 CERTOCSPCertID *dest; | 1783 CERTOCSPCertID *dest; |
1784 PRArenaPool *arena = NULL; | 1784 PLArenaPool *arena = NULL; |
1785 | 1785 |
1786 if (!src) { | 1786 if (!src) { |
1787 PORT_SetError(SEC_ERROR_INVALID_ARGS); | 1787 PORT_SetError(SEC_ERROR_INVALID_ARGS); |
1788 return NULL; | 1788 return NULL; |
1789 } | 1789 } |
1790 | 1790 |
1791 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); | 1791 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); |
1792 if (!arena) | 1792 if (!arena) |
1793 goto loser; | 1793 goto loser; |
1794 | 1794 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1913 * response expects this array to be in the exact same order as the | 1913 * response expects this array to be in the exact same order as the |
1914 * certs are found in the list. It would be harder to change that | 1914 * certs are found in the list. It would be harder to change that |
1915 * order than preserve it, but since the requirement is not obvious, | 1915 * order than preserve it, but since the requirement is not obvious, |
1916 * it deserves to be mentioned. | 1916 * it deserves to be mentioned. |
1917 * | 1917 * |
1918 * Any problem causes a null return and error set: | 1918 * Any problem causes a null return and error set: |
1919 * SEC_ERROR_UNKNOWN_ISSUER | 1919 * SEC_ERROR_UNKNOWN_ISSUER |
1920 * Other errors are low-level problems (no memory, bad database, etc.). | 1920 * Other errors are low-level problems (no memory, bad database, etc.). |
1921 */ | 1921 */ |
1922 static ocspSingleRequest ** | 1922 static ocspSingleRequest ** |
1923 ocsp_CreateSingleRequestList(PRArenaPool *arena, CERTCertList *certList, | 1923 ocsp_CreateSingleRequestList(PLArenaPool *arena, CERTCertList *certList, |
1924 int64 time, PRBool includeLocator) | 1924 PRTime time, PRBool includeLocator) |
1925 { | 1925 { |
1926 ocspSingleRequest **requestList = NULL; | 1926 ocspSingleRequest **requestList = NULL; |
1927 CERTCertListNode *node = NULL; | 1927 CERTCertListNode *node = NULL; |
1928 int i, count; | 1928 int i, count; |
1929 void *mark = PORT_ArenaMark(arena); | 1929 void *mark = PORT_ArenaMark(arena); |
1930 | 1930 |
1931 node = CERT_LIST_HEAD(certList); | 1931 node = CERT_LIST_HEAD(certList); |
1932 for (count = 0; !CERT_LIST_END(node, certList); count++) { | 1932 for (count = 0; !CERT_LIST_END(node, certList); count++) { |
1933 node = CERT_LIST_NEXT(node); | 1933 node = CERT_LIST_NEXT(node); |
1934 } | 1934 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1968 PORT_ArenaUnmark(arena, mark); | 1968 PORT_ArenaUnmark(arena, mark); |
1969 requestList[i] = NULL; | 1969 requestList[i] = NULL; |
1970 return requestList; | 1970 return requestList; |
1971 | 1971 |
1972 loser: | 1972 loser: |
1973 PORT_ArenaRelease(arena, mark); | 1973 PORT_ArenaRelease(arena, mark); |
1974 return NULL; | 1974 return NULL; |
1975 } | 1975 } |
1976 | 1976 |
1977 static ocspSingleRequest ** | 1977 static ocspSingleRequest ** |
1978 ocsp_CreateRequestFromCert(PRArenaPool *arena, | 1978 ocsp_CreateRequestFromCert(PLArenaPool *arena, |
1979 CERTOCSPCertID *certID, | 1979 CERTOCSPCertID *certID, |
1980 CERTCertificate *singleCert, | 1980 CERTCertificate *singleCert, |
1981 int64 time, | 1981 PRTime time, |
1982 PRBool includeLocator) | 1982 PRBool includeLocator) |
1983 { | 1983 { |
1984 ocspSingleRequest **requestList = NULL; | 1984 ocspSingleRequest **requestList = NULL; |
1985 void *mark = PORT_ArenaMark(arena); | 1985 void *mark = PORT_ArenaMark(arena); |
1986 PORT_Assert(certID != NULL && singleCert != NULL); | 1986 PORT_Assert(certID != NULL && singleCert != NULL); |
1987 | 1987 |
1988 /* meaning of value 2: one entry + one end marker */ | 1988 /* meaning of value 2: one entry + one end marker */ |
1989 requestList = PORT_ArenaNewArray(arena, ocspSingleRequest *, 2); | 1989 requestList = PORT_ArenaNewArray(arena, ocspSingleRequest *, 2); |
1990 if (requestList == NULL) | 1990 if (requestList == NULL) |
1991 goto loser; | 1991 goto loser; |
(...skipping 16 matching lines...) Expand all Loading... |
2008 return requestList; | 2008 return requestList; |
2009 | 2009 |
2010 loser: | 2010 loser: |
2011 PORT_ArenaRelease(arena, mark); | 2011 PORT_ArenaRelease(arena, mark); |
2012 return NULL; | 2012 return NULL; |
2013 } | 2013 } |
2014 | 2014 |
2015 static CERTOCSPRequest * | 2015 static CERTOCSPRequest * |
2016 ocsp_prepareEmptyOCSPRequest(void) | 2016 ocsp_prepareEmptyOCSPRequest(void) |
2017 { | 2017 { |
2018 PRArenaPool *arena = NULL; | 2018 PLArenaPool *arena = NULL; |
2019 CERTOCSPRequest *request = NULL; | 2019 CERTOCSPRequest *request = NULL; |
2020 ocspTBSRequest *tbsRequest = NULL; | 2020 ocspTBSRequest *tbsRequest = NULL; |
2021 | 2021 |
2022 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); | 2022 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); |
2023 if (arena == NULL) { | 2023 if (arena == NULL) { |
2024 goto loser; | 2024 goto loser; |
2025 } | 2025 } |
2026 request = PORT_ArenaZNew(arena, CERTOCSPRequest); | 2026 request = PORT_ArenaZNew(arena, CERTOCSPRequest); |
2027 if (request == NULL) { | 2027 if (request == NULL) { |
2028 goto loser; | 2028 goto loser; |
(...skipping 11 matching lines...) Expand all Loading... |
2040 loser: | 2040 loser: |
2041 if (arena != NULL) { | 2041 if (arena != NULL) { |
2042 PORT_FreeArena(arena, PR_FALSE); | 2042 PORT_FreeArena(arena, PR_FALSE); |
2043 } | 2043 } |
2044 return NULL; | 2044 return NULL; |
2045 } | 2045 } |
2046 | 2046 |
2047 CERTOCSPRequest * | 2047 CERTOCSPRequest * |
2048 cert_CreateSingleCertOCSPRequest(CERTOCSPCertID *certID, | 2048 cert_CreateSingleCertOCSPRequest(CERTOCSPCertID *certID, |
2049 CERTCertificate *singleCert, | 2049 CERTCertificate *singleCert, |
2050 int64 time, | 2050 PRTime time, |
2051 PRBool addServiceLocator, | 2051 PRBool addServiceLocator, |
2052 CERTCertificate *signerCert) | 2052 CERTCertificate *signerCert) |
2053 { | 2053 { |
2054 CERTOCSPRequest *request; | 2054 CERTOCSPRequest *request; |
2055 OCSP_TRACE(("OCSP cert_CreateSingleCertOCSPRequest %s\n", singleCert->subjec
tName)); | 2055 OCSP_TRACE(("OCSP cert_CreateSingleCertOCSPRequest %s\n", singleCert->subjec
tName)); |
2056 | 2056 |
2057 /* XXX Support for signerCert may be implemented later, | 2057 /* XXX Support for signerCert may be implemented later, |
2058 * see also the comment in CERT_CreateOCSPRequest. | 2058 * see also the comment in CERT_CreateOCSPRequest. |
2059 */ | 2059 */ |
2060 if (signerCert != NULL) { | 2060 if (signerCert != NULL) { |
(...skipping 27 matching lines...) Expand all Loading... |
2088 * the given list. | 2088 * the given list. |
2089 * INPUTS: | 2089 * INPUTS: |
2090 * CERTCertList *certList | 2090 * CERTCertList *certList |
2091 * A list of certs for which status will be requested. | 2091 * A list of certs for which status will be requested. |
2092 * Note that all of these certificates should have the same issuer, | 2092 * Note that all of these certificates should have the same issuer, |
2093 * or it's expected the response will be signed by a trusted responder. | 2093 * or it's expected the response will be signed by a trusted responder. |
2094 * If the certs need to be broken up into multiple requests, that | 2094 * If the certs need to be broken up into multiple requests, that |
2095 * must be handled by the caller (and thus by having multiple calls | 2095 * must be handled by the caller (and thus by having multiple calls |
2096 * to this routine), who knows about where the request(s) are being | 2096 * to this routine), who knows about where the request(s) are being |
2097 * sent and whether there are any trusted responders in place. | 2097 * sent and whether there are any trusted responders in place. |
2098 * int64 time | 2098 * PRTime time |
2099 * Indicates the time for which the certificate status is to be | 2099 * Indicates the time for which the certificate status is to be |
2100 * determined -- this may be used in the search for the cert's issuer | 2100 * determined -- this may be used in the search for the cert's issuer |
2101 * but has no effect on the request itself. | 2101 * but has no effect on the request itself. |
2102 * PRBool addServiceLocator | 2102 * PRBool addServiceLocator |
2103 * If true, the Service Locator extension should be added to the | 2103 * If true, the Service Locator extension should be added to the |
2104 * single request(s) for each cert. | 2104 * single request(s) for each cert. |
2105 * CERTCertificate *signerCert | 2105 * CERTCertificate *signerCert |
2106 * If non-NULL, means sign the request using this cert. Otherwise, | 2106 * If non-NULL, means sign the request using this cert. Otherwise, |
2107 * do not sign. | 2107 * do not sign. |
2108 * XXX note that request signing is not yet supported; see comment in code | 2108 * XXX note that request signing is not yet supported; see comment in code |
2109 * RETURN: | 2109 * RETURN: |
2110 * A pointer to a CERTOCSPRequest structure containing an OCSP request | 2110 * A pointer to a CERTOCSPRequest structure containing an OCSP request |
2111 * for the cert list. On error, null is returned, with an error set | 2111 * for the cert list. On error, null is returned, with an error set |
2112 * indicating the reason. This is likely SEC_ERROR_UNKNOWN_ISSUER. | 2112 * indicating the reason. This is likely SEC_ERROR_UNKNOWN_ISSUER. |
2113 * (The issuer is needed to create a request for the certificate.) | 2113 * (The issuer is needed to create a request for the certificate.) |
2114 * Other errors are low-level problems (no memory, bad database, etc.). | 2114 * Other errors are low-level problems (no memory, bad database, etc.). |
2115 */ | 2115 */ |
2116 CERTOCSPRequest * | 2116 CERTOCSPRequest * |
2117 CERT_CreateOCSPRequest(CERTCertList *certList, int64 time, | 2117 CERT_CreateOCSPRequest(CERTCertList *certList, PRTime time, |
2118 PRBool addServiceLocator, | 2118 PRBool addServiceLocator, |
2119 CERTCertificate *signerCert) | 2119 CERTCertificate *signerCert) |
2120 { | 2120 { |
2121 CERTOCSPRequest *request = NULL; | 2121 CERTOCSPRequest *request = NULL; |
2122 | 2122 |
2123 if (!certList) { | 2123 if (!certList) { |
2124 PORT_SetError(SEC_ERROR_INVALID_ARGS); | 2124 PORT_SetError(SEC_ERROR_INVALID_ARGS); |
2125 return NULL; | 2125 return NULL; |
2126 } | 2126 } |
2127 /* | 2127 /* |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2377 } | 2377 } |
2378 | 2378 |
2379 /* | 2379 /* |
2380 * Helper function for decoding SingleResponses -- they each contain | 2380 * Helper function for decoding SingleResponses -- they each contain |
2381 * a status which is encoded as CHOICE, which needs to be decoded "by hand". | 2381 * a status which is encoded as CHOICE, which needs to be decoded "by hand". |
2382 * | 2382 * |
2383 * Note -- on error, this routine does not release the memory it may | 2383 * Note -- on error, this routine does not release the memory it may |
2384 * have allocated; it expects its caller to do that. | 2384 * have allocated; it expects its caller to do that. |
2385 */ | 2385 */ |
2386 static SECStatus | 2386 static SECStatus |
2387 ocsp_FinishDecodingSingleResponses(PRArenaPool *reqArena, | 2387 ocsp_FinishDecodingSingleResponses(PLArenaPool *reqArena, |
2388 CERTOCSPSingleResponse **responses) | 2388 CERTOCSPSingleResponse **responses) |
2389 { | 2389 { |
2390 ocspCertStatus *certStatus; | 2390 ocspCertStatus *certStatus; |
2391 ocspCertStatusType certStatusType; | 2391 ocspCertStatusType certStatusType; |
2392 const SEC_ASN1Template *certStatusTemplate; | 2392 const SEC_ASN1Template *certStatusTemplate; |
2393 int derTag; | 2393 int derTag; |
2394 int i; | 2394 int i; |
2395 SECStatus rv = SECFailure; | 2395 SECStatus rv = SECFailure; |
2396 | 2396 |
2397 if (!reqArena) { | 2397 if (!reqArena) { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2461 break; | 2461 break; |
2462 } | 2462 } |
2463 | 2463 |
2464 return responderIDType; | 2464 return responderIDType; |
2465 } | 2465 } |
2466 | 2466 |
2467 /* | 2467 /* |
2468 * Decode "src" as a BasicOCSPResponse, returning the result. | 2468 * Decode "src" as a BasicOCSPResponse, returning the result. |
2469 */ | 2469 */ |
2470 static ocspBasicOCSPResponse * | 2470 static ocspBasicOCSPResponse * |
2471 ocsp_DecodeBasicOCSPResponse(PRArenaPool *arena, SECItem *src) | 2471 ocsp_DecodeBasicOCSPResponse(PLArenaPool *arena, SECItem *src) |
2472 { | 2472 { |
2473 void *mark; | 2473 void *mark; |
2474 ocspBasicOCSPResponse *basicResponse; | 2474 ocspBasicOCSPResponse *basicResponse; |
2475 ocspResponseData *responseData; | 2475 ocspResponseData *responseData; |
2476 ocspResponderID *responderID; | 2476 ocspResponderID *responderID; |
2477 CERTOCSPResponderIDType responderIDType; | 2477 CERTOCSPResponderIDType responderIDType; |
2478 const SEC_ASN1Template *responderIDTemplate; | 2478 const SEC_ASN1Template *responderIDTemplate; |
2479 int derTag; | 2479 int derTag; |
2480 SECStatus rv; | 2480 SECStatus rv; |
2481 SECItem newsrc; | 2481 SECItem newsrc; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2551 PORT_ArenaRelease(arena, mark); | 2551 PORT_ArenaRelease(arena, mark); |
2552 return NULL; | 2552 return NULL; |
2553 } | 2553 } |
2554 | 2554 |
2555 | 2555 |
2556 /* | 2556 /* |
2557 * Decode the responseBytes based on the responseType found in "rbytes", | 2557 * Decode the responseBytes based on the responseType found in "rbytes", |
2558 * leaving the resulting translated/decoded information in there as well. | 2558 * leaving the resulting translated/decoded information in there as well. |
2559 */ | 2559 */ |
2560 static SECStatus | 2560 static SECStatus |
2561 ocsp_DecodeResponseBytes(PRArenaPool *arena, ocspResponseBytes *rbytes) | 2561 ocsp_DecodeResponseBytes(PLArenaPool *arena, ocspResponseBytes *rbytes) |
2562 { | 2562 { |
2563 PORT_Assert(rbytes != NULL); /* internal error, really */ | 2563 PORT_Assert(rbytes != NULL); /* internal error, really */ |
2564 if (rbytes == NULL) { | 2564 if (rbytes == NULL) { |
2565 PORT_SetError(SEC_ERROR_INVALID_ARGS); /* XXX set better error? */ | 2565 PORT_SetError(SEC_ERROR_INVALID_ARGS); /* XXX set better error? */ |
2566 return SECFailure; | 2566 return SECFailure; |
2567 } | 2567 } |
2568 | 2568 |
2569 rbytes->responseTypeTag = SECOID_FindOIDTag(&rbytes->responseType); | 2569 rbytes->responseTypeTag = SECOID_FindOIDTag(&rbytes->responseType); |
2570 switch (rbytes->responseTypeTag) { | 2570 switch (rbytes->responseTypeTag) { |
2571 case SEC_OID_PKIX_OCSP_BASIC_RESPONSE: | 2571 case SEC_OID_PKIX_OCSP_BASIC_RESPONSE: |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2603 * RETURN: | 2603 * RETURN: |
2604 * Returns a pointer to a CERTOCSPResponse (the decoded OCSP Response); | 2604 * Returns a pointer to a CERTOCSPResponse (the decoded OCSP Response); |
2605 * the caller is responsible for destroying it. Or NULL if error (either | 2605 * the caller is responsible for destroying it. Or NULL if error (either |
2606 * response could not be decoded (SEC_ERROR_OCSP_MALFORMED_RESPONSE), | 2606 * response could not be decoded (SEC_ERROR_OCSP_MALFORMED_RESPONSE), |
2607 * it was of an unexpected type (SEC_ERROR_OCSP_UNKNOWN_RESPONSE_TYPE), | 2607 * it was of an unexpected type (SEC_ERROR_OCSP_UNKNOWN_RESPONSE_TYPE), |
2608 * or a low-level or internal error occurred). | 2608 * or a low-level or internal error occurred). |
2609 */ | 2609 */ |
2610 CERTOCSPResponse * | 2610 CERTOCSPResponse * |
2611 CERT_DecodeOCSPResponse(const SECItem *src) | 2611 CERT_DecodeOCSPResponse(const SECItem *src) |
2612 { | 2612 { |
2613 PRArenaPool *arena = NULL; | 2613 PLArenaPool *arena = NULL; |
2614 CERTOCSPResponse *response = NULL; | 2614 CERTOCSPResponse *response = NULL; |
2615 SECStatus rv = SECFailure; | 2615 SECStatus rv = SECFailure; |
2616 ocspResponseStatus sv; | 2616 ocspResponseStatus sv; |
2617 SECItem newSrc; | 2617 SECItem newSrc; |
2618 | 2618 |
2619 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); | 2619 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); |
2620 if (arena == NULL) { | 2620 if (arena == NULL) { |
2621 goto loser; | 2621 goto loser; |
2622 } | 2622 } |
2623 response = (CERTOCSPResponse *) PORT_ArenaZAlloc(arena, | 2623 response = (CERTOCSPResponse *) PORT_ArenaZAlloc(arena, |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3094 | 3094 |
3095 /* | 3095 /* |
3096 * Reads on the given socket and returns an encoded response when received. | 3096 * Reads on the given socket and returns an encoded response when received. |
3097 * Properly formatted HTTP/1.0 response headers are expected to be read | 3097 * Properly formatted HTTP/1.0 response headers are expected to be read |
3098 * from the socket, preceding a binary-encoded OCSP response. Problems | 3098 * from the socket, preceding a binary-encoded OCSP response. Problems |
3099 * with parsing cause the error SEC_ERROR_OCSP_BAD_HTTP_RESPONSE to be | 3099 * with parsing cause the error SEC_ERROR_OCSP_BAD_HTTP_RESPONSE to be |
3100 * set; any other problems are likely low-level i/o or memory allocation | 3100 * set; any other problems are likely low-level i/o or memory allocation |
3101 * errors. | 3101 * errors. |
3102 */ | 3102 */ |
3103 static SECItem * | 3103 static SECItem * |
3104 ocsp_GetEncodedResponse(PRArenaPool *arena, PRFileDesc *sock) | 3104 ocsp_GetEncodedResponse(PLArenaPool *arena, PRFileDesc *sock) |
3105 { | 3105 { |
3106 /* first read HTTP status line and headers */ | 3106 /* first read HTTP status line and headers */ |
3107 | 3107 |
3108 char* inBuffer = NULL; | 3108 char* inBuffer = NULL; |
3109 PRInt32 offset = 0; | 3109 PRInt32 offset = 0; |
3110 PRInt32 inBufsize = 0; | 3110 PRInt32 inBufsize = 0; |
3111 const PRInt32 bufSizeIncrement = OCSP_BUFSIZE; /* 1 KB at a time */ | 3111 const PRInt32 bufSizeIncrement = OCSP_BUFSIZE; /* 1 KB at a time */ |
3112 const PRInt32 maxBufSize = 8 * bufSizeIncrement ; /* 8 KB max */ | 3112 const PRInt32 maxBufSize = 8 * bufSizeIncrement ; /* 8 KB max */ |
3113 const char* CRLF = "\r\n"; | 3113 const char* CRLF = "\r\n"; |
3114 const PRInt32 CRLFlen = strlen(CRLF); | 3114 const PRInt32 CRLFlen = strlen(CRLF); |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3331 { | 3331 { |
3332 return ocsp_ParseURL(url, pHostname, pPort, pPath); | 3332 return ocsp_ParseURL(url, pHostname, pPort, pPath); |
3333 } | 3333 } |
3334 | 3334 |
3335 /* | 3335 /* |
3336 * Limit the size of http responses we are willing to accept. | 3336 * Limit the size of http responses we are willing to accept. |
3337 */ | 3337 */ |
3338 #define MAX_WANTED_OCSP_RESPONSE_LEN 64*1024 | 3338 #define MAX_WANTED_OCSP_RESPONSE_LEN 64*1024 |
3339 | 3339 |
3340 static SECItem * | 3340 static SECItem * |
3341 fetchOcspHttpClientV1(PRArenaPool *arena, | 3341 fetchOcspHttpClientV1(PLArenaPool *arena, |
3342 const SEC_HttpClientFcnV1 *hcv1, | 3342 const SEC_HttpClientFcnV1 *hcv1, |
3343 const char *location, | 3343 const char *location, |
3344 SECItem *encodedRequest) | 3344 SECItem *encodedRequest) |
3345 { | 3345 { |
3346 char *hostname = NULL; | 3346 char *hostname = NULL; |
3347 char *path = NULL; | 3347 char *path = NULL; |
3348 PRUint16 port; | 3348 PRUint16 port; |
3349 SECItem *encodedResponse = NULL; | 3349 SECItem *encodedResponse = NULL; |
3350 SEC_HTTP_SERVER_SESSION pServerSession = NULL; | 3350 SEC_HTTP_SERVER_SESSION pServerSession = NULL; |
3351 SEC_HTTP_REQUEST_SESSION pRequestSession = NULL; | 3351 SEC_HTTP_REQUEST_SESSION pRequestSession = NULL; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3440 PORT_Free(hostname); | 3440 PORT_Free(hostname); |
3441 | 3441 |
3442 return encodedResponse; | 3442 return encodedResponse; |
3443 } | 3443 } |
3444 | 3444 |
3445 /* | 3445 /* |
3446 * FUNCTION: CERT_GetEncodedOCSPResponse | 3446 * FUNCTION: CERT_GetEncodedOCSPResponse |
3447 * Creates and sends a request to an OCSP responder, then reads and | 3447 * Creates and sends a request to an OCSP responder, then reads and |
3448 * returns the (encoded) response. | 3448 * returns the (encoded) response. |
3449 * INPUTS: | 3449 * INPUTS: |
3450 * PRArenaPool *arena | 3450 * PLArenaPool *arena |
3451 * Pointer to arena from which return value will be allocated. | 3451 * Pointer to arena from which return value will be allocated. |
3452 * If NULL, result will be allocated from the heap (and thus should | 3452 * If NULL, result will be allocated from the heap (and thus should |
3453 * be freed via SECITEM_FreeItem). | 3453 * be freed via SECITEM_FreeItem). |
3454 * CERTCertList *certList | 3454 * CERTCertList *certList |
3455 * A list of certs for which status will be requested. | 3455 * A list of certs for which status will be requested. |
3456 * Note that all of these certificates should have the same issuer, | 3456 * Note that all of these certificates should have the same issuer, |
3457 * or it's expected the response will be signed by a trusted responder. | 3457 * or it's expected the response will be signed by a trusted responder. |
3458 * If the certs need to be broken up into multiple requests, that | 3458 * If the certs need to be broken up into multiple requests, that |
3459 * must be handled by the caller (and thus by having multiple calls | 3459 * must be handled by the caller (and thus by having multiple calls |
3460 * to this routine), who knows about where the request(s) are being | 3460 * to this routine), who knows about where the request(s) are being |
3461 * sent and whether there are any trusted responders in place. | 3461 * sent and whether there are any trusted responders in place. |
3462 * const char *location | 3462 * const char *location |
3463 * The location of the OCSP responder (a URL). | 3463 * The location of the OCSP responder (a URL). |
3464 * int64 time | 3464 * PRTime time |
3465 * Indicates the time for which the certificate status is to be | 3465 * Indicates the time for which the certificate status is to be |
3466 * determined -- this may be used in the search for the cert's issuer | 3466 * determined -- this may be used in the search for the cert's issuer |
3467 * but has no other bearing on the operation. | 3467 * but has no other bearing on the operation. |
3468 * PRBool addServiceLocator | 3468 * PRBool addServiceLocator |
3469 * If true, the Service Locator extension should be added to the | 3469 * If true, the Service Locator extension should be added to the |
3470 * single request(s) for each cert. | 3470 * single request(s) for each cert. |
3471 * CERTCertificate *signerCert | 3471 * CERTCertificate *signerCert |
3472 * If non-NULL, means sign the request using this cert. Otherwise, | 3472 * If non-NULL, means sign the request using this cert. Otherwise, |
3473 * do not sign. | 3473 * do not sign. |
3474 * void *pwArg | 3474 * void *pwArg |
3475 * Pointer to argument for password prompting, if needed. (Definitely | 3475 * Pointer to argument for password prompting, if needed. (Definitely |
3476 * not needed if not signing.) | 3476 * not needed if not signing.) |
3477 * OUTPUTS: | 3477 * OUTPUTS: |
3478 * CERTOCSPRequest **pRequest | 3478 * CERTOCSPRequest **pRequest |
3479 * Pointer in which to store the OCSP request created for the given | 3479 * Pointer in which to store the OCSP request created for the given |
3480 * list of certificates. It is only filled in if the entire operation | 3480 * list of certificates. It is only filled in if the entire operation |
3481 * is successful and the pointer is not null -- and in that case the | 3481 * is successful and the pointer is not null -- and in that case the |
3482 * caller is then reponsible for destroying it. | 3482 * caller is then reponsible for destroying it. |
3483 * RETURN: | 3483 * RETURN: |
3484 * Returns a pointer to the SECItem holding the response. | 3484 * Returns a pointer to the SECItem holding the response. |
3485 * On error, returns null with error set describing the reason: | 3485 * On error, returns null with error set describing the reason: |
3486 * SEC_ERROR_UNKNOWN_ISSUER | 3486 * SEC_ERROR_UNKNOWN_ISSUER |
3487 * SEC_ERROR_CERT_BAD_ACCESS_LOCATION | 3487 * SEC_ERROR_CERT_BAD_ACCESS_LOCATION |
3488 * SEC_ERROR_OCSP_BAD_HTTP_RESPONSE | 3488 * SEC_ERROR_OCSP_BAD_HTTP_RESPONSE |
3489 * Other errors are low-level problems (no memory, bad database, etc.). | 3489 * Other errors are low-level problems (no memory, bad database, etc.). |
3490 */ | 3490 */ |
3491 SECItem * | 3491 SECItem * |
3492 CERT_GetEncodedOCSPResponse(PRArenaPool *arena, CERTCertList *certList, | 3492 CERT_GetEncodedOCSPResponse(PLArenaPool *arena, CERTCertList *certList, |
3493 » » » const char *location, int64 time, | 3493 » » » const char *location, PRTime time, |
3494 PRBool addServiceLocator, | 3494 PRBool addServiceLocator, |
3495 CERTCertificate *signerCert, void *pwArg, | 3495 CERTCertificate *signerCert, void *pwArg, |
3496 CERTOCSPRequest **pRequest) | 3496 CERTOCSPRequest **pRequest) |
3497 { | 3497 { |
3498 CERTOCSPRequest *request; | 3498 CERTOCSPRequest *request; |
3499 request = CERT_CreateOCSPRequest(certList, time, addServiceLocator, | 3499 request = CERT_CreateOCSPRequest(certList, time, addServiceLocator, |
3500 signerCert); | 3500 signerCert); |
3501 if (!request) | 3501 if (!request) |
3502 return NULL; | 3502 return NULL; |
3503 return ocsp_GetEncodedOCSPResponseFromRequest(arena, request, location, | 3503 return ocsp_GetEncodedOCSPResponseFromRequest(arena, request, location, |
3504 time, addServiceLocator, | 3504 time, addServiceLocator, |
3505 pwArg, pRequest); | 3505 pwArg, pRequest); |
3506 } | 3506 } |
3507 | 3507 |
3508 static SECItem * | 3508 static SECItem * |
3509 ocsp_GetEncodedOCSPResponseFromRequest(PRArenaPool *arena, | 3509 ocsp_GetEncodedOCSPResponseFromRequest(PLArenaPool *arena, |
3510 CERTOCSPRequest *request, | 3510 CERTOCSPRequest *request, |
3511 const char *location, int64 time, | 3511 const char *location, PRTime time, |
3512 PRBool addServiceLocator, | 3512 PRBool addServiceLocator, |
3513 void *pwArg, | 3513 void *pwArg, |
3514 CERTOCSPRequest **pRequest) | 3514 CERTOCSPRequest **pRequest) |
3515 { | 3515 { |
3516 SECItem *encodedRequest = NULL; | 3516 SECItem *encodedRequest = NULL; |
3517 SECItem *encodedResponse = NULL; | 3517 SECItem *encodedResponse = NULL; |
3518 PRFileDesc *sock = NULL; | 3518 PRFileDesc *sock = NULL; |
3519 SECStatus rv; | 3519 SECStatus rv; |
3520 const SEC_HttpClientFcn *registeredHttpClient = NULL; | 3520 const SEC_HttpClientFcn *registeredHttpClient = NULL; |
3521 | 3521 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3559 CERT_DestroyOCSPRequest(request); | 3559 CERT_DestroyOCSPRequest(request); |
3560 if (encodedRequest != NULL) | 3560 if (encodedRequest != NULL) |
3561 SECITEM_FreeItem(encodedRequest, PR_TRUE); | 3561 SECITEM_FreeItem(encodedRequest, PR_TRUE); |
3562 if (sock != NULL) | 3562 if (sock != NULL) |
3563 PR_Close(sock); | 3563 PR_Close(sock); |
3564 | 3564 |
3565 return encodedResponse; | 3565 return encodedResponse; |
3566 } | 3566 } |
3567 | 3567 |
3568 static SECItem * | 3568 static SECItem * |
3569 ocsp_GetEncodedOCSPResponseForSingleCert(PRArenaPool *arena, | 3569 ocsp_GetEncodedOCSPResponseForSingleCert(PLArenaPool *arena, |
3570 CERTOCSPCertID *certID, | 3570 CERTOCSPCertID *certID, |
3571 CERTCertificate *singleCert, | 3571 CERTCertificate *singleCert, |
3572 const char *location, int64 time, | 3572 const char *location, PRTime time, |
3573 PRBool addServiceLocator, | 3573 PRBool addServiceLocator, |
3574 void *pwArg, | 3574 void *pwArg, |
3575 CERTOCSPRequest **pRequest) | 3575 CERTOCSPRequest **pRequest) |
3576 { | 3576 { |
3577 CERTOCSPRequest *request; | 3577 CERTOCSPRequest *request; |
3578 request = cert_CreateSingleCertOCSPRequest(certID, singleCert, time, | 3578 request = cert_CreateSingleCertOCSPRequest(certID, singleCert, time, |
3579 addServiceLocator, NULL); | 3579 addServiceLocator, NULL); |
3580 if (!request) | 3580 if (!request) |
3581 return NULL; | 3581 return NULL; |
3582 return ocsp_GetEncodedOCSPResponseFromRequest(arena, request, location, | 3582 return ocsp_GetEncodedOCSPResponseFromRequest(arena, request, location, |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3871 */ | 3871 */ |
3872 SECStatus | 3872 SECStatus |
3873 CERT_VerifyOCSPResponseSignature(CERTOCSPResponse *response, | 3873 CERT_VerifyOCSPResponseSignature(CERTOCSPResponse *response, |
3874 CERTCertDBHandle *handle, void *pwArg, | 3874 CERTCertDBHandle *handle, void *pwArg, |
3875 CERTCertificate **pSignerCert, | 3875 CERTCertificate **pSignerCert, |
3876 CERTCertificate *issuer) | 3876 CERTCertificate *issuer) |
3877 { | 3877 { |
3878 SECItem *tbsResponseDataDER; | 3878 SECItem *tbsResponseDataDER; |
3879 CERTCertificate *signerCert = NULL; | 3879 CERTCertificate *signerCert = NULL; |
3880 SECStatus rv = SECFailure; | 3880 SECStatus rv = SECFailure; |
3881 int64 producedAt; | 3881 PRTime producedAt; |
3882 | 3882 |
3883 /* ocsp_DecodeBasicOCSPResponse will fail if asn1 decoder is unable | 3883 /* ocsp_DecodeBasicOCSPResponse will fail if asn1 decoder is unable |
3884 * to properly decode tbsData (see the function and | 3884 * to properly decode tbsData (see the function and |
3885 * ocsp_BasicOCSPResponseTemplate). Thus, tbsData can not be | 3885 * ocsp_BasicOCSPResponseTemplate). Thus, tbsData can not be |
3886 * equal to null */ | 3886 * equal to null */ |
3887 ocspResponseData *tbsData = ocsp_GetResponseData(response, | 3887 ocspResponseData *tbsData = ocsp_GetResponseData(response, |
3888 &tbsResponseDataDER); | 3888 &tbsResponseDataDER); |
3889 ocspSignature *signature = ocsp_GetResponseSignature(response); | 3889 ocspSignature *signature = ocsp_GetResponseSignature(response); |
3890 | 3890 |
3891 if (!signature) { | 3891 if (!signature) { |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4199 * of OCSP signing authority for the certificate in question. | 4199 * of OCSP signing authority for the certificate in question. |
4200 * 2. The CA who issued the certificate in question. | 4200 * 2. The CA who issued the certificate in question. |
4201 * 3. A "CA designated responder", aka an "authorized responder" -- it | 4201 * 3. A "CA designated responder", aka an "authorized responder" -- it |
4202 * must be represented by a special cert issued by the CA who issued | 4202 * must be represented by a special cert issued by the CA who issued |
4203 * the certificate in question. | 4203 * the certificate in question. |
4204 */ | 4204 */ |
4205 static PRBool | 4205 static PRBool |
4206 ocsp_AuthorizedResponderForCertID(CERTCertDBHandle *handle, | 4206 ocsp_AuthorizedResponderForCertID(CERTCertDBHandle *handle, |
4207 CERTCertificate *signerCert, | 4207 CERTCertificate *signerCert, |
4208 CERTOCSPCertID *certID, | 4208 CERTOCSPCertID *certID, |
4209 » » » » int64 thisUpdate) | 4209 » » » » PRTime thisUpdate) |
4210 { | 4210 { |
4211 CERTCertificate *issuerCert = NULL, *defRespCert; | 4211 CERTCertificate *issuerCert = NULL, *defRespCert; |
4212 SECItem *keyHash = NULL; | 4212 SECItem *keyHash = NULL; |
4213 SECItem *nameHash = NULL; | 4213 SECItem *nameHash = NULL; |
4214 SECOidTag hashAlg; | 4214 SECOidTag hashAlg; |
4215 PRBool keyHashEQ = PR_FALSE, nameHashEQ = PR_FALSE; | 4215 PRBool keyHashEQ = PR_FALSE, nameHashEQ = PR_FALSE; |
4216 | 4216 |
4217 /* | 4217 /* |
4218 * Check first for a trusted responder, which overrides everything else. | 4218 * Check first for a trusted responder, which overrides everything else. |
4219 */ | 4219 */ |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4321 * | 4321 * |
4322 * XXX This *should* be based on some configuration parameter, so that | 4322 * XXX This *should* be based on some configuration parameter, so that |
4323 * different usages could specify exactly what constitutes "sufficiently | 4323 * different usages could specify exactly what constitutes "sufficiently |
4324 * recent". But that is not going to happen right away. For now, we | 4324 * recent". But that is not going to happen right away. For now, we |
4325 * want something from within the last 24 hours. This macro defines that | 4325 * want something from within the last 24 hours. This macro defines that |
4326 * number in seconds. | 4326 * number in seconds. |
4327 */ | 4327 */ |
4328 #define OCSP_ALLOWABLE_LAPSE_SECONDS (24L * 60L * 60L) | 4328 #define OCSP_ALLOWABLE_LAPSE_SECONDS (24L * 60L * 60L) |
4329 | 4329 |
4330 static PRBool | 4330 static PRBool |
4331 ocsp_TimeIsRecent(int64 checkTime) | 4331 ocsp_TimeIsRecent(PRTime checkTime) |
4332 { | 4332 { |
4333 int64 now = PR_Now(); | 4333 PRTime now = PR_Now(); |
4334 int64 lapse, tmp; | 4334 PRTime lapse, tmp; |
4335 | 4335 |
4336 LL_I2L(lapse, OCSP_ALLOWABLE_LAPSE_SECONDS); | 4336 LL_I2L(lapse, OCSP_ALLOWABLE_LAPSE_SECONDS); |
4337 LL_I2L(tmp, PR_USEC_PER_SEC); | 4337 LL_I2L(tmp, PR_USEC_PER_SEC); |
4338 LL_MUL(lapse, lapse, tmp); /* allowable lapse in microseconds */ | 4338 LL_MUL(lapse, lapse, tmp); /* allowable lapse in microseconds */ |
4339 | 4339 |
4340 LL_ADD(checkTime, checkTime, lapse); | 4340 LL_ADD(checkTime, checkTime, lapse); |
4341 if (LL_CMP(now, >, checkTime)) | 4341 if (LL_CMP(now, >, checkTime)) |
4342 return PR_FALSE; | 4342 return PR_FALSE; |
4343 | 4343 |
4344 return PR_TRUE; | 4344 return PR_TRUE; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4396 * If any of those checks fail, SECFailure is returned and an error is set: | 4396 * If any of those checks fail, SECFailure is returned and an error is set: |
4397 * SEC_ERROR_OCSP_FUTURE_RESPONSE | 4397 * SEC_ERROR_OCSP_FUTURE_RESPONSE |
4398 * SEC_ERROR_OCSP_OLD_RESPONSE | 4398 * SEC_ERROR_OCSP_OLD_RESPONSE |
4399 * SEC_ERROR_OCSP_UNAUTHORIZED_RESPONSE | 4399 * SEC_ERROR_OCSP_UNAUTHORIZED_RESPONSE |
4400 * Other errors are low-level problems (no memory, bad database, etc.). | 4400 * Other errors are low-level problems (no memory, bad database, etc.). |
4401 */ | 4401 */ |
4402 static SECStatus | 4402 static SECStatus |
4403 ocsp_VerifySingleResponse(CERTOCSPSingleResponse *single, | 4403 ocsp_VerifySingleResponse(CERTOCSPSingleResponse *single, |
4404 CERTCertDBHandle *handle, | 4404 CERTCertDBHandle *handle, |
4405 CERTCertificate *signerCert, | 4405 CERTCertificate *signerCert, |
4406 » » » int64 producedAt) | 4406 » » » PRTime producedAt) |
4407 { | 4407 { |
4408 CERTOCSPCertID *certID = single->certID; | 4408 CERTOCSPCertID *certID = single->certID; |
4409 int64 now, thisUpdate, nextUpdate, tmstamp, tmp; | 4409 PRTime now, thisUpdate, nextUpdate, tmstamp, tmp; |
4410 SECStatus rv; | 4410 SECStatus rv; |
4411 | 4411 |
4412 OCSP_TRACE(("OCSP ocsp_VerifySingleResponse, nextUpdate: %d\n", | 4412 OCSP_TRACE(("OCSP ocsp_VerifySingleResponse, nextUpdate: %d\n", |
4413 ((single->nextUpdate) != 0))); | 4413 ((single->nextUpdate) != 0))); |
4414 /* | 4414 /* |
4415 * If all the responder said was that the given cert was unknown to it, | 4415 * If all the responder said was that the given cert was unknown to it, |
4416 * that is a valid response. Not very interesting to us, of course, | 4416 * that is a valid response. Not very interesting to us, of course, |
4417 * but all this function is concerned with is validity of the response, | 4417 * but all this function is concerned with is validity of the response, |
4418 * not the status of the cert. | 4418 * not the status of the cert. |
4419 */ | 4419 */ |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4485 * This result should be freed (via PORT_Free) when no longer in use. | 4485 * This result should be freed (via PORT_Free) when no longer in use. |
4486 */ | 4486 */ |
4487 char * | 4487 char * |
4488 CERT_GetOCSPAuthorityInfoAccessLocation(CERTCertificate *cert) | 4488 CERT_GetOCSPAuthorityInfoAccessLocation(CERTCertificate *cert) |
4489 { | 4489 { |
4490 CERTGeneralName *locname = NULL; | 4490 CERTGeneralName *locname = NULL; |
4491 SECItem *location = NULL; | 4491 SECItem *location = NULL; |
4492 SECItem *encodedAuthInfoAccess = NULL; | 4492 SECItem *encodedAuthInfoAccess = NULL; |
4493 CERTAuthInfoAccess **authInfoAccess = NULL; | 4493 CERTAuthInfoAccess **authInfoAccess = NULL; |
4494 char *locURI = NULL; | 4494 char *locURI = NULL; |
4495 PRArenaPool *arena = NULL; | 4495 PLArenaPool *arena = NULL; |
4496 SECStatus rv; | 4496 SECStatus rv; |
4497 int i; | 4497 int i; |
4498 | 4498 |
4499 /* | 4499 /* |
4500 * Allocate this one from the heap because it will get filled in | 4500 * Allocate this one from the heap because it will get filled in |
4501 * by CERT_FindCertExtension which will also allocate from the heap, | 4501 * by CERT_FindCertExtension which will also allocate from the heap, |
4502 * and we can free the entire thing on our way out. | 4502 * and we can free the entire thing on our way out. |
4503 */ | 4503 */ |
4504 encodedAuthInfoAccess = SECITEM_AllocItem(NULL, NULL, 0); | 4504 encodedAuthInfoAccess = SECITEM_AllocItem(NULL, NULL, 0); |
4505 if (encodedAuthInfoAccess == NULL) | 4505 if (encodedAuthInfoAccess == NULL) |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4639 } | 4639 } |
4640 } | 4640 } |
4641 return ocspUrl; | 4641 return ocspUrl; |
4642 } | 4642 } |
4643 | 4643 |
4644 /* | 4644 /* |
4645 * Return SECSuccess if the cert was revoked *after* "time", | 4645 * Return SECSuccess if the cert was revoked *after* "time", |
4646 * SECFailure otherwise. | 4646 * SECFailure otherwise. |
4647 */ | 4647 */ |
4648 static SECStatus | 4648 static SECStatus |
4649 ocsp_CertRevokedAfter(ocspRevokedInfo *revokedInfo, int64 time) | 4649 ocsp_CertRevokedAfter(ocspRevokedInfo *revokedInfo, PRTime time) |
4650 { | 4650 { |
4651 int64 revokedTime; | 4651 PRTime revokedTime; |
4652 SECStatus rv; | 4652 SECStatus rv; |
4653 | 4653 |
4654 rv = DER_GeneralizedTimeToTime(&revokedTime, &revokedInfo->revocationTime); | 4654 rv = DER_GeneralizedTimeToTime(&revokedTime, &revokedInfo->revocationTime); |
4655 if (rv != SECSuccess) | 4655 if (rv != SECSuccess) |
4656 return rv; | 4656 return rv; |
4657 | 4657 |
4658 /* | 4658 /* |
4659 * Set the error even if we will return success; someone might care. | 4659 * Set the error even if we will return success; someone might care. |
4660 */ | 4660 */ |
4661 PORT_SetError(SEC_ERROR_REVOKED_CERTIFICATE); | 4661 PORT_SetError(SEC_ERROR_REVOKED_CERTIFICATE); |
4662 | 4662 |
4663 if (LL_CMP(revokedTime, >, time)) | 4663 if (LL_CMP(revokedTime, >, time)) |
4664 return SECSuccess; | 4664 return SECSuccess; |
4665 | 4665 |
4666 return SECFailure; | 4666 return SECFailure; |
4667 } | 4667 } |
4668 | 4668 |
4669 /* | 4669 /* |
4670 * See if the cert represented in the single response had a good status | 4670 * See if the cert represented in the single response had a good status |
4671 * at the specified time. | 4671 * at the specified time. |
4672 */ | 4672 */ |
4673 static SECStatus | 4673 static SECStatus |
4674 ocsp_CertHasGoodStatus(ocspCertStatus *status, int64 time) | 4674 ocsp_CertHasGoodStatus(ocspCertStatus *status, PRTime time) |
4675 { | 4675 { |
4676 SECStatus rv; | 4676 SECStatus rv; |
4677 switch (status->certStatusType) { | 4677 switch (status->certStatusType) { |
4678 case ocspCertStatus_good: | 4678 case ocspCertStatus_good: |
4679 rv = SECSuccess; | 4679 rv = SECSuccess; |
4680 break; | 4680 break; |
4681 case ocspCertStatus_revoked: | 4681 case ocspCertStatus_revoked: |
4682 rv = ocsp_CertRevokedAfter(status->certStatusInfo.revokedInfo, time); | 4682 rv = ocsp_CertRevokedAfter(status->certStatusInfo.revokedInfo, time); |
4683 break; | 4683 break; |
4684 case ocspCertStatus_unknown: | 4684 case ocspCertStatus_unknown: |
4685 PORT_SetError(SEC_ERROR_OCSP_UNKNOWN_CERT); | 4685 PORT_SetError(SEC_ERROR_OCSP_UNKNOWN_CERT); |
4686 rv = SECFailure; | 4686 rv = SECFailure; |
4687 break; | 4687 break; |
4688 case ocspCertStatus_other: | 4688 case ocspCertStatus_other: |
4689 default: | 4689 default: |
4690 PORT_Assert(0); | 4690 PORT_Assert(0); |
4691 PORT_SetError(SEC_ERROR_OCSP_MALFORMED_RESPONSE); | 4691 PORT_SetError(SEC_ERROR_OCSP_MALFORMED_RESPONSE); |
4692 rv = SECFailure; | 4692 rv = SECFailure; |
4693 break; | 4693 break; |
4694 } | 4694 } |
4695 return rv; | 4695 return rv; |
4696 } | 4696 } |
4697 | 4697 |
4698 static SECStatus | 4698 static SECStatus |
4699 ocsp_SingleResponseCertHasGoodStatus(CERTOCSPSingleResponse *single, | 4699 ocsp_SingleResponseCertHasGoodStatus(CERTOCSPSingleResponse *single, |
4700 int64 time) | 4700 PRTime time) |
4701 { | 4701 { |
4702 return ocsp_CertHasGoodStatus(single->certStatus, time); | 4702 return ocsp_CertHasGoodStatus(single->certStatus, time); |
4703 } | 4703 } |
4704 | 4704 |
4705 /* Return value SECFailure means: not found or not fresh. | 4705 /* Return value SECFailure means: not found or not fresh. |
4706 * On SECSuccess, the out parameters contain the OCSP status. | 4706 * On SECSuccess, the out parameters contain the OCSP status. |
4707 * rvOcsp contains the overall result of the OCSP operation. | 4707 * rvOcsp contains the overall result of the OCSP operation. |
4708 * Depending on input parameter ignoreGlobalOcspFailureSetting, | 4708 * Depending on input parameter ignoreGlobalOcspFailureSetting, |
4709 * a soft failure might be converted into *rvOcsp=SECSuccess. | 4709 * a soft failure might be converted into *rvOcsp=SECSuccess. |
4710 * If the cached attempt to obtain OCSP information had resulted | 4710 * If the cached attempt to obtain OCSP information had resulted |
4711 * in a failure, missingResponseError shows the error code of | 4711 * in a failure, missingResponseError shows the error code of |
4712 * that failure. | 4712 * that failure. |
4713 */ | 4713 */ |
4714 SECStatus | 4714 SECStatus |
4715 ocsp_GetCachedOCSPResponseStatusIfFresh(CERTOCSPCertID *certID, | 4715 ocsp_GetCachedOCSPResponseStatusIfFresh(CERTOCSPCertID *certID, |
4716 int64 time, | 4716 PRTime time, |
4717 PRBool ignoreGlobalOcspFailureSetting, | 4717 PRBool ignoreGlobalOcspFailureSetting, |
4718 SECStatus *rvOcsp, | 4718 SECStatus *rvOcsp, |
4719 SECErrorCodes *missingResponseError) | 4719 SECErrorCodes *missingResponseError) |
4720 { | 4720 { |
4721 OCSPCacheItem *cacheItem = NULL; | 4721 OCSPCacheItem *cacheItem = NULL; |
4722 SECStatus rv = SECFailure; | 4722 SECStatus rv = SECFailure; |
4723 | 4723 |
4724 if (!certID || !missingResponseError || !rvOcsp) { | 4724 if (!certID || !missingResponseError || !rvOcsp) { |
4725 PORT_SetError(SEC_ERROR_INVALID_ARGS); | 4725 PORT_SetError(SEC_ERROR_INVALID_ARGS); |
4726 return SECFailure; | 4726 return SECFailure; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4778 * (If no AIA extension for OCSP and no default responder in place, the | 4778 * (If no AIA extension for OCSP and no default responder in place, the |
4779 * cert is considered to have a good status and SECSuccess is returned.) | 4779 * cert is considered to have a good status and SECSuccess is returned.) |
4780 * INPUTS: | 4780 * INPUTS: |
4781 * CERTCertDBHandle *handle | 4781 * CERTCertDBHandle *handle |
4782 * certificate DB of the cert that is being checked | 4782 * certificate DB of the cert that is being checked |
4783 * CERTCertificate *cert | 4783 * CERTCertificate *cert |
4784 * the certificate being checked | 4784 * the certificate being checked |
4785 * XXX in the long term also need a boolean parameter that specifies | 4785 * XXX in the long term also need a boolean parameter that specifies |
4786 * whether to check the cert chain, as well; for now we check only | 4786 * whether to check the cert chain, as well; for now we check only |
4787 * the leaf (the specified certificate) | 4787 * the leaf (the specified certificate) |
4788 * int64 time | 4788 * PRTime time |
4789 * time for which status is to be determined | 4789 * time for which status is to be determined |
4790 * void *pwArg | 4790 * void *pwArg |
4791 * argument for password prompting, if needed | 4791 * argument for password prompting, if needed |
4792 * RETURN: | 4792 * RETURN: |
4793 * Returns SECSuccess if an approved OCSP responder "knows" the cert | 4793 * Returns SECSuccess if an approved OCSP responder "knows" the cert |
4794 * *and* returns a non-revoked status for it; SECFailure otherwise, | 4794 * *and* returns a non-revoked status for it; SECFailure otherwise, |
4795 * with an error set describing the reason: | 4795 * with an error set describing the reason: |
4796 * | 4796 * |
4797 * SEC_ERROR_OCSP_BAD_HTTP_RESPONSE | 4797 * SEC_ERROR_OCSP_BAD_HTTP_RESPONSE |
4798 * SEC_ERROR_OCSP_FUTURE_RESPONSE | 4798 * SEC_ERROR_OCSP_FUTURE_RESPONSE |
(...skipping 16 matching lines...) Expand all Loading... |
4815 * SEC_ERROR_UNKNOWN_ISSUER | 4815 * SEC_ERROR_UNKNOWN_ISSUER |
4816 * SEC_ERROR_UNKNOWN_SIGNER | 4816 * SEC_ERROR_UNKNOWN_SIGNER |
4817 * | 4817 * |
4818 * Other errors are any of the many possible failures in cert verification | 4818 * Other errors are any of the many possible failures in cert verification |
4819 * (e.g. SEC_ERROR_REVOKED_CERTIFICATE, SEC_ERROR_UNTRUSTED_ISSUER) when | 4819 * (e.g. SEC_ERROR_REVOKED_CERTIFICATE, SEC_ERROR_UNTRUSTED_ISSUER) when |
4820 * verifying the signer's cert, or low-level problems (error allocating | 4820 * verifying the signer's cert, or low-level problems (error allocating |
4821 * memory, error performing ASN.1 decoding, etc.). | 4821 * memory, error performing ASN.1 decoding, etc.). |
4822 */ | 4822 */ |
4823 SECStatus | 4823 SECStatus |
4824 CERT_CheckOCSPStatus(CERTCertDBHandle *handle, CERTCertificate *cert, | 4824 CERT_CheckOCSPStatus(CERTCertDBHandle *handle, CERTCertificate *cert, |
4825 » » int64 time, void *pwArg) | 4825 » » PRTime time, void *pwArg) |
4826 { | 4826 { |
4827 CERTOCSPCertID *certID; | 4827 CERTOCSPCertID *certID; |
4828 PRBool certIDWasConsumed = PR_FALSE; | 4828 PRBool certIDWasConsumed = PR_FALSE; |
4829 SECStatus rv = SECFailure; | 4829 SECStatus rv = SECFailure; |
4830 SECStatus rvOcsp; | 4830 SECStatus rvOcsp; |
4831 SECErrorCodes dummy_error_code; /* we ignore this */ | 4831 SECErrorCodes dummy_error_code; /* we ignore this */ |
4832 | 4832 |
4833 OCSP_TRACE_CERT(cert); | 4833 OCSP_TRACE_CERT(cert); |
4834 OCSP_TRACE_TIME("## requested validity time:", time); | 4834 OCSP_TRACE_TIME("## requested validity time:", time); |
4835 | 4835 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4869 * cache. | 4869 * cache. |
4870 * | 4870 * |
4871 * This function is intended for use when OCSP responses are provided via a | 4871 * This function is intended for use when OCSP responses are provided via a |
4872 * side-channel, i.e. TLS OCSP stapling (a.k.a. the status_request extension). | 4872 * side-channel, i.e. TLS OCSP stapling (a.k.a. the status_request extension). |
4873 * | 4873 * |
4874 * INPUTS: | 4874 * INPUTS: |
4875 * CERTCertDBHandle *handle | 4875 * CERTCertDBHandle *handle |
4876 * certificate DB of the cert that is being checked | 4876 * certificate DB of the cert that is being checked |
4877 * CERTCertificate *cert | 4877 * CERTCertificate *cert |
4878 * the certificate being checked | 4878 * the certificate being checked |
4879 * int64 time | 4879 * PRTime time |
4880 * time for which status is to be determined | 4880 * time for which status is to be determined |
4881 * SECItem *encodedResponse | 4881 * SECItem *encodedResponse |
4882 * the DER encoded bytes of the OCSP response | 4882 * the DER encoded bytes of the OCSP response |
4883 * void *pwArg | 4883 * void *pwArg |
4884 * argument for password prompting, if needed | 4884 * argument for password prompting, if needed |
4885 * RETURN: | 4885 * RETURN: |
4886 * SECSuccess if the cert was found in the cache, or if the OCSP response was | 4886 * SECSuccess if the cert was found in the cache, or if the OCSP response was |
4887 * found to be valid and inserted into the cache. SECFailure otherwise. | 4887 * found to be valid and inserted into the cache. SECFailure otherwise. |
4888 */ | 4888 */ |
4889 SECStatus | 4889 SECStatus |
4890 CERT_CacheOCSPResponseFromSideChannel(CERTCertDBHandle *handle, | 4890 CERT_CacheOCSPResponseFromSideChannel(CERTCertDBHandle *handle, |
4891 CERTCertificate *cert, | 4891 CERTCertificate *cert, |
4892 » » » » int64 time, | 4892 » » » » PRTime time, |
4893 const SECItem *encodedResponse, | 4893 const SECItem *encodedResponse, |
4894 void *pwArg) | 4894 void *pwArg) |
4895 { | 4895 { |
4896 CERTOCSPCertID *certID = NULL; | 4896 CERTOCSPCertID *certID = NULL; |
4897 PRBool certIDWasConsumed = PR_FALSE; | 4897 PRBool certIDWasConsumed = PR_FALSE; |
4898 SECStatus rv = SECFailure; | 4898 SECStatus rv = SECFailure; |
4899 SECStatus rvOcsp; | 4899 SECStatus rvOcsp; |
4900 SECErrorCodes dummy_error_code; /* we ignore this */ | 4900 SECErrorCodes dummy_error_code; /* we ignore this */ |
4901 | 4901 |
4902 /* The OCSP cache can be in three states regarding this certificate: | 4902 /* The OCSP cache can be in three states regarding this certificate: |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4969 } | 4969 } |
4970 | 4970 |
4971 /* | 4971 /* |
4972 * Status in *certIDWasConsumed will always be correct, regardless of | 4972 * Status in *certIDWasConsumed will always be correct, regardless of |
4973 * return value. | 4973 * return value. |
4974 */ | 4974 */ |
4975 static SECStatus | 4975 static SECStatus |
4976 ocsp_GetOCSPStatusFromNetwork(CERTCertDBHandle *handle, | 4976 ocsp_GetOCSPStatusFromNetwork(CERTCertDBHandle *handle, |
4977 CERTOCSPCertID *certID, | 4977 CERTOCSPCertID *certID, |
4978 CERTCertificate *cert, | 4978 CERTCertificate *cert, |
4979 int64 time, | 4979 PRTime time, |
4980 void *pwArg, | 4980 void *pwArg, |
4981 PRBool *certIDWasConsumed, | 4981 PRBool *certIDWasConsumed, |
4982 SECStatus *rv_ocsp) | 4982 SECStatus *rv_ocsp) |
4983 { | 4983 { |
4984 char *location = NULL; | 4984 char *location = NULL; |
4985 PRBool locationIsDefault; | 4985 PRBool locationIsDefault; |
4986 SECItem *encodedResponse = NULL; | 4986 SECItem *encodedResponse = NULL; |
4987 CERTOCSPRequest *request = NULL; | 4987 CERTOCSPRequest *request = NULL; |
4988 SECStatus rv = SECFailure; | 4988 SECStatus rv = SECFailure; |
4989 | 4989 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5075 * A 'good' response is a valid response that attests that the certificate | 5075 * A 'good' response is a valid response that attests that the certificate |
5076 * is not currently revoked (see RFC 2560 Section 2.2). | 5076 * is not currently revoked (see RFC 2560 Section 2.2). |
5077 * | 5077 * |
5078 * INPUTS: | 5078 * INPUTS: |
5079 * CERTCertDBHandle *handle | 5079 * CERTCertDBHandle *handle |
5080 * certificate DB of the cert that is being checked | 5080 * certificate DB of the cert that is being checked |
5081 * CERTOCSPCertID *certID | 5081 * CERTOCSPCertID *certID |
5082 * the cert ID corresponding to |cert| | 5082 * the cert ID corresponding to |cert| |
5083 * CERTCertificate *cert | 5083 * CERTCertificate *cert |
5084 * the certificate being checked | 5084 * the certificate being checked |
5085 * int64 time | 5085 * PRTime time |
5086 * time for which status is to be determined | 5086 * time for which status is to be determined |
5087 * void *pwArg | 5087 * void *pwArg |
5088 * the opaque argument to the password prompting function. | 5088 * the opaque argument to the password prompting function. |
5089 * SECItem *encodedResponse | 5089 * SECItem *encodedResponse |
5090 * the DER encoded bytes of the OCSP response | 5090 * the DER encoded bytes of the OCSP response |
5091 * PRBool cacheInvalid | 5091 * PRBool cacheInvalid |
5092 * If true then invalid responses will cause a negative cache entry to be | 5092 * If true then invalid responses will cause a negative cache entry to be |
5093 * created. (Invalid means bad syntax, bad signature etc) | 5093 * created. (Invalid means bad syntax, bad signature etc) |
5094 * PRBool *certIDWasConsumed | 5094 * PRBool *certIDWasConsumed |
5095 * (output) on return, this is true iff |certID| was consumed by this | 5095 * (output) on return, this is true iff |certID| was consumed by this |
5096 * function. | 5096 * function. |
5097 * SECStatus *rv_ocsp | 5097 * SECStatus *rv_ocsp |
5098 * (output) on return, this is SECSuccess iff the response is good (see | 5098 * (output) on return, this is SECSuccess iff the response is good (see |
5099 * definition of 'good' above). | 5099 * definition of 'good' above). |
5100 * RETURN: | 5100 * RETURN: |
5101 * SECSuccess iff the response is valid. | 5101 * SECSuccess iff the response is valid. |
5102 */ | 5102 */ |
5103 static SECStatus | 5103 static SECStatus |
5104 ocsp_CacheEncodedOCSPResponse(CERTCertDBHandle *handle, | 5104 ocsp_CacheEncodedOCSPResponse(CERTCertDBHandle *handle, |
5105 CERTOCSPCertID *certID, | 5105 CERTOCSPCertID *certID, |
5106 CERTCertificate *cert, | 5106 CERTCertificate *cert, |
5107 » » » int64 time, | 5107 » » » PRTime time, |
5108 void *pwArg, | 5108 void *pwArg, |
5109 const SECItem *encodedResponse, | 5109 const SECItem *encodedResponse, |
5110 PRBool cacheInvalid, | 5110 PRBool cacheInvalid, |
5111 PRBool *certIDWasConsumed, | 5111 PRBool *certIDWasConsumed, |
5112 SECStatus *rv_ocsp) | 5112 SECStatus *rv_ocsp) |
5113 { | 5113 { |
5114 CERTOCSPResponse *response = NULL; | 5114 CERTOCSPResponse *response = NULL; |
5115 CERTCertificate *signerCert = NULL; | 5115 CERTCertificate *signerCert = NULL; |
5116 CERTCertificate *issuerCert = NULL; | 5116 CERTCertificate *issuerCert = NULL; |
5117 CERTOCSPSingleResponse *single = NULL; | 5117 CERTOCSPSingleResponse *single = NULL; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5188 if (response != NULL) | 5188 if (response != NULL) |
5189 CERT_DestroyOCSPResponse(response); | 5189 CERT_DestroyOCSPResponse(response); |
5190 return rv; | 5190 return rv; |
5191 } | 5191 } |
5192 | 5192 |
5193 static SECStatus | 5193 static SECStatus |
5194 ocsp_GetVerifiedSingleResponseForCertID(CERTCertDBHandle *handle, | 5194 ocsp_GetVerifiedSingleResponseForCertID(CERTCertDBHandle *handle, |
5195 CERTOCSPResponse *response, | 5195 CERTOCSPResponse *response, |
5196 CERTOCSPCertID *certID, | 5196 CERTOCSPCertID *certID, |
5197 CERTCertificate *signerCert, | 5197 CERTCertificate *signerCert, |
5198 int64 time, | 5198 PRTime time, |
5199 CERTOCSPSingleResponse | 5199 CERTOCSPSingleResponse |
5200 **pSingleResponse) | 5200 **pSingleResponse) |
5201 { | 5201 { |
5202 SECStatus rv; | 5202 SECStatus rv; |
5203 ocspResponseData *responseData; | 5203 ocspResponseData *responseData; |
5204 int64 producedAt; | 5204 PRTime producedAt; |
5205 CERTOCSPSingleResponse *single; | 5205 CERTOCSPSingleResponse *single; |
5206 | 5206 |
5207 /* | 5207 /* |
5208 * The ResponseData part is the real guts of the response. | 5208 * The ResponseData part is the real guts of the response. |
5209 */ | 5209 */ |
5210 responseData = ocsp_GetResponseData(response, NULL); | 5210 responseData = ocsp_GetResponseData(response, NULL); |
5211 if (responseData == NULL) { | 5211 if (responseData == NULL) { |
5212 rv = SECFailure; | 5212 rv = SECFailure; |
5213 goto loser; | 5213 goto loser; |
5214 } | 5214 } |
(...skipping 22 matching lines...) Expand all Loading... |
5237 | 5237 |
5238 loser: | 5238 loser: |
5239 return rv; | 5239 return rv; |
5240 } | 5240 } |
5241 | 5241 |
5242 SECStatus | 5242 SECStatus |
5243 CERT_GetOCSPStatusForCertID(CERTCertDBHandle *handle, | 5243 CERT_GetOCSPStatusForCertID(CERTCertDBHandle *handle, |
5244 CERTOCSPResponse *response, | 5244 CERTOCSPResponse *response, |
5245 CERTOCSPCertID *certID, | 5245 CERTOCSPCertID *certID, |
5246 CERTCertificate *signerCert, | 5246 CERTCertificate *signerCert, |
5247 int64 time) | 5247 PRTime time) |
5248 { | 5248 { |
5249 /* | 5249 /* |
5250 * We do not update the cache, because: | 5250 * We do not update the cache, because: |
5251 * | 5251 * |
5252 * CERT_GetOCSPStatusForCertID is an old exported API that was introduced | 5252 * CERT_GetOCSPStatusForCertID is an old exported API that was introduced |
5253 * before the OCSP cache got implemented. | 5253 * before the OCSP cache got implemented. |
5254 * | 5254 * |
5255 * The implementation of helper function cert_ProcessOCSPResponse | 5255 * The implementation of helper function cert_ProcessOCSPResponse |
5256 * requires the ability to transfer ownership of the the given certID to | 5256 * requires the ability to transfer ownership of the the given certID to |
5257 * the cache. The external API doesn't allow us to prevent the caller from | 5257 * the cache. The external API doesn't allow us to prevent the caller from |
(...skipping 13 matching lines...) Expand all Loading... |
5271 } | 5271 } |
5272 | 5272 |
5273 /* | 5273 /* |
5274 * The first 5 parameters match the definition of CERT_GetOCSPStatusForCertID. | 5274 * The first 5 parameters match the definition of CERT_GetOCSPStatusForCertID. |
5275 */ | 5275 */ |
5276 SECStatus | 5276 SECStatus |
5277 cert_ProcessOCSPResponse(CERTCertDBHandle *handle, | 5277 cert_ProcessOCSPResponse(CERTCertDBHandle *handle, |
5278 CERTOCSPResponse *response, | 5278 CERTOCSPResponse *response, |
5279 CERTOCSPCertID *certID, | 5279 CERTOCSPCertID *certID, |
5280 CERTCertificate *signerCert, | 5280 CERTCertificate *signerCert, |
5281 int64 time, | 5281 PRTime time, |
5282 PRBool *certIDWasConsumed, | 5282 PRBool *certIDWasConsumed, |
5283 SECStatus *cacheUpdateStatus) | 5283 SECStatus *cacheUpdateStatus) |
5284 { | 5284 { |
5285 SECStatus rv; | 5285 SECStatus rv; |
5286 SECStatus rv_cache = SECSuccess; | 5286 SECStatus rv_cache = SECSuccess; |
5287 CERTOCSPSingleResponse *single = NULL; | 5287 CERTOCSPSingleResponse *single = NULL; |
5288 | 5288 |
5289 rv = ocsp_GetVerifiedSingleResponseForCertID(handle, response, certID, | 5289 rv = ocsp_GetVerifiedSingleResponseForCertID(handle, response, certID, |
5290 signerCert, time, &single); | 5290 signerCert, time, &single); |
5291 if (rv == SECSuccess) { | 5291 if (rv == SECSuccess) { |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5808 case ocspResponse_unauthorized: | 5808 case ocspResponse_unauthorized: |
5809 PORT_SetError(SEC_ERROR_OCSP_UNAUTHORIZED_REQUEST); | 5809 PORT_SetError(SEC_ERROR_OCSP_UNAUTHORIZED_REQUEST); |
5810 break; | 5810 break; |
5811 case ocspResponse_unused: | 5811 case ocspResponse_unused: |
5812 default: | 5812 default: |
5813 PORT_SetError(SEC_ERROR_OCSP_UNKNOWN_RESPONSE_STATUS); | 5813 PORT_SetError(SEC_ERROR_OCSP_UNKNOWN_RESPONSE_STATUS); |
5814 break; | 5814 break; |
5815 } | 5815 } |
5816 return SECFailure; | 5816 return SECFailure; |
5817 } | 5817 } |
OLD | NEW |