xref: /openbsd-src/lib/libcrypto/ocsp/ocsp.h (revision 50b7afb2c2c0993b0894d4e34bf857cb13ed9c80)
1 /* $OpenBSD: ocsp.h,v 1.6 2014/06/12 15:49:30 deraadt Exp $ */
2 /* Written by Tom Titchener <Tom_Titchener@groove.net> for the OpenSSL
3  * project. */
4 
5 /* History:
6    This file was transfered to Richard Levitte from CertCo by Kathy
7    Weinhold in mid-spring 2000 to be included in OpenSSL or released
8    as a patch kit. */
9 
10 /* ====================================================================
11  * Copyright (c) 1998-2000 The OpenSSL Project.  All rights reserved.
12  *
13  * Redistribution and use in source and binary forms, with or without
14  * modification, are permitted provided that the following conditions
15  * are met:
16  *
17  * 1. Redistributions of source code must retain the above copyright
18  *    notice, this list of conditions and the following disclaimer.
19  *
20  * 2. Redistributions in binary form must reproduce the above copyright
21  *    notice, this list of conditions and the following disclaimer in
22  *    the documentation and/or other materials provided with the
23  *    distribution.
24  *
25  * 3. All advertising materials mentioning features or use of this
26  *    software must display the following acknowledgment:
27  *    "This product includes software developed by the OpenSSL Project
28  *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
29  *
30  * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
31  *    endorse or promote products derived from this software without
32  *    prior written permission. For written permission, please contact
33  *    openssl-core@openssl.org.
34  *
35  * 5. Products derived from this software may not be called "OpenSSL"
36  *    nor may "OpenSSL" appear in their names without prior written
37  *    permission of the OpenSSL Project.
38  *
39  * 6. Redistributions of any form whatsoever must retain the following
40  *    acknowledgment:
41  *    "This product includes software developed by the OpenSSL Project
42  *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
43  *
44  * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
45  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
46  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
47  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
48  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
49  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
50  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
51  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
53  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
54  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
55  * OF THE POSSIBILITY OF SUCH DAMAGE.
56  * ====================================================================
57  *
58  * This product includes cryptographic software written by Eric Young
59  * (eay@cryptsoft.com).  This product includes software written by Tim
60  * Hudson (tjh@cryptsoft.com).
61  *
62  */
63 
64 #ifndef HEADER_OCSP_H
65 #define HEADER_OCSP_H
66 
67 #include <openssl/ossl_typ.h>
68 #include <openssl/x509.h>
69 #include <openssl/x509v3.h>
70 #include <openssl/safestack.h>
71 
72 #ifdef  __cplusplus
73 extern "C" {
74 #endif
75 
76 /* Various flags and values */
77 
78 #define OCSP_DEFAULT_NONCE_LENGTH	16
79 
80 #define OCSP_NOCERTS			0x1
81 #define OCSP_NOINTERN			0x2
82 #define OCSP_NOSIGS			0x4
83 #define OCSP_NOCHAIN			0x8
84 #define OCSP_NOVERIFY			0x10
85 #define OCSP_NOEXPLICIT			0x20
86 #define OCSP_NOCASIGN			0x40
87 #define OCSP_NODELEGATED		0x80
88 #define OCSP_NOCHECKS			0x100
89 #define OCSP_TRUSTOTHER			0x200
90 #define OCSP_RESPID_KEY			0x400
91 #define OCSP_NOTIME			0x800
92 
93 /*   CertID ::= SEQUENCE {
94  *       hashAlgorithm            AlgorithmIdentifier,
95  *       issuerNameHash     OCTET STRING, -- Hash of Issuer's DN
96  *       issuerKeyHash      OCTET STRING, -- Hash of Issuers public key (excluding the tag & length fields)
97  *       serialNumber       CertificateSerialNumber }
98  */
99 typedef struct ocsp_cert_id_st {
100 	X509_ALGOR *hashAlgorithm;
101 	ASN1_OCTET_STRING *issuerNameHash;
102 	ASN1_OCTET_STRING *issuerKeyHash;
103 	ASN1_INTEGER *serialNumber;
104 } OCSP_CERTID;
105 
106 DECLARE_STACK_OF(OCSP_CERTID)
107 
108 /*   Request ::=     SEQUENCE {
109  *       reqCert                    CertID,
110  *       singleRequestExtensions    [0] EXPLICIT Extensions OPTIONAL }
111  */
112 typedef struct ocsp_one_request_st {
113 	OCSP_CERTID *reqCert;
114 	STACK_OF(X509_EXTENSION) *singleRequestExtensions;
115 } OCSP_ONEREQ;
116 
117 DECLARE_STACK_OF(OCSP_ONEREQ)
118 DECLARE_ASN1_SET_OF(OCSP_ONEREQ)
119 
120 
121 /*   TBSRequest      ::=     SEQUENCE {
122  *       version             [0] EXPLICIT Version DEFAULT v1,
123  *       requestorName       [1] EXPLICIT GeneralName OPTIONAL,
124  *       requestList             SEQUENCE OF Request,
125  *       requestExtensions   [2] EXPLICIT Extensions OPTIONAL }
126  */
127 typedef struct ocsp_req_info_st {
128 	ASN1_INTEGER *version;
129 	GENERAL_NAME *requestorName;
130 	STACK_OF(OCSP_ONEREQ) *requestList;
131 	STACK_OF(X509_EXTENSION) *requestExtensions;
132 } OCSP_REQINFO;
133 
134 /*   Signature       ::=     SEQUENCE {
135  *       signatureAlgorithm   AlgorithmIdentifier,
136  *       signature            BIT STRING,
137  *       certs                [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }
138  */
139 typedef struct ocsp_signature_st {
140 	X509_ALGOR *signatureAlgorithm;
141 	ASN1_BIT_STRING *signature;
142 	STACK_OF(X509) *certs;
143 } OCSP_SIGNATURE;
144 
145 /*   OCSPRequest     ::=     SEQUENCE {
146  *       tbsRequest                  TBSRequest,
147  *       optionalSignature   [0]     EXPLICIT Signature OPTIONAL }
148  */
149 typedef struct ocsp_request_st {
150 	OCSP_REQINFO *tbsRequest;
151 	OCSP_SIGNATURE *optionalSignature; /* OPTIONAL */
152 } OCSP_REQUEST;
153 
154 /*   OCSPResponseStatus ::= ENUMERATED {
155  *       successful            (0),      --Response has valid confirmations
156  *       malformedRequest      (1),      --Illegal confirmation request
157  *       internalError         (2),      --Internal error in issuer
158  *       tryLater              (3),      --Try again later
159  *                                       --(4) is not used
160  *       sigRequired           (5),      --Must sign the request
161  *       unauthorized          (6)       --Request unauthorized
162  *   }
163  */
164 #define OCSP_RESPONSE_STATUS_SUCCESSFUL		0
165 #define OCSP_RESPONSE_STATUS_MALFORMEDREQUEST	1
166 #define OCSP_RESPONSE_STATUS_INTERNALERROR	2
167 #define OCSP_RESPONSE_STATUS_TRYLATER		3
168 #define OCSP_RESPONSE_STATUS_SIGREQUIRED	5
169 #define OCSP_RESPONSE_STATUS_UNAUTHORIZED	6
170 
171 /*   ResponseBytes ::=       SEQUENCE {
172  *       responseType   OBJECT IDENTIFIER,
173  *       response       OCTET STRING }
174  */
175 typedef struct ocsp_resp_bytes_st {
176 	ASN1_OBJECT *responseType;
177 	ASN1_OCTET_STRING *response;
178 } OCSP_RESPBYTES;
179 
180 /*   OCSPResponse ::= SEQUENCE {
181  *      responseStatus         OCSPResponseStatus,
182  *      responseBytes          [0] EXPLICIT ResponseBytes OPTIONAL }
183  */
184 struct ocsp_response_st {
185 	ASN1_ENUMERATED *responseStatus;
186 	OCSP_RESPBYTES  *responseBytes;
187 };
188 
189 /*   ResponderID ::= CHOICE {
190  *      byName   [1] Name,
191  *      byKey    [2] KeyHash }
192  */
193 #define V_OCSP_RESPID_NAME 0
194 #define V_OCSP_RESPID_KEY  1
195 struct ocsp_responder_id_st {
196 	int type;
197 	union {
198 		X509_NAME* byName;
199 		ASN1_OCTET_STRING *byKey;
200 	} value;
201 };
202 
203 DECLARE_STACK_OF(OCSP_RESPID)
204 DECLARE_ASN1_FUNCTIONS(OCSP_RESPID)
205 
206 /*   KeyHash ::= OCTET STRING --SHA-1 hash of responder's public key
207  *                            --(excluding the tag and length fields)
208  */
209 
210 /*   RevokedInfo ::= SEQUENCE {
211  *       revocationTime              GeneralizedTime,
212  *       revocationReason    [0]     EXPLICIT CRLReason OPTIONAL }
213  */
214 typedef struct ocsp_revoked_info_st {
215 	ASN1_GENERALIZEDTIME *revocationTime;
216 	ASN1_ENUMERATED *revocationReason;
217 } OCSP_REVOKEDINFO;
218 
219 /*   CertStatus ::= CHOICE {
220  *       good                [0]     IMPLICIT NULL,
221  *       revoked             [1]     IMPLICIT RevokedInfo,
222  *       unknown             [2]     IMPLICIT UnknownInfo }
223  */
224 #define V_OCSP_CERTSTATUS_GOOD    0
225 #define V_OCSP_CERTSTATUS_REVOKED 1
226 #define V_OCSP_CERTSTATUS_UNKNOWN 2
227 typedef struct ocsp_cert_status_st {
228 	int type;
229 	union {
230 		ASN1_NULL *good;
231 		OCSP_REVOKEDINFO *revoked;
232 		ASN1_NULL *unknown;
233 	} value;
234 } OCSP_CERTSTATUS;
235 
236 /*   SingleResponse ::= SEQUENCE {
237  *      certID                       CertID,
238  *      certStatus                   CertStatus,
239  *      thisUpdate                   GeneralizedTime,
240  *      nextUpdate           [0]     EXPLICIT GeneralizedTime OPTIONAL,
241  *      singleExtensions     [1]     EXPLICIT Extensions OPTIONAL }
242  */
243 typedef struct ocsp_single_response_st {
244 	OCSP_CERTID *certId;
245 	OCSP_CERTSTATUS *certStatus;
246 	ASN1_GENERALIZEDTIME *thisUpdate;
247 	ASN1_GENERALIZEDTIME *nextUpdate;
248 	STACK_OF(X509_EXTENSION) *singleExtensions;
249 } OCSP_SINGLERESP;
250 
251 DECLARE_STACK_OF(OCSP_SINGLERESP)
252 DECLARE_ASN1_SET_OF(OCSP_SINGLERESP)
253 
254 /*   ResponseData ::= SEQUENCE {
255  *      version              [0] EXPLICIT Version DEFAULT v1,
256  *      responderID              ResponderID,
257  *      producedAt               GeneralizedTime,
258  *      responses                SEQUENCE OF SingleResponse,
259  *      responseExtensions   [1] EXPLICIT Extensions OPTIONAL }
260  */
261 typedef struct ocsp_response_data_st {
262 	ASN1_INTEGER *version;
263 	OCSP_RESPID  *responderId;
264 	ASN1_GENERALIZEDTIME *producedAt;
265 	STACK_OF(OCSP_SINGLERESP) *responses;
266 	STACK_OF(X509_EXTENSION) *responseExtensions;
267 } OCSP_RESPDATA;
268 
269 /*   BasicOCSPResponse       ::= SEQUENCE {
270  *      tbsResponseData      ResponseData,
271  *      signatureAlgorithm   AlgorithmIdentifier,
272  *      signature            BIT STRING,
273  *      certs                [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }
274  */
275   /* Note 1:
276      The value for "signature" is specified in the OCSP rfc2560 as follows:
277      "The value for the signature SHALL be computed on the hash of the DER
278      encoding ResponseData."  This means that you must hash the DER-encoded
279      tbsResponseData, and then run it through a crypto-signing function, which
280      will (at least w/RSA) do a hash-'n'-private-encrypt operation.  This seems
281      a bit odd, but that's the spec.  Also note that the data structures do not
282      leave anywhere to independently specify the algorithm used for the initial
283      hash. So, we look at the signature-specification algorithm, and try to do
284      something intelligent.	-- Kathy Weinhold, CertCo */
285   /* Note 2:
286      It seems that the mentioned passage from RFC 2560 (section 4.2.1) is open
287      for interpretation.  I've done tests against another responder, and found
288      that it doesn't do the double hashing that the RFC seems to say one
289      should.  Therefore, all relevant functions take a flag saying which
290      variant should be used.	-- Richard Levitte, OpenSSL team and CeloCom */
291 typedef struct ocsp_basic_response_st {
292 	OCSP_RESPDATA *tbsResponseData;
293 	X509_ALGOR *signatureAlgorithm;
294 	ASN1_BIT_STRING *signature;
295 	STACK_OF(X509) *certs;
296 } OCSP_BASICRESP;
297 
298 /*
299  *   CRLReason ::= ENUMERATED {
300  *        unspecified             (0),
301  *        keyCompromise           (1),
302  *        cACompromise            (2),
303  *        affiliationChanged      (3),
304  *        superseded              (4),
305  *        cessationOfOperation    (5),
306  *        certificateHold         (6),
307  *        removeFromCRL           (8) }
308  */
309 #define OCSP_REVOKED_STATUS_NOSTATUS			-1
310 #define OCSP_REVOKED_STATUS_UNSPECIFIED			0
311 #define OCSP_REVOKED_STATUS_KEYCOMPROMISE		1
312 #define OCSP_REVOKED_STATUS_CACOMPROMISE		2
313 #define OCSP_REVOKED_STATUS_AFFILIATIONCHANGED		3
314 #define OCSP_REVOKED_STATUS_SUPERSEDED			4
315 #define OCSP_REVOKED_STATUS_CESSATIONOFOPERATION	5
316 #define OCSP_REVOKED_STATUS_CERTIFICATEHOLD		6
317 #define OCSP_REVOKED_STATUS_REMOVEFROMCRL		8
318 
319 /* CrlID ::= SEQUENCE {
320  *     crlUrl               [0]     EXPLICIT IA5String OPTIONAL,
321  *     crlNum               [1]     EXPLICIT INTEGER OPTIONAL,
322  *     crlTime              [2]     EXPLICIT GeneralizedTime OPTIONAL }
323  */
324 typedef struct ocsp_crl_id_st {
325 	ASN1_IA5STRING *crlUrl;
326 	ASN1_INTEGER *crlNum;
327 	ASN1_GENERALIZEDTIME *crlTime;
328 } OCSP_CRLID;
329 
330 /* ServiceLocator ::= SEQUENCE {
331  *      issuer    Name,
332  *      locator   AuthorityInfoAccessSyntax OPTIONAL }
333  */
334 typedef struct ocsp_service_locator_st {
335 	X509_NAME* issuer;
336 	STACK_OF(ACCESS_DESCRIPTION) *locator;
337 } OCSP_SERVICELOC;
338 
339 #define PEM_STRING_OCSP_REQUEST	"OCSP REQUEST"
340 #define PEM_STRING_OCSP_RESPONSE "OCSP RESPONSE"
341 
342 #define d2i_OCSP_REQUEST_bio(bp,p) \
343     ASN1_d2i_bio_of(OCSP_REQUEST,OCSP_REQUEST_new,d2i_OCSP_REQUEST,bp,p)
344 
345 #define d2i_OCSP_RESPONSE_bio(bp,p) \
346     ASN1_d2i_bio_of(OCSP_RESPONSE,OCSP_RESPONSE_new,d2i_OCSP_RESPONSE,bp,p)
347 
348 #define	PEM_read_bio_OCSP_REQUEST(bp,x,cb) \
349     (OCSP_REQUEST *)PEM_ASN1_read_bio((char *(*)())d2i_OCSP_REQUEST, \
350 	PEM_STRING_OCSP_REQUEST,bp,(char **)x,cb,NULL)
351 
352 #define	PEM_read_bio_OCSP_RESPONSE(bp,x,cb) \
353     (OCSP_RESPONSE *)PEM_ASN1_read_bio((char *(*)())d2i_OCSP_RESPONSE, \
354 	PEM_STRING_OCSP_RESPONSE,bp,(char **)x,cb,NULL)
355 
356 #define PEM_write_bio_OCSP_REQUEST(bp,o) \
357     PEM_ASN1_write_bio((int (*)())i2d_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,\
358 	bp,(char *)o, NULL,NULL,0,NULL,NULL)
359 
360 #define PEM_write_bio_OCSP_RESPONSE(bp,o) \
361     PEM_ASN1_write_bio((int (*)())i2d_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,\
362 	bp,(char *)o, NULL,NULL,0,NULL,NULL)
363 
364 #define i2d_OCSP_RESPONSE_bio(bp,o) \
365     ASN1_i2d_bio_of(OCSP_RESPONSE,i2d_OCSP_RESPONSE,bp,o)
366 
367 #define i2d_OCSP_REQUEST_bio(bp,o) \
368     ASN1_i2d_bio_of(OCSP_REQUEST,i2d_OCSP_REQUEST,bp,o)
369 
370 #define OCSP_REQUEST_sign(o,pkey,md) \
371     ASN1_item_sign(ASN1_ITEM_rptr(OCSP_REQINFO), \
372 	o->optionalSignature->signatureAlgorithm,NULL, \
373 	o->optionalSignature->signature,o->tbsRequest,pkey,md)
374 
375 #define OCSP_BASICRESP_sign(o,pkey,md,d) \
376     ASN1_item_sign(ASN1_ITEM_rptr(OCSP_RESPDATA),o->signatureAlgorithm,NULL, \
377 	o->signature,o->tbsResponseData,pkey,md)
378 
379 #define OCSP_REQUEST_verify(a,r) \
380     ASN1_item_verify(ASN1_ITEM_rptr(OCSP_REQINFO), \
381 	a->optionalSignature->signatureAlgorithm, \
382 	a->optionalSignature->signature,a->tbsRequest,r)
383 
384 #define OCSP_BASICRESP_verify(a,r,d) \
385     ASN1_item_verify(ASN1_ITEM_rptr(OCSP_RESPDATA), \
386 	a->signatureAlgorithm,a->signature,a->tbsResponseData,r)
387 
388 #define ASN1_BIT_STRING_digest(data,type,md,len) \
389     ASN1_item_digest(ASN1_ITEM_rptr(ASN1_BIT_STRING),type,data,md,len)
390 
391 #define OCSP_CERTSTATUS_dup(cs)\
392     (OCSP_CERTSTATUS*)ASN1_dup((int(*)())i2d_OCSP_CERTSTATUS,\
393 	(char *(*)())d2i_OCSP_CERTSTATUS,(char *)(cs))
394 
395 OCSP_CERTID *OCSP_CERTID_dup(OCSP_CERTID *id);
396 
397 OCSP_RESPONSE *OCSP_sendreq_bio(BIO *b, char *path, OCSP_REQUEST *req);
398 OCSP_REQ_CTX *OCSP_sendreq_new(BIO *io, char *path, OCSP_REQUEST *req,
399 	    int maxline);
400 int	OCSP_sendreq_nbio(OCSP_RESPONSE **presp, OCSP_REQ_CTX *rctx);
401 void	OCSP_REQ_CTX_free(OCSP_REQ_CTX *rctx);
402 int	OCSP_REQ_CTX_set1_req(OCSP_REQ_CTX *rctx, OCSP_REQUEST *req);
403 int	OCSP_REQ_CTX_add1_header(OCSP_REQ_CTX *rctx, const char *name,
404 	    const char *value);
405 
406 OCSP_CERTID *OCSP_cert_to_id(const EVP_MD *dgst, X509 *subject, X509 *issuer);
407 
408 OCSP_CERTID *OCSP_cert_id_new(const EVP_MD *dgst, X509_NAME *issuerName,
409 	    ASN1_BIT_STRING* issuerKey, ASN1_INTEGER *serialNumber);
410 
411 OCSP_ONEREQ *OCSP_request_add0_id(OCSP_REQUEST *req, OCSP_CERTID *cid);
412 
413 int	OCSP_request_add1_nonce(OCSP_REQUEST *req, unsigned char *val, int len);
414 int	OCSP_basic_add1_nonce(OCSP_BASICRESP *resp, unsigned char *val, int len);
415 int	OCSP_check_nonce(OCSP_REQUEST *req, OCSP_BASICRESP *bs);
416 int	OCSP_copy_nonce(OCSP_BASICRESP *resp, OCSP_REQUEST *req);
417 
418 int	OCSP_request_set1_name(OCSP_REQUEST *req, X509_NAME *nm);
419 int	OCSP_request_add1_cert(OCSP_REQUEST *req, X509 *cert);
420 
421 int	OCSP_request_sign(OCSP_REQUEST *req, X509 *signer, EVP_PKEY *key,
422 	    const EVP_MD *dgst, STACK_OF(X509) *certs, unsigned long flags);
423 
424 int	OCSP_response_status(OCSP_RESPONSE *resp);
425 OCSP_BASICRESP *OCSP_response_get1_basic(OCSP_RESPONSE *resp);
426 
427 int	OCSP_resp_count(OCSP_BASICRESP *bs);
428 OCSP_SINGLERESP *OCSP_resp_get0(OCSP_BASICRESP *bs, int idx);
429 int	OCSP_resp_find(OCSP_BASICRESP *bs, OCSP_CERTID *id, int last);
430 int	OCSP_single_get0_status(OCSP_SINGLERESP *single, int *reason,
431 	    ASN1_GENERALIZEDTIME **revtime, ASN1_GENERALIZEDTIME **thisupd,
432 	    ASN1_GENERALIZEDTIME **nextupd);
433 int	OCSP_resp_find_status(OCSP_BASICRESP *bs, OCSP_CERTID *id, int *status,
434 	    int *reason, ASN1_GENERALIZEDTIME **revtime,
435 	    ASN1_GENERALIZEDTIME **thisupd, ASN1_GENERALIZEDTIME **nextupd);
436 int	OCSP_check_validity(ASN1_GENERALIZEDTIME *thisupd,
437 	    ASN1_GENERALIZEDTIME *nextupd, long sec, long maxsec);
438 
439 int	OCSP_request_verify(OCSP_REQUEST *req, STACK_OF(X509) *certs,
440 	    X509_STORE *store, unsigned long flags);
441 
442 int	OCSP_parse_url(char *url, char **phost, char **pport, char **ppath,
443 	    int *pssl);
444 
445 int	OCSP_id_issuer_cmp(OCSP_CERTID *a, OCSP_CERTID *b);
446 int	OCSP_id_cmp(OCSP_CERTID *a, OCSP_CERTID *b);
447 
448 int	OCSP_request_onereq_count(OCSP_REQUEST *req);
449 OCSP_ONEREQ *OCSP_request_onereq_get0(OCSP_REQUEST *req, int i);
450 OCSP_CERTID *OCSP_onereq_get0_id(OCSP_ONEREQ *one);
451 int	OCSP_id_get0_info(ASN1_OCTET_STRING **piNameHash, ASN1_OBJECT **pmd,
452 	    ASN1_OCTET_STRING **pikeyHash, ASN1_INTEGER **pserial,
453 	    OCSP_CERTID *cid);
454 int	OCSP_request_is_signed(OCSP_REQUEST *req);
455 OCSP_RESPONSE *OCSP_response_create(int status, OCSP_BASICRESP *bs);
456 OCSP_SINGLERESP *OCSP_basic_add1_status(OCSP_BASICRESP *rsp, OCSP_CERTID *cid,
457 	    int status, int reason, ASN1_TIME *revtime, ASN1_TIME *thisupd,
458 	    ASN1_TIME *nextupd);
459 int	OCSP_basic_add1_cert(OCSP_BASICRESP *resp, X509 *cert);
460 int	OCSP_basic_sign(OCSP_BASICRESP *brsp, X509 *signer, EVP_PKEY *key,
461 	    const EVP_MD *dgst, STACK_OF(X509) *certs, unsigned long flags);
462 
463 X509_EXTENSION *OCSP_crlID_new(char *url, long *n, char *tim);
464 
465 X509_EXTENSION *OCSP_accept_responses_new(char **oids);
466 
467 X509_EXTENSION *OCSP_archive_cutoff_new(char* tim);
468 
469 X509_EXTENSION *OCSP_url_svcloc_new(X509_NAME* issuer, char **urls);
470 
471 int	OCSP_REQUEST_get_ext_count(OCSP_REQUEST *x);
472 int	OCSP_REQUEST_get_ext_by_NID(OCSP_REQUEST *x, int nid, int lastpos);
473 int	OCSP_REQUEST_get_ext_by_OBJ(OCSP_REQUEST *x, ASN1_OBJECT *obj,
474 	    int lastpos);
475 int	OCSP_REQUEST_get_ext_by_critical(OCSP_REQUEST *x, int crit,
476 	    int lastpos);
477 X509_EXTENSION *OCSP_REQUEST_get_ext(OCSP_REQUEST *x, int loc);
478 X509_EXTENSION *OCSP_REQUEST_delete_ext(OCSP_REQUEST *x, int loc);
479 void *OCSP_REQUEST_get1_ext_d2i(OCSP_REQUEST *x, int nid, int *crit, int *idx);
480 int	OCSP_REQUEST_add1_ext_i2d(OCSP_REQUEST *x, int nid, void *value,
481 	    int crit, unsigned long flags);
482 int	OCSP_REQUEST_add_ext(OCSP_REQUEST *x, X509_EXTENSION *ex, int loc);
483 
484 int	OCSP_ONEREQ_get_ext_count(OCSP_ONEREQ *x);
485 int	OCSP_ONEREQ_get_ext_by_NID(OCSP_ONEREQ *x, int nid, int lastpos);
486 int	OCSP_ONEREQ_get_ext_by_OBJ(OCSP_ONEREQ *x, ASN1_OBJECT *obj,
487 	    int lastpos);
488 int	OCSP_ONEREQ_get_ext_by_critical(OCSP_ONEREQ *x, int crit, int lastpos);
489 X509_EXTENSION *OCSP_ONEREQ_get_ext(OCSP_ONEREQ *x, int loc);
490 X509_EXTENSION *OCSP_ONEREQ_delete_ext(OCSP_ONEREQ *x, int loc);
491 void *OCSP_ONEREQ_get1_ext_d2i(OCSP_ONEREQ *x, int nid, int *crit, int *idx);
492 int	OCSP_ONEREQ_add1_ext_i2d(OCSP_ONEREQ *x, int nid, void *value, int crit,
493 	    unsigned long flags);
494 int	OCSP_ONEREQ_add_ext(OCSP_ONEREQ *x, X509_EXTENSION *ex, int loc);
495 
496 int	OCSP_BASICRESP_get_ext_count(OCSP_BASICRESP *x);
497 int	OCSP_BASICRESP_get_ext_by_NID(OCSP_BASICRESP *x, int nid, int lastpos);
498 int	OCSP_BASICRESP_get_ext_by_OBJ(OCSP_BASICRESP *x, ASN1_OBJECT *obj,
499 	    int lastpos);
500 int	OCSP_BASICRESP_get_ext_by_critical(OCSP_BASICRESP *x, int crit,
501 	    int lastpos);
502 X509_EXTENSION *OCSP_BASICRESP_get_ext(OCSP_BASICRESP *x, int loc);
503 X509_EXTENSION *OCSP_BASICRESP_delete_ext(OCSP_BASICRESP *x, int loc);
504 void *OCSP_BASICRESP_get1_ext_d2i(OCSP_BASICRESP *x, int nid, int *crit,
505 	    int *idx);
506 int	OCSP_BASICRESP_add1_ext_i2d(OCSP_BASICRESP *x, int nid, void *value,
507 	    int crit, unsigned long flags);
508 int	OCSP_BASICRESP_add_ext(OCSP_BASICRESP *x, X509_EXTENSION *ex, int loc);
509 
510 int	OCSP_SINGLERESP_get_ext_count(OCSP_SINGLERESP *x);
511 int	OCSP_SINGLERESP_get_ext_by_NID(OCSP_SINGLERESP *x, int nid,
512 	    int lastpos);
513 int	OCSP_SINGLERESP_get_ext_by_OBJ(OCSP_SINGLERESP *x, ASN1_OBJECT *obj,
514 	    int lastpos);
515 int	OCSP_SINGLERESP_get_ext_by_critical(OCSP_SINGLERESP *x, int crit,
516 	    int lastpos);
517 X509_EXTENSION *OCSP_SINGLERESP_get_ext(OCSP_SINGLERESP *x, int loc);
518 X509_EXTENSION *OCSP_SINGLERESP_delete_ext(OCSP_SINGLERESP *x, int loc);
519 void *OCSP_SINGLERESP_get1_ext_d2i(OCSP_SINGLERESP *x, int nid, int *crit,
520 	    int *idx);
521 int	OCSP_SINGLERESP_add1_ext_i2d(OCSP_SINGLERESP *x, int nid, void *value,
522 	    int crit, unsigned long flags);
523 int	OCSP_SINGLERESP_add_ext(OCSP_SINGLERESP *x, X509_EXTENSION *ex,
524 	    int loc);
525 
526 DECLARE_ASN1_FUNCTIONS(OCSP_SINGLERESP)
527 DECLARE_ASN1_FUNCTIONS(OCSP_CERTSTATUS)
528 DECLARE_ASN1_FUNCTIONS(OCSP_REVOKEDINFO)
529 DECLARE_ASN1_FUNCTIONS(OCSP_BASICRESP)
530 DECLARE_ASN1_FUNCTIONS(OCSP_RESPDATA)
531 DECLARE_ASN1_FUNCTIONS(OCSP_RESPID)
532 DECLARE_ASN1_FUNCTIONS(OCSP_RESPONSE)
533 DECLARE_ASN1_FUNCTIONS(OCSP_RESPBYTES)
534 DECLARE_ASN1_FUNCTIONS(OCSP_ONEREQ)
535 DECLARE_ASN1_FUNCTIONS(OCSP_CERTID)
536 DECLARE_ASN1_FUNCTIONS(OCSP_REQUEST)
537 DECLARE_ASN1_FUNCTIONS(OCSP_SIGNATURE)
538 DECLARE_ASN1_FUNCTIONS(OCSP_REQINFO)
539 DECLARE_ASN1_FUNCTIONS(OCSP_CRLID)
540 DECLARE_ASN1_FUNCTIONS(OCSP_SERVICELOC)
541 
542 const char *OCSP_response_status_str(long s);
543 const char *OCSP_cert_status_str(long s);
544 const char *OCSP_crl_reason_str(long s);
545 
546 int	OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST* a, unsigned long flags);
547 int	OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE* o, unsigned long flags);
548 
549 int	OCSP_basic_verify(OCSP_BASICRESP *bs, STACK_OF(X509) *certs,
550 	    X509_STORE *st, unsigned long flags);
551 
552 /* BEGIN ERROR CODES */
553 /* The following lines are auto generated by the script mkerr.pl. Any changes
554  * made after this point may be overwritten when the script is next run.
555  */
556 void ERR_load_OCSP_strings(void);
557 
558 /* Error codes for the OCSP functions. */
559 
560 /* Function codes. */
561 #define OCSP_F_ASN1_STRING_ENCODE			 100
562 #define OCSP_F_D2I_OCSP_NONCE				 102
563 #define OCSP_F_OCSP_BASIC_ADD1_STATUS			 103
564 #define OCSP_F_OCSP_BASIC_SIGN				 104
565 #define OCSP_F_OCSP_BASIC_VERIFY			 105
566 #define OCSP_F_OCSP_CERT_ID_NEW				 101
567 #define OCSP_F_OCSP_CHECK_DELEGATED			 106
568 #define OCSP_F_OCSP_CHECK_IDS				 107
569 #define OCSP_F_OCSP_CHECK_ISSUER			 108
570 #define OCSP_F_OCSP_CHECK_VALIDITY			 115
571 #define OCSP_F_OCSP_MATCH_ISSUERID			 109
572 #define OCSP_F_OCSP_PARSE_URL				 114
573 #define OCSP_F_OCSP_REQUEST_SIGN			 110
574 #define OCSP_F_OCSP_REQUEST_VERIFY			 116
575 #define OCSP_F_OCSP_RESPONSE_GET1_BASIC			 111
576 #define OCSP_F_OCSP_SENDREQ_BIO				 112
577 #define OCSP_F_OCSP_SENDREQ_NBIO			 117
578 #define OCSP_F_PARSE_HTTP_LINE1				 118
579 #define OCSP_F_REQUEST_VERIFY				 113
580 
581 /* Reason codes. */
582 #define OCSP_R_BAD_DATA					 100
583 #define OCSP_R_CERTIFICATE_VERIFY_ERROR			 101
584 #define OCSP_R_DIGEST_ERR				 102
585 #define OCSP_R_ERROR_IN_NEXTUPDATE_FIELD		 122
586 #define OCSP_R_ERROR_IN_THISUPDATE_FIELD		 123
587 #define OCSP_R_ERROR_PARSING_URL			 121
588 #define OCSP_R_MISSING_OCSPSIGNING_USAGE		 103
589 #define OCSP_R_NEXTUPDATE_BEFORE_THISUPDATE		 124
590 #define OCSP_R_NOT_BASIC_RESPONSE			 104
591 #define OCSP_R_NO_CERTIFICATES_IN_CHAIN			 105
592 #define OCSP_R_NO_CONTENT				 106
593 #define OCSP_R_NO_PUBLIC_KEY				 107
594 #define OCSP_R_NO_RESPONSE_DATA				 108
595 #define OCSP_R_NO_REVOKED_TIME				 109
596 #define OCSP_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE	 110
597 #define OCSP_R_REQUEST_NOT_SIGNED			 128
598 #define OCSP_R_RESPONSE_CONTAINS_NO_REVOCATION_DATA	 111
599 #define OCSP_R_ROOT_CA_NOT_TRUSTED			 112
600 #define OCSP_R_SERVER_READ_ERROR			 113
601 #define OCSP_R_SERVER_RESPONSE_ERROR			 114
602 #define OCSP_R_SERVER_RESPONSE_PARSE_ERROR		 115
603 #define OCSP_R_SERVER_WRITE_ERROR			 116
604 #define OCSP_R_SIGNATURE_FAILURE			 117
605 #define OCSP_R_SIGNER_CERTIFICATE_NOT_FOUND		 118
606 #define OCSP_R_STATUS_EXPIRED				 125
607 #define OCSP_R_STATUS_NOT_YET_VALID			 126
608 #define OCSP_R_STATUS_TOO_OLD				 127
609 #define OCSP_R_UNKNOWN_MESSAGE_DIGEST			 119
610 #define OCSP_R_UNKNOWN_NID				 120
611 #define OCSP_R_UNSUPPORTED_REQUESTORNAME_TYPE		 129
612 
613 #ifdef  __cplusplus
614 }
615 #endif
616 #endif
617