Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: mozilla/security/nss/lib/certhigh/ocsp.h

Issue 14249009: Change the NSS and NSPR source tree to the new directory structure to be (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/nss/
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « mozilla/security/nss/lib/certhigh/crlv2.c ('k') | mozilla/security/nss/lib/certhigh/ocsp.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 /*
6 * Interface to the OCSP implementation.
7 *
8 * $Id: ocsp.h,v 1.24 2012/12/12 16:03:44 wtc%google.com Exp $
9 */
10
11 #ifndef _OCSP_H_
12 #define _OCSP_H_
13
14
15 #include "plarena.h"
16 #include "seccomon.h"
17 #include "secoidt.h"
18 #include "keyt.h"
19 #include "certt.h"
20 #include "ocspt.h"
21
22
23 /************************************************************************/
24 SEC_BEGIN_PROTOS
25
26 /*
27 * This function registers the HttpClient with whose functions the
28 * HttpClientFcn structure has been populated as the default Http
29 * client.
30 *
31 * The function table must be a global object.
32 * The caller must ensure that NSS will be able to call
33 * the registered functions for the lifetime of the process.
34 */
35 extern SECStatus
36 SEC_RegisterDefaultHttpClient(const SEC_HttpClientFcn *fcnTable);
37
38 /*
39 * This function obtains the HttpClient which has been registered
40 * by an earlier call to SEC_RegisterDefaultHttpClient.
41 */
42 extern const SEC_HttpClientFcn *
43 SEC_GetRegisteredHttpClient(void);
44
45 /*
46 * Sets parameters that control NSS' internal OCSP cache.
47 * maxCacheEntries, special varlues are:
48 * -1 disable cache
49 * 0 unlimited cache entries
50 * minimumSecondsToNextFetchAttempt:
51 * whenever an OCSP request was attempted or completed over the network,
52 * wait at least this number of seconds before trying to fetch again.
53 * maximumSecondsToNextFetchAttempt:
54 * this is the maximum age of a cached response we allow, until we try
55 * to fetch an updated response, even if the OCSP responder expects
56 * that newer information update will not be available yet.
57 */
58 extern SECStatus
59 CERT_OCSPCacheSettings(PRInt32 maxCacheEntries,
60 PRUint32 minimumSecondsToNextFetchAttempt,
61 PRUint32 maximumSecondsToNextFetchAttempt);
62
63 /*
64 * Set the desired behaviour on OCSP failures.
65 * See definition of ocspFailureMode for allowed choices.
66 */
67 extern SECStatus
68 CERT_SetOCSPFailureMode(SEC_OcspFailureMode ocspFailureMode);
69
70 /*
71 * Configure the maximum time NSS will wait for an OCSP response.
72 */
73 extern SECStatus
74 CERT_SetOCSPTimeout(PRUint32 seconds);
75
76 /*
77 * Removes all items currently stored in the OCSP cache.
78 */
79 extern SECStatus
80 CERT_ClearOCSPCache(void);
81
82 /*
83 * FUNCTION: CERT_EnableOCSPChecking
84 * Turns on OCSP checking for the given certificate database.
85 * INPUTS:
86 * CERTCertDBHandle *handle
87 * Certificate database for which OCSP checking will be enabled.
88 * RETURN:
89 * Returns SECFailure if an error occurred (likely only problem
90 * allocating memory); SECSuccess otherwise.
91 */
92 extern SECStatus
93 CERT_EnableOCSPChecking(CERTCertDBHandle *handle);
94
95 /*
96 * FUNCTION: CERT_DisableOCSPChecking
97 * Turns off OCSP checking for the given certificate database.
98 * This routine disables OCSP checking. Though it will return
99 * SECFailure if OCSP checking is not enabled, it is "safe" to
100 * call it that way and just ignore the return value, if it is
101 * easier to just call it than to "remember" whether it is enabled.
102 * INPUTS:
103 * CERTCertDBHandle *handle
104 * Certificate database for which OCSP checking will be disabled.
105 * RETURN:
106 * Returns SECFailure if an error occurred (usually means that OCSP
107 * checking was not enabled or status contexts were not initialized --
108 * error set will be SEC_ERROR_OCSP_NOT_ENABLED); SECSuccess otherwise.
109 */
110 extern SECStatus
111 CERT_DisableOCSPChecking(CERTCertDBHandle *handle);
112
113 /*
114 * FUNCTION: CERT_SetOCSPDefaultResponder
115 * Specify the location and cert of the default responder.
116 * If OCSP checking is already enabled *and* use of a default responder
117 * is also already enabled, all OCSP checking from now on will go directly
118 * to the specified responder. If OCSP checking is not enabled, or if
119 * it is but use of a default responder is not enabled, the information
120 * will be recorded and take effect whenever both are enabled.
121 * INPUTS:
122 * CERTCertDBHandle *handle
123 * Cert database on which OCSP checking should use the default responder.
124 * const char *url
125 * The location of the default responder (e.g. "http://foo.com:80/ocsp")
126 * Note that the location will not be tested until the first attempt
127 * to send a request there.
128 * const char *name
129 * The nickname of the cert to trust (expected) to sign the OCSP responses.
130 * If the corresponding cert cannot be found, SECFailure is returned.
131 * RETURN:
132 * Returns SECFailure if an error occurred; SECSuccess otherwise.
133 * The most likely error is that the cert for "name" could not be found
134 * (probably SEC_ERROR_UNKNOWN_CERT). Other errors are low-level (no memory,
135 * bad database, etc.).
136 */
137 extern SECStatus
138 CERT_SetOCSPDefaultResponder(CERTCertDBHandle *handle,
139 const char *url, const char *name);
140
141 /*
142 * FUNCTION: CERT_EnableOCSPDefaultResponder
143 * Turns on use of a default responder when OCSP checking.
144 * If OCSP checking is already enabled, this will make subsequent checks
145 * go directly to the default responder. (The location of the responder
146 * and the nickname of the responder cert must already be specified.)
147 * If OCSP checking is not enabled, this will be recorded and take effect
148 * whenever it is enabled.
149 * INPUTS:
150 * CERTCertDBHandle *handle
151 * Cert database on which OCSP checking should use the default responder.
152 * RETURN:
153 * Returns SECFailure if an error occurred; SECSuccess otherwise.
154 * No errors are especially likely unless the caller did not previously
155 * perform a successful call to SetOCSPDefaultResponder (in which case
156 * the error set will be SEC_ERROR_OCSP_NO_DEFAULT_RESPONDER).
157 */
158 extern SECStatus
159 CERT_EnableOCSPDefaultResponder(CERTCertDBHandle *handle);
160
161 /*
162 * FUNCTION: CERT_DisableOCSPDefaultResponder
163 * Turns off use of a default responder when OCSP checking.
164 * (Does nothing if use of a default responder is not enabled.)
165 * INPUTS:
166 * CERTCertDBHandle *handle
167 * Cert database on which OCSP checking should stop using a default
168 * responder.
169 * RETURN:
170 * Returns SECFailure if an error occurred; SECSuccess otherwise.
171 * Errors very unlikely (like random memory corruption...).
172 */
173 extern SECStatus
174 CERT_DisableOCSPDefaultResponder(CERTCertDBHandle *handle);
175
176 /*
177 * -------------------------------------------------------
178 * The Functions above are those expected to be used by a client
179 * providing OCSP status checking along with every cert verification.
180 * The functions below are for OCSP testing, debugging, or clients
181 * or servers performing more specialized OCSP tasks.
182 * -------------------------------------------------------
183 */
184
185 /*
186 * FUNCTION: CERT_CreateOCSPRequest
187 * Creates a CERTOCSPRequest, requesting the status of the certs in
188 * the given list.
189 * INPUTS:
190 * CERTCertList *certList
191 * A list of certs for which status will be requested.
192 * Note that all of these certificates should have the same issuer,
193 * or it's expected the response will be signed by a trusted responder.
194 * If the certs need to be broken up into multiple requests, that
195 * must be handled by the caller (and thus by having multiple calls
196 * to this routine), who knows about where the request(s) are being
197 * sent and whether there are any trusted responders in place.
198 * PRTime time
199 * Indicates the time for which the certificate status is to be
200 * determined -- this may be used in the search for the cert's issuer
201 * but has no effect on the request itself.
202 * PRBool addServiceLocator
203 * If true, the Service Locator extension should be added to the
204 * single request(s) for each cert.
205 * CERTCertificate *signerCert
206 * If non-NULL, means sign the request using this cert. Otherwise,
207 * do not sign.
208 * XXX note that request signing is not yet supported; see comment in code
209 * RETURN:
210 * A pointer to a CERTOCSPRequest structure containing an OCSP request
211 * for the cert list. On error, null is returned, with an error set
212 * indicating the reason. This is likely SEC_ERROR_UNKNOWN_ISSUER.
213 * (The issuer is needed to create a request for the certificate.)
214 * Other errors are low-level problems (no memory, bad database, etc.).
215 */
216 extern CERTOCSPRequest *
217 CERT_CreateOCSPRequest(CERTCertList *certList, PRTime time,
218 PRBool addServiceLocator,
219 CERTCertificate *signerCert);
220
221 /*
222 * FUNCTION: CERT_AddOCSPAcceptableResponses
223 * Add the AcceptableResponses extension to an OCSP Request.
224 * INPUTS:
225 * CERTOCSPRequest *request
226 * The request to which the extension should be added.
227 * SECOidTag responseType0, ...
228 * A list (of one or more) of SECOidTag -- each of the response types
229 * to be added. The last OID *must* be SEC_OID_PKIX_OCSP_BASIC_RESPONSE.
230 * (This marks the end of the list, and it must be specified because a
231 * client conforming to the OCSP standard is required to handle the basic
232 * response type.) The OIDs are not checked in any way.
233 * RETURN:
234 * SECSuccess if the extension is added; SECFailure if anything goes wrong.
235 * All errors are internal or low-level problems (e.g. no memory).
236 */
237 extern SECStatus
238 CERT_AddOCSPAcceptableResponses(CERTOCSPRequest *request,
239 SECOidTag responseType0, ...);
240
241 /*
242 * FUNCTION: CERT_EncodeOCSPRequest
243 * DER encodes an OCSP Request, possibly adding a signature as well.
244 * XXX Signing is not yet supported, however; see comments in code.
245 * INPUTS:
246 * PLArenaPool *arena
247 * The return value is allocated from here.
248 * If a NULL is passed in, allocation is done from the heap instead.
249 * CERTOCSPRequest *request
250 * The request to be encoded.
251 * void *pwArg
252 * Pointer to argument for password prompting, if needed. (Definitely
253 * not needed if not signing.)
254 * RETURN:
255 * Returns a NULL on error and a pointer to the SECItem with the
256 * encoded value otherwise. Any error is likely to be low-level
257 * (e.g. no memory).
258 */
259 extern SECItem *
260 CERT_EncodeOCSPRequest(PLArenaPool *arena, CERTOCSPRequest *request,
261 void *pwArg);
262
263 /*
264 * FUNCTION: CERT_DecodeOCSPRequest
265 * Decode a DER encoded OCSP Request.
266 * INPUTS:
267 * SECItem *src
268 * Pointer to a SECItem holding DER encoded OCSP Request.
269 * RETURN:
270 * Returns a pointer to a CERTOCSPRequest containing the decoded request.
271 * On error, returns NULL. Most likely error is trouble decoding
272 * (SEC_ERROR_OCSP_MALFORMED_REQUEST), or low-level problem (no memory).
273 */
274 extern CERTOCSPRequest *
275 CERT_DecodeOCSPRequest(const SECItem *src);
276
277 /*
278 * FUNCTION: CERT_DestroyOCSPRequest
279 * Frees an OCSP Request structure.
280 * INPUTS:
281 * CERTOCSPRequest *request
282 * Pointer to CERTOCSPRequest to be freed.
283 * RETURN:
284 * No return value; no errors.
285 */
286 extern void
287 CERT_DestroyOCSPRequest(CERTOCSPRequest *request);
288
289 /*
290 * FUNCTION: CERT_DecodeOCSPResponse
291 * Decode a DER encoded OCSP Response.
292 * INPUTS:
293 * SECItem *src
294 * Pointer to a SECItem holding DER encoded OCSP Response.
295 * RETURN:
296 * Returns a pointer to a CERTOCSPResponse (the decoded OCSP Response);
297 * the caller is responsible for destroying it. Or NULL if error (either
298 * response could not be decoded (SEC_ERROR_OCSP_MALFORMED_RESPONSE),
299 * it was of an unexpected type (SEC_ERROR_OCSP_UNKNOWN_RESPONSE_TYPE),
300 * or a low-level or internal error occurred).
301 */
302 extern CERTOCSPResponse *
303 CERT_DecodeOCSPResponse(SECItem *src);
304
305 /*
306 * FUNCTION: CERT_DestroyOCSPResponse
307 * Frees an OCSP Response structure.
308 * INPUTS:
309 * CERTOCSPResponse *request
310 * Pointer to CERTOCSPResponse to be freed.
311 * RETURN:
312 * No return value; no errors.
313 */
314 extern void
315 CERT_DestroyOCSPResponse(CERTOCSPResponse *response);
316
317 /*
318 * FUNCTION: CERT_GetEncodedOCSPResponse
319 * Creates and sends a request to an OCSP responder, then reads and
320 * returns the (encoded) response.
321 * INPUTS:
322 * PLArenaPool *arena
323 * Pointer to arena from which return value will be allocated.
324 * If NULL, result will be allocated from the heap (and thus should
325 * be freed via SECITEM_FreeItem).
326 * CERTCertList *certList
327 * A list of certs for which status will be requested.
328 * Note that all of these certificates should have the same issuer,
329 * or it's expected the response will be signed by a trusted responder.
330 * If the certs need to be broken up into multiple requests, that
331 * must be handled by the caller (and thus by having multiple calls
332 * to this routine), who knows about where the request(s) are being
333 * sent and whether there are any trusted responders in place.
334 * const char *location
335 * The location of the OCSP responder (a URL).
336 * PRTime time
337 * Indicates the time for which the certificate status is to be
338 * determined -- this may be used in the search for the cert's issuer
339 * but has no other bearing on the operation.
340 * PRBool addServiceLocator
341 * If true, the Service Locator extension should be added to the
342 * single request(s) for each cert.
343 * CERTCertificate *signerCert
344 * If non-NULL, means sign the request using this cert. Otherwise,
345 * do not sign.
346 * void *pwArg
347 * Pointer to argument for password prompting, if needed. (Definitely
348 * not needed if not signing.)
349 * OUTPUTS:
350 * CERTOCSPRequest **pRequest
351 * Pointer in which to store the OCSP request created for the given
352 * list of certificates. It is only filled in if the entire operation
353 * is successful and the pointer is not null -- and in that case the
354 * caller is then reponsible for destroying it.
355 * RETURN:
356 * Returns a pointer to the SECItem holding the response.
357 * On error, returns null with error set describing the reason:
358 * SEC_ERROR_UNKNOWN_ISSUER
359 * SEC_ERROR_CERT_BAD_ACCESS_LOCATION
360 * SEC_ERROR_OCSP_BAD_HTTP_RESPONSE
361 * Other errors are low-level problems (no memory, bad database, etc.).
362 */
363 extern SECItem *
364 CERT_GetEncodedOCSPResponse(PLArenaPool *arena, CERTCertList *certList,
365 const char *location, PRTime time,
366 PRBool addServiceLocator,
367 CERTCertificate *signerCert, void *pwArg,
368 CERTOCSPRequest **pRequest);
369
370 /*
371 * FUNCTION: CERT_VerifyOCSPResponseSignature
372 * Check the signature on an OCSP Response. Will also perform a
373 * verification of the signer's certificate. Note, however, that a
374 * successful verification does not make any statement about the
375 * signer's *authority* to provide status for the certificate(s),
376 * that must be checked individually for each certificate.
377 * INPUTS:
378 * CERTOCSPResponse *response
379 * Pointer to response structure with signature to be checked.
380 * CERTCertDBHandle *handle
381 * Pointer to CERTCertDBHandle for certificate DB to use for verification.
382 * void *pwArg
383 * Pointer to argument for password prompting, if needed.
384 * CERTCertificate *issuerCert
385 * Issuer of the certificate that generated the OCSP request.
386 * OUTPUTS:
387 * CERTCertificate **pSignerCert
388 * Pointer in which to store signer's certificate; only filled-in if
389 * non-null.
390 * RETURN:
391 * Returns SECSuccess when signature is valid, anything else means invalid.
392 * Possible errors set:
393 * SEC_ERROR_OCSP_MALFORMED_RESPONSE - unknown type of ResponderID
394 * SEC_ERROR_INVALID_TIME - bad format of "ProducedAt" time
395 * SEC_ERROR_UNKNOWN_SIGNER - signer's cert could not be found
396 * SEC_ERROR_BAD_SIGNATURE - the signature did not verify
397 * Other errors are any of the many possible failures in cert verification
398 * (e.g. SEC_ERROR_REVOKED_CERTIFICATE, SEC_ERROR_UNTRUSTED_ISSUER) when
399 * verifying the signer's cert, or low-level problems (no memory, etc.)
400 */
401 extern SECStatus
402 CERT_VerifyOCSPResponseSignature(CERTOCSPResponse *response,
403 CERTCertDBHandle *handle, void *pwArg,
404 CERTCertificate **pSignerCert,
405 CERTCertificate *issuerCert);
406
407 /*
408 * FUNCTION: CERT_GetOCSPAuthorityInfoAccessLocation
409 * Get the value of the URI of the OCSP responder for the given cert.
410 * This is found in the (optional) Authority Information Access extension
411 * in the cert.
412 * INPUTS:
413 * CERTCertificate *cert
414 * The certificate being examined.
415 * RETURN:
416 * char *
417 * A copy of the URI for the OCSP method, if found. If either the
418 * extension is not present or it does not contain an entry for OCSP,
419 * SEC_ERROR_EXTENSION_NOT_FOUND will be set and a NULL returned.
420 * Any other error will also result in a NULL being returned.
421 *
422 * This result should be freed (via PORT_Free) when no longer in use.
423 */
424 extern char *
425 CERT_GetOCSPAuthorityInfoAccessLocation(CERTCertificate *cert);
426
427 /*
428 * FUNCTION: CERT_RegisterAlternateOCSPAIAInfoCallBack
429 * This function serves two purposes.
430 * 1) It registers the address of a callback function that will be
431 * called for certs that have no OCSP AIA extension, to see if the
432 * callback wishes to supply an alternative URL for such an OCSP inquiry.
433 * 2) It outputs the previously registered function's address to the
434 * address supplied by the caller, unless that is NULL.
435 * The registered callback function returns NULL, or an allocated string
436 * that may be subsequently freed by calling PORT_Free().
437 * RETURN:
438 * SECSuccess or SECFailure (if the library is not yet intialized)
439 */
440 extern SECStatus
441 CERT_RegisterAlternateOCSPAIAInfoCallBack(
442 CERT_StringFromCertFcn newCallback,
443 CERT_StringFromCertFcn * oldCallback);
444
445 /*
446 * FUNCTION: CERT_ParseURL
447 * Parse a URI into hostname, port, and path. The scheme in the URI must
448 * be "http".
449 * INPUTS:
450 * const char *url
451 * The URI to be parsed
452 * OUTPUTS:
453 * char **pHostname
454 * Pointer to store the hostname obtained from the URI.
455 * This result should be freed (via PORT_Free) when no longer in use.
456 * PRUint16 *pPort
457 * Pointer to store the port number obtained from the URI.
458 * char **pPath
459 * Pointer to store the path obtained from the URI.
460 * This result should be freed (via PORT_Free) when no longer in use.
461 * RETURN:
462 * Returns SECSuccess when parsing was successful. Returns SECFailure when
463 * problems were encountered.
464 */
465 extern SECStatus
466 CERT_ParseURL(const char *url, char **pHostname, PRUint16 *pPort, char **pPath);
467
468 /*
469 * FUNCTION: CERT_CheckOCSPStatus
470 * Checks the status of a certificate via OCSP. Will only check status for
471 * a certificate that has an AIA (Authority Information Access) extension
472 * for OCSP *or* when a "default responder" is specified and enabled.
473 * (If no AIA extension for OCSP and no default responder in place, the
474 * cert is considered to have a good status and SECSuccess is returned.)
475 * INPUTS:
476 * CERTCertDBHandle *handle
477 * certificate DB of the cert that is being checked
478 * CERTCertificate *cert
479 * the certificate being checked
480 * XXX in the long term also need a boolean parameter that specifies
481 * whether to check the cert chain, as well; for now we check only
482 * the leaf (the specified certificate)
483 * PRTime time
484 * time for which status is to be determined
485 * void *pwArg
486 * argument for password prompting, if needed
487 * RETURN:
488 * Returns SECSuccess if an approved OCSP responder "knows" the cert
489 * *and* returns a non-revoked status for it; SECFailure otherwise,
490 * with an error set describing the reason:
491 *
492 * SEC_ERROR_OCSP_BAD_HTTP_RESPONSE
493 * SEC_ERROR_OCSP_FUTURE_RESPONSE
494 * SEC_ERROR_OCSP_MALFORMED_REQUEST
495 * SEC_ERROR_OCSP_MALFORMED_RESPONSE
496 * SEC_ERROR_OCSP_OLD_RESPONSE
497 * SEC_ERROR_OCSP_REQUEST_NEEDS_SIG
498 * SEC_ERROR_OCSP_SERVER_ERROR
499 * SEC_ERROR_OCSP_TRY_SERVER_LATER
500 * SEC_ERROR_OCSP_UNAUTHORIZED_REQUEST
501 * SEC_ERROR_OCSP_UNAUTHORIZED_RESPONSE
502 * SEC_ERROR_OCSP_UNKNOWN_CERT
503 * SEC_ERROR_OCSP_UNKNOWN_RESPONSE_STATUS
504 * SEC_ERROR_OCSP_UNKNOWN_RESPONSE_TYPE
505 *
506 * SEC_ERROR_BAD_SIGNATURE
507 * SEC_ERROR_CERT_BAD_ACCESS_LOCATION
508 * SEC_ERROR_INVALID_TIME
509 * SEC_ERROR_REVOKED_CERTIFICATE
510 * SEC_ERROR_UNKNOWN_ISSUER
511 * SEC_ERROR_UNKNOWN_SIGNER
512 *
513 * Other errors are any of the many possible failures in cert verification
514 * (e.g. SEC_ERROR_REVOKED_CERTIFICATE, SEC_ERROR_UNTRUSTED_ISSUER) when
515 * verifying the signer's cert, or low-level problems (error allocating
516 * memory, error performing ASN.1 decoding, etc.).
517 */
518 extern SECStatus
519 CERT_CheckOCSPStatus(CERTCertDBHandle *handle, CERTCertificate *cert,
520 PRTime time, void *pwArg);
521
522 /*
523 * FUNCTION: CERT_CacheOCSPResponseFromSideChannel
524 * First, this function checks the OCSP cache to see if a good response
525 * for the given certificate already exists. If it does, then the function
526 * returns successfully.
527 *
528 * If not, then it validates that the given OCSP response is a valid,
529 * good response for the given certificate and inserts it into the
530 * cache.
531 *
532 * This function is intended for use when OCSP responses are provided via a
533 * side-channel, i.e. TLS OCSP stapling (a.k.a. the status_request extension).
534 *
535 * INPUTS:
536 * CERTCertDBHandle *handle
537 * certificate DB of the cert that is being checked
538 * CERTCertificate *cert
539 * the certificate being checked
540 * PRTime time
541 * time for which status is to be determined
542 * SECItem *encodedResponse
543 * the DER encoded bytes of the OCSP response
544 * void *pwArg
545 * argument for password prompting, if needed
546 * RETURN:
547 * SECSuccess if the cert was found in the cache, or if the OCSP response was
548 * found to be valid and inserted into the cache. SECFailure otherwise.
549 */
550 extern SECStatus
551 CERT_CacheOCSPResponseFromSideChannel(CERTCertDBHandle *handle,
552 CERTCertificate *cert,
553 PRTime time,
554 SECItem *encodedResponse,
555 void *pwArg);
556
557 /*
558 * FUNCTION: CERT_GetOCSPStatusForCertID
559 * Returns the OCSP status contained in the passed in parameter response
560 * that corresponds to the certID passed in.
561 * INPUTS:
562 * CERTCertDBHandle *handle
563 * certificate DB of the cert that is being checked
564 * CERTOCSPResponse *response
565 * the OCSP response we want to retrieve status from.
566 * CERTOCSPCertID *certID
567 * the ID we want to look for from the response.
568 * CERTCertificate *signerCert
569 * the certificate that was used to sign the OCSP response.
570 * must be obtained via a call to CERT_VerifyOCSPResponseSignature.
571 * PRTime time
572 * The time at which we're checking the status for.
573 * RETURN:
574 * Return values are the same as those for CERT_CheckOCSPStatus
575 */
576 extern SECStatus
577 CERT_GetOCSPStatusForCertID(CERTCertDBHandle *handle,
578 CERTOCSPResponse *response,
579 CERTOCSPCertID *certID,
580 CERTCertificate *signerCert,
581 PRTime time);
582
583 /*
584 * FUNCTION CERT_GetOCSPResponseStatus
585 * Returns the response status for the response passed.
586 * INPUTS:
587 * CERTOCSPResponse *response
588 * The response to query for status
589 * RETURN:
590 * Returns SECSuccess if the response has a successful status value.
591 * Otherwise it returns SECFailure and sets one of the following error
592 * codes via PORT_SetError
593 * SEC_ERROR_OCSP_MALFORMED_REQUEST
594 * SEC_ERROR_OCSP_SERVER_ERROR
595 * SEC_ERROR_OCSP_TRY_SERVER_LATER
596 * SEC_ERROR_OCSP_REQUEST_NEEDS_SIG
597 * SEC_ERROR_OCSP_UNAUTHORIZED_REQUEST
598 * SEC_ERROR_OCSP_UNKNOWN_RESPONSE_STATUS
599 */
600 extern SECStatus
601 CERT_GetOCSPResponseStatus(CERTOCSPResponse *response);
602
603 /*
604 * FUNCTION CERT_CreateOCSPCertID
605 * Returns the OCSP certID for the certificate passed in.
606 * INPUTS:
607 * CERTCertificate *cert
608 * The certificate for which to create the certID for.
609 * PRTime time
610 * The time at which the id is requested for. This is used
611 * to determine the appropriate issuer for the cert since
612 * the issuing CA may be an older expired certificate.
613 * RETURN:
614 * A new copy of a CERTOCSPCertID*. The memory for this certID
615 * should be freed by calling CERT_DestroyOCSPCertID when the
616 * certID is no longer necessary.
617 */
618 extern CERTOCSPCertID*
619 CERT_CreateOCSPCertID(CERTCertificate *cert, PRTime time);
620
621 /*
622 * FUNCTION: CERT_DestroyOCSPCertID
623 * Frees the memory associated with the certID passed in.
624 * INPUTS:
625 * CERTOCSPCertID* certID
626 * The certID that the caller no longer needs and wants to
627 * free the associated memory.
628 * RETURN:
629 * SECSuccess if freeing the memory was successful. Returns
630 * SECFailure if the memory passed in was not allocated with
631 * a call to CERT_CreateOCSPCertID.
632 */
633 extern SECStatus
634 CERT_DestroyOCSPCertID(CERTOCSPCertID* certID);
635
636
637 extern CERTOCSPSingleResponse*
638 CERT_CreateOCSPSingleResponseGood(PLArenaPool *arena,
639 CERTOCSPCertID *id,
640 PRTime thisUpdate,
641 const PRTime *nextUpdate);
642
643 extern CERTOCSPSingleResponse*
644 CERT_CreateOCSPSingleResponseUnknown(PLArenaPool *arena,
645 CERTOCSPCertID *id,
646 PRTime thisUpdate,
647 const PRTime *nextUpdate);
648
649 extern CERTOCSPSingleResponse*
650 CERT_CreateOCSPSingleResponseRevoked(
651 PLArenaPool *arena,
652 CERTOCSPCertID *id,
653 PRTime thisUpdate,
654 const PRTime *nextUpdate,
655 PRTime revocationTime,
656 const CERTCRLEntryReasonCode* revocationReason);
657
658 extern SECItem*
659 CERT_CreateEncodedOCSPSuccessResponse(
660 PLArenaPool *arena,
661 CERTCertificate *responderCert,
662 CERTOCSPResponderIDType responderIDType,
663 PRTime producedAt,
664 CERTOCSPSingleResponse **responses,
665 void *wincx);
666
667 /*
668 * FUNCTION: CERT_CreateEncodedOCSPErrorResponse
669 * Creates an encoded OCSP response with an error response status.
670 * INPUTS:
671 * PLArenaPool *arena
672 * The return value is allocated from here.
673 * If a NULL is passed in, allocation is done from the heap instead.
674 * int error
675 * An NSS error code indicating an error response status. The error
676 * code is mapped to an OCSP response status as follows:
677 * SEC_ERROR_OCSP_MALFORMED_REQUEST -> malformedRequest
678 * SEC_ERROR_OCSP_SERVER_ERROR -> internalError
679 * SEC_ERROR_OCSP_TRY_SERVER_LATER -> tryLater
680 * SEC_ERROR_OCSP_REQUEST_NEEDS_SIG -> sigRequired
681 * SEC_ERROR_OCSP_UNAUTHORIZED_REQUEST -> unauthorized
682 * where the OCSP response status is an enumerated type defined in
683 * RFC 2560:
684 * OCSPResponseStatus ::= ENUMERATED {
685 * successful (0), --Response has valid confirmations
686 * malformedRequest (1), --Illegal confirmation request
687 * internalError (2), --Internal error in issuer
688 * tryLater (3), --Try again later
689 * --(4) is not used
690 * sigRequired (5), --Must sign the request
691 * unauthorized (6) --Request unauthorized
692 * }
693 * RETURN:
694 * Returns a pointer to the SECItem holding the response.
695 * On error, returns null with error set describing the reason:
696 * SEC_ERROR_INVALID_ARGS
697 * Other errors are low-level problems (no memory, bad database, etc.).
698 */
699 extern SECItem*
700 CERT_CreateEncodedOCSPErrorResponse(PLArenaPool *arena, int error);
701
702 /************************************************************************/
703 SEC_END_PROTOS
704
705 #endif /* _OCSP_H_ */
OLDNEW
« no previous file with comments | « mozilla/security/nss/lib/certhigh/crlv2.c ('k') | mozilla/security/nss/lib/certhigh/ocsp.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698