xref: /openbsd-src/lib/libcrypto/ocsp/ocsp.h (revision f2da64fbbbf1b03f09f390ab01267c93dfd77c4c)
1 /* $OpenBSD: ocsp.h,v 1.8 2016/09/04 17:18:18 jsing 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 OCSP_RESPID *OCSP_RESPID_new(void);
205 void OCSP_RESPID_free(OCSP_RESPID *a);
206 OCSP_RESPID *d2i_OCSP_RESPID(OCSP_RESPID **a, const unsigned char **in, long len);
207 int i2d_OCSP_RESPID(OCSP_RESPID *a, unsigned char **out);
208 extern const ASN1_ITEM OCSP_RESPID_it;
209 
210 /*   KeyHash ::= OCTET STRING --SHA-1 hash of responder's public key
211  *                            --(excluding the tag and length fields)
212  */
213 
214 /*   RevokedInfo ::= SEQUENCE {
215  *       revocationTime              GeneralizedTime,
216  *       revocationReason    [0]     EXPLICIT CRLReason OPTIONAL }
217  */
218 typedef struct ocsp_revoked_info_st {
219 	ASN1_GENERALIZEDTIME *revocationTime;
220 	ASN1_ENUMERATED *revocationReason;
221 } OCSP_REVOKEDINFO;
222 
223 /*   CertStatus ::= CHOICE {
224  *       good                [0]     IMPLICIT NULL,
225  *       revoked             [1]     IMPLICIT RevokedInfo,
226  *       unknown             [2]     IMPLICIT UnknownInfo }
227  */
228 #define V_OCSP_CERTSTATUS_GOOD    0
229 #define V_OCSP_CERTSTATUS_REVOKED 1
230 #define V_OCSP_CERTSTATUS_UNKNOWN 2
231 typedef struct ocsp_cert_status_st {
232 	int type;
233 	union {
234 		ASN1_NULL *good;
235 		OCSP_REVOKEDINFO *revoked;
236 		ASN1_NULL *unknown;
237 	} value;
238 } OCSP_CERTSTATUS;
239 
240 /*   SingleResponse ::= SEQUENCE {
241  *      certID                       CertID,
242  *      certStatus                   CertStatus,
243  *      thisUpdate                   GeneralizedTime,
244  *      nextUpdate           [0]     EXPLICIT GeneralizedTime OPTIONAL,
245  *      singleExtensions     [1]     EXPLICIT Extensions OPTIONAL }
246  */
247 typedef struct ocsp_single_response_st {
248 	OCSP_CERTID *certId;
249 	OCSP_CERTSTATUS *certStatus;
250 	ASN1_GENERALIZEDTIME *thisUpdate;
251 	ASN1_GENERALIZEDTIME *nextUpdate;
252 	STACK_OF(X509_EXTENSION) *singleExtensions;
253 } OCSP_SINGLERESP;
254 
255 DECLARE_STACK_OF(OCSP_SINGLERESP)
256 DECLARE_ASN1_SET_OF(OCSP_SINGLERESP)
257 
258 /*   ResponseData ::= SEQUENCE {
259  *      version              [0] EXPLICIT Version DEFAULT v1,
260  *      responderID              ResponderID,
261  *      producedAt               GeneralizedTime,
262  *      responses                SEQUENCE OF SingleResponse,
263  *      responseExtensions   [1] EXPLICIT Extensions OPTIONAL }
264  */
265 typedef struct ocsp_response_data_st {
266 	ASN1_INTEGER *version;
267 	OCSP_RESPID  *responderId;
268 	ASN1_GENERALIZEDTIME *producedAt;
269 	STACK_OF(OCSP_SINGLERESP) *responses;
270 	STACK_OF(X509_EXTENSION) *responseExtensions;
271 } OCSP_RESPDATA;
272 
273 /*   BasicOCSPResponse       ::= SEQUENCE {
274  *      tbsResponseData      ResponseData,
275  *      signatureAlgorithm   AlgorithmIdentifier,
276  *      signature            BIT STRING,
277  *      certs                [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }
278  */
279   /* Note 1:
280      The value for "signature" is specified in the OCSP rfc2560 as follows:
281      "The value for the signature SHALL be computed on the hash of the DER
282      encoding ResponseData."  This means that you must hash the DER-encoded
283      tbsResponseData, and then run it through a crypto-signing function, which
284      will (at least w/RSA) do a hash-'n'-private-encrypt operation.  This seems
285      a bit odd, but that's the spec.  Also note that the data structures do not
286      leave anywhere to independently specify the algorithm used for the initial
287      hash. So, we look at the signature-specification algorithm, and try to do
288      something intelligent.	-- Kathy Weinhold, CertCo */
289   /* Note 2:
290      It seems that the mentioned passage from RFC 2560 (section 4.2.1) is open
291      for interpretation.  I've done tests against another responder, and found
292      that it doesn't do the double hashing that the RFC seems to say one
293      should.  Therefore, all relevant functions take a flag saying which
294      variant should be used.	-- Richard Levitte, OpenSSL team and CeloCom */
295 typedef struct ocsp_basic_response_st {
296 	OCSP_RESPDATA *tbsResponseData;
297 	X509_ALGOR *signatureAlgorithm;
298 	ASN1_BIT_STRING *signature;
299 	STACK_OF(X509) *certs;
300 } OCSP_BASICRESP;
301 
302 /*
303  *   CRLReason ::= ENUMERATED {
304  *        unspecified             (0),
305  *        keyCompromise           (1),
306  *        cACompromise            (2),
307  *        affiliationChanged      (3),
308  *        superseded              (4),
309  *        cessationOfOperation    (5),
310  *        certificateHold         (6),
311  *        removeFromCRL           (8) }
312  */
313 #define OCSP_REVOKED_STATUS_NOSTATUS			-1
314 #define OCSP_REVOKED_STATUS_UNSPECIFIED			0
315 #define OCSP_REVOKED_STATUS_KEYCOMPROMISE		1
316 #define OCSP_REVOKED_STATUS_CACOMPROMISE		2
317 #define OCSP_REVOKED_STATUS_AFFILIATIONCHANGED		3
318 #define OCSP_REVOKED_STATUS_SUPERSEDED			4
319 #define OCSP_REVOKED_STATUS_CESSATIONOFOPERATION	5
320 #define OCSP_REVOKED_STATUS_CERTIFICATEHOLD		6
321 #define OCSP_REVOKED_STATUS_REMOVEFROMCRL		8
322 
323 /* CrlID ::= SEQUENCE {
324  *     crlUrl               [0]     EXPLICIT IA5String OPTIONAL,
325  *     crlNum               [1]     EXPLICIT INTEGER OPTIONAL,
326  *     crlTime              [2]     EXPLICIT GeneralizedTime OPTIONAL }
327  */
328 typedef struct ocsp_crl_id_st {
329 	ASN1_IA5STRING *crlUrl;
330 	ASN1_INTEGER *crlNum;
331 	ASN1_GENERALIZEDTIME *crlTime;
332 } OCSP_CRLID;
333 
334 /* ServiceLocator ::= SEQUENCE {
335  *      issuer    Name,
336  *      locator   AuthorityInfoAccessSyntax OPTIONAL }
337  */
338 typedef struct ocsp_service_locator_st {
339 	X509_NAME* issuer;
340 	STACK_OF(ACCESS_DESCRIPTION) *locator;
341 } OCSP_SERVICELOC;
342 
343 #define PEM_STRING_OCSP_REQUEST	"OCSP REQUEST"
344 #define PEM_STRING_OCSP_RESPONSE "OCSP RESPONSE"
345 
346 #define d2i_OCSP_REQUEST_bio(bp,p) \
347     ASN1_d2i_bio_of(OCSP_REQUEST,OCSP_REQUEST_new,d2i_OCSP_REQUEST,bp,p)
348 
349 #define d2i_OCSP_RESPONSE_bio(bp,p) \
350     ASN1_d2i_bio_of(OCSP_RESPONSE,OCSP_RESPONSE_new,d2i_OCSP_RESPONSE,bp,p)
351 
352 #define	PEM_read_bio_OCSP_REQUEST(bp,x,cb) \
353     (OCSP_REQUEST *)PEM_ASN1_read_bio((char *(*)())d2i_OCSP_REQUEST, \
354 	PEM_STRING_OCSP_REQUEST,bp,(char **)x,cb,NULL)
355 
356 #define	PEM_read_bio_OCSP_RESPONSE(bp,x,cb) \
357     (OCSP_RESPONSE *)PEM_ASN1_read_bio((char *(*)())d2i_OCSP_RESPONSE, \
358 	PEM_STRING_OCSP_RESPONSE,bp,(char **)x,cb,NULL)
359 
360 #define PEM_write_bio_OCSP_REQUEST(bp,o) \
361     PEM_ASN1_write_bio((int (*)())i2d_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,\
362 	bp,(char *)o, NULL,NULL,0,NULL,NULL)
363 
364 #define PEM_write_bio_OCSP_RESPONSE(bp,o) \
365     PEM_ASN1_write_bio((int (*)())i2d_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,\
366 	bp,(char *)o, NULL,NULL,0,NULL,NULL)
367 
368 #define i2d_OCSP_RESPONSE_bio(bp,o) \
369     ASN1_i2d_bio_of(OCSP_RESPONSE,i2d_OCSP_RESPONSE,bp,o)
370 
371 #define i2d_OCSP_REQUEST_bio(bp,o) \
372     ASN1_i2d_bio_of(OCSP_REQUEST,i2d_OCSP_REQUEST,bp,o)
373 
374 #define OCSP_REQUEST_sign(o,pkey,md) \
375     ASN1_item_sign(ASN1_ITEM_rptr(OCSP_REQINFO), \
376 	o->optionalSignature->signatureAlgorithm,NULL, \
377 	o->optionalSignature->signature,o->tbsRequest,pkey,md)
378 
379 #define OCSP_BASICRESP_sign(o,pkey,md,d) \
380     ASN1_item_sign(ASN1_ITEM_rptr(OCSP_RESPDATA),o->signatureAlgorithm,NULL, \
381 	o->signature,o->tbsResponseData,pkey,md)
382 
383 #define OCSP_REQUEST_verify(a,r) \
384     ASN1_item_verify(ASN1_ITEM_rptr(OCSP_REQINFO), \
385 	a->optionalSignature->signatureAlgorithm, \
386 	a->optionalSignature->signature,a->tbsRequest,r)
387 
388 #define OCSP_BASICRESP_verify(a,r,d) \
389     ASN1_item_verify(ASN1_ITEM_rptr(OCSP_RESPDATA), \
390 	a->signatureAlgorithm,a->signature,a->tbsResponseData,r)
391 
392 #define ASN1_BIT_STRING_digest(data,type,md,len) \
393     ASN1_item_digest(ASN1_ITEM_rptr(ASN1_BIT_STRING),type,data,md,len)
394 
395 #define OCSP_CERTSTATUS_dup(cs) \
396 	ASN1_item_dup(&OCSP_CERTSTATUS_it, cs)
397 
398 OCSP_CERTID *OCSP_CERTID_dup(OCSP_CERTID *id);
399 
400 OCSP_RESPONSE *OCSP_sendreq_bio(BIO *b, char *path, OCSP_REQUEST *req);
401 OCSP_REQ_CTX *OCSP_sendreq_new(BIO *io, char *path, OCSP_REQUEST *req,
402 	    int maxline);
403 int	OCSP_sendreq_nbio(OCSP_RESPONSE **presp, OCSP_REQ_CTX *rctx);
404 void	OCSP_REQ_CTX_free(OCSP_REQ_CTX *rctx);
405 int	OCSP_REQ_CTX_set1_req(OCSP_REQ_CTX *rctx, OCSP_REQUEST *req);
406 int	OCSP_REQ_CTX_add1_header(OCSP_REQ_CTX *rctx, const char *name,
407 	    const char *value);
408 
409 OCSP_CERTID *OCSP_cert_to_id(const EVP_MD *dgst, X509 *subject, X509 *issuer);
410 
411 OCSP_CERTID *OCSP_cert_id_new(const EVP_MD *dgst, X509_NAME *issuerName,
412 	    ASN1_BIT_STRING* issuerKey, ASN1_INTEGER *serialNumber);
413 
414 OCSP_ONEREQ *OCSP_request_add0_id(OCSP_REQUEST *req, OCSP_CERTID *cid);
415 
416 int	OCSP_request_add1_nonce(OCSP_REQUEST *req, unsigned char *val, int len);
417 int	OCSP_basic_add1_nonce(OCSP_BASICRESP *resp, unsigned char *val, int len);
418 int	OCSP_check_nonce(OCSP_REQUEST *req, OCSP_BASICRESP *bs);
419 int	OCSP_copy_nonce(OCSP_BASICRESP *resp, OCSP_REQUEST *req);
420 
421 int	OCSP_request_set1_name(OCSP_REQUEST *req, X509_NAME *nm);
422 int	OCSP_request_add1_cert(OCSP_REQUEST *req, X509 *cert);
423 
424 int	OCSP_request_sign(OCSP_REQUEST *req, X509 *signer, EVP_PKEY *key,
425 	    const EVP_MD *dgst, STACK_OF(X509) *certs, unsigned long flags);
426 
427 int	OCSP_response_status(OCSP_RESPONSE *resp);
428 OCSP_BASICRESP *OCSP_response_get1_basic(OCSP_RESPONSE *resp);
429 
430 int	OCSP_resp_count(OCSP_BASICRESP *bs);
431 OCSP_SINGLERESP *OCSP_resp_get0(OCSP_BASICRESP *bs, int idx);
432 int	OCSP_resp_find(OCSP_BASICRESP *bs, OCSP_CERTID *id, int last);
433 int	OCSP_single_get0_status(OCSP_SINGLERESP *single, int *reason,
434 	    ASN1_GENERALIZEDTIME **revtime, ASN1_GENERALIZEDTIME **thisupd,
435 	    ASN1_GENERALIZEDTIME **nextupd);
436 int	OCSP_resp_find_status(OCSP_BASICRESP *bs, OCSP_CERTID *id, int *status,
437 	    int *reason, ASN1_GENERALIZEDTIME **revtime,
438 	    ASN1_GENERALIZEDTIME **thisupd, ASN1_GENERALIZEDTIME **nextupd);
439 int	OCSP_check_validity(ASN1_GENERALIZEDTIME *thisupd,
440 	    ASN1_GENERALIZEDTIME *nextupd, long sec, long maxsec);
441 
442 int	OCSP_request_verify(OCSP_REQUEST *req, STACK_OF(X509) *certs,
443 	    X509_STORE *store, unsigned long flags);
444 
445 int	OCSP_parse_url(char *url, char **phost, char **pport, char **ppath,
446 	    int *pssl);
447 
448 int	OCSP_id_issuer_cmp(OCSP_CERTID *a, OCSP_CERTID *b);
449 int	OCSP_id_cmp(OCSP_CERTID *a, OCSP_CERTID *b);
450 
451 int	OCSP_request_onereq_count(OCSP_REQUEST *req);
452 OCSP_ONEREQ *OCSP_request_onereq_get0(OCSP_REQUEST *req, int i);
453 OCSP_CERTID *OCSP_onereq_get0_id(OCSP_ONEREQ *one);
454 int	OCSP_id_get0_info(ASN1_OCTET_STRING **piNameHash, ASN1_OBJECT **pmd,
455 	    ASN1_OCTET_STRING **pikeyHash, ASN1_INTEGER **pserial,
456 	    OCSP_CERTID *cid);
457 int	OCSP_request_is_signed(OCSP_REQUEST *req);
458 OCSP_RESPONSE *OCSP_response_create(int status, OCSP_BASICRESP *bs);
459 OCSP_SINGLERESP *OCSP_basic_add1_status(OCSP_BASICRESP *rsp, OCSP_CERTID *cid,
460 	    int status, int reason, ASN1_TIME *revtime, ASN1_TIME *thisupd,
461 	    ASN1_TIME *nextupd);
462 int	OCSP_basic_add1_cert(OCSP_BASICRESP *resp, X509 *cert);
463 int	OCSP_basic_sign(OCSP_BASICRESP *brsp, X509 *signer, EVP_PKEY *key,
464 	    const EVP_MD *dgst, STACK_OF(X509) *certs, unsigned long flags);
465 
466 X509_EXTENSION *OCSP_crlID_new(char *url, long *n, char *tim);
467 
468 X509_EXTENSION *OCSP_accept_responses_new(char **oids);
469 
470 X509_EXTENSION *OCSP_archive_cutoff_new(char* tim);
471 
472 X509_EXTENSION *OCSP_url_svcloc_new(X509_NAME* issuer, char **urls);
473 
474 int	OCSP_REQUEST_get_ext_count(OCSP_REQUEST *x);
475 int	OCSP_REQUEST_get_ext_by_NID(OCSP_REQUEST *x, int nid, int lastpos);
476 int	OCSP_REQUEST_get_ext_by_OBJ(OCSP_REQUEST *x, ASN1_OBJECT *obj,
477 	    int lastpos);
478 int	OCSP_REQUEST_get_ext_by_critical(OCSP_REQUEST *x, int crit,
479 	    int lastpos);
480 X509_EXTENSION *OCSP_REQUEST_get_ext(OCSP_REQUEST *x, int loc);
481 X509_EXTENSION *OCSP_REQUEST_delete_ext(OCSP_REQUEST *x, int loc);
482 void *OCSP_REQUEST_get1_ext_d2i(OCSP_REQUEST *x, int nid, int *crit, int *idx);
483 int	OCSP_REQUEST_add1_ext_i2d(OCSP_REQUEST *x, int nid, void *value,
484 	    int crit, unsigned long flags);
485 int	OCSP_REQUEST_add_ext(OCSP_REQUEST *x, X509_EXTENSION *ex, int loc);
486 
487 int	OCSP_ONEREQ_get_ext_count(OCSP_ONEREQ *x);
488 int	OCSP_ONEREQ_get_ext_by_NID(OCSP_ONEREQ *x, int nid, int lastpos);
489 int	OCSP_ONEREQ_get_ext_by_OBJ(OCSP_ONEREQ *x, ASN1_OBJECT *obj,
490 	    int lastpos);
491 int	OCSP_ONEREQ_get_ext_by_critical(OCSP_ONEREQ *x, int crit, int lastpos);
492 X509_EXTENSION *OCSP_ONEREQ_get_ext(OCSP_ONEREQ *x, int loc);
493 X509_EXTENSION *OCSP_ONEREQ_delete_ext(OCSP_ONEREQ *x, int loc);
494 void *OCSP_ONEREQ_get1_ext_d2i(OCSP_ONEREQ *x, int nid, int *crit, int *idx);
495 int	OCSP_ONEREQ_add1_ext_i2d(OCSP_ONEREQ *x, int nid, void *value, int crit,
496 	    unsigned long flags);
497 int	OCSP_ONEREQ_add_ext(OCSP_ONEREQ *x, X509_EXTENSION *ex, int loc);
498 
499 int	OCSP_BASICRESP_get_ext_count(OCSP_BASICRESP *x);
500 int	OCSP_BASICRESP_get_ext_by_NID(OCSP_BASICRESP *x, int nid, int lastpos);
501 int	OCSP_BASICRESP_get_ext_by_OBJ(OCSP_BASICRESP *x, ASN1_OBJECT *obj,
502 	    int lastpos);
503 int	OCSP_BASICRESP_get_ext_by_critical(OCSP_BASICRESP *x, int crit,
504 	    int lastpos);
505 X509_EXTENSION *OCSP_BASICRESP_get_ext(OCSP_BASICRESP *x, int loc);
506 X509_EXTENSION *OCSP_BASICRESP_delete_ext(OCSP_BASICRESP *x, int loc);
507 void *OCSP_BASICRESP_get1_ext_d2i(OCSP_BASICRESP *x, int nid, int *crit,
508 	    int *idx);
509 int	OCSP_BASICRESP_add1_ext_i2d(OCSP_BASICRESP *x, int nid, void *value,
510 	    int crit, unsigned long flags);
511 int	OCSP_BASICRESP_add_ext(OCSP_BASICRESP *x, X509_EXTENSION *ex, int loc);
512 
513 int	OCSP_SINGLERESP_get_ext_count(OCSP_SINGLERESP *x);
514 int	OCSP_SINGLERESP_get_ext_by_NID(OCSP_SINGLERESP *x, int nid,
515 	    int lastpos);
516 int	OCSP_SINGLERESP_get_ext_by_OBJ(OCSP_SINGLERESP *x, ASN1_OBJECT *obj,
517 	    int lastpos);
518 int	OCSP_SINGLERESP_get_ext_by_critical(OCSP_SINGLERESP *x, int crit,
519 	    int lastpos);
520 X509_EXTENSION *OCSP_SINGLERESP_get_ext(OCSP_SINGLERESP *x, int loc);
521 X509_EXTENSION *OCSP_SINGLERESP_delete_ext(OCSP_SINGLERESP *x, int loc);
522 void *OCSP_SINGLERESP_get1_ext_d2i(OCSP_SINGLERESP *x, int nid, int *crit,
523 	    int *idx);
524 int	OCSP_SINGLERESP_add1_ext_i2d(OCSP_SINGLERESP *x, int nid, void *value,
525 	    int crit, unsigned long flags);
526 int	OCSP_SINGLERESP_add_ext(OCSP_SINGLERESP *x, X509_EXTENSION *ex,
527 	    int loc);
528 
529 OCSP_SINGLERESP *OCSP_SINGLERESP_new(void);
530 void OCSP_SINGLERESP_free(OCSP_SINGLERESP *a);
531 OCSP_SINGLERESP *d2i_OCSP_SINGLERESP(OCSP_SINGLERESP **a, const unsigned char **in, long len);
532 int i2d_OCSP_SINGLERESP(OCSP_SINGLERESP *a, unsigned char **out);
533 extern const ASN1_ITEM OCSP_SINGLERESP_it;
534 OCSP_CERTSTATUS *OCSP_CERTSTATUS_new(void);
535 void OCSP_CERTSTATUS_free(OCSP_CERTSTATUS *a);
536 OCSP_CERTSTATUS *d2i_OCSP_CERTSTATUS(OCSP_CERTSTATUS **a, const unsigned char **in, long len);
537 int i2d_OCSP_CERTSTATUS(OCSP_CERTSTATUS *a, unsigned char **out);
538 extern const ASN1_ITEM OCSP_CERTSTATUS_it;
539 OCSP_REVOKEDINFO *OCSP_REVOKEDINFO_new(void);
540 void OCSP_REVOKEDINFO_free(OCSP_REVOKEDINFO *a);
541 OCSP_REVOKEDINFO *d2i_OCSP_REVOKEDINFO(OCSP_REVOKEDINFO **a, const unsigned char **in, long len);
542 int i2d_OCSP_REVOKEDINFO(OCSP_REVOKEDINFO *a, unsigned char **out);
543 extern const ASN1_ITEM OCSP_REVOKEDINFO_it;
544 OCSP_BASICRESP *OCSP_BASICRESP_new(void);
545 void OCSP_BASICRESP_free(OCSP_BASICRESP *a);
546 OCSP_BASICRESP *d2i_OCSP_BASICRESP(OCSP_BASICRESP **a, const unsigned char **in, long len);
547 int i2d_OCSP_BASICRESP(OCSP_BASICRESP *a, unsigned char **out);
548 extern const ASN1_ITEM OCSP_BASICRESP_it;
549 OCSP_RESPDATA *OCSP_RESPDATA_new(void);
550 void OCSP_RESPDATA_free(OCSP_RESPDATA *a);
551 OCSP_RESPDATA *d2i_OCSP_RESPDATA(OCSP_RESPDATA **a, const unsigned char **in, long len);
552 int i2d_OCSP_RESPDATA(OCSP_RESPDATA *a, unsigned char **out);
553 extern const ASN1_ITEM OCSP_RESPDATA_it;
554 OCSP_RESPID *OCSP_RESPID_new(void);
555 void OCSP_RESPID_free(OCSP_RESPID *a);
556 OCSP_RESPID *d2i_OCSP_RESPID(OCSP_RESPID **a, const unsigned char **in, long len);
557 int i2d_OCSP_RESPID(OCSP_RESPID *a, unsigned char **out);
558 extern const ASN1_ITEM OCSP_RESPID_it;
559 OCSP_RESPONSE *OCSP_RESPONSE_new(void);
560 void OCSP_RESPONSE_free(OCSP_RESPONSE *a);
561 OCSP_RESPONSE *d2i_OCSP_RESPONSE(OCSP_RESPONSE **a, const unsigned char **in, long len);
562 int i2d_OCSP_RESPONSE(OCSP_RESPONSE *a, unsigned char **out);
563 extern const ASN1_ITEM OCSP_RESPONSE_it;
564 OCSP_RESPBYTES *OCSP_RESPBYTES_new(void);
565 void OCSP_RESPBYTES_free(OCSP_RESPBYTES *a);
566 OCSP_RESPBYTES *d2i_OCSP_RESPBYTES(OCSP_RESPBYTES **a, const unsigned char **in, long len);
567 int i2d_OCSP_RESPBYTES(OCSP_RESPBYTES *a, unsigned char **out);
568 extern const ASN1_ITEM OCSP_RESPBYTES_it;
569 OCSP_ONEREQ *OCSP_ONEREQ_new(void);
570 void OCSP_ONEREQ_free(OCSP_ONEREQ *a);
571 OCSP_ONEREQ *d2i_OCSP_ONEREQ(OCSP_ONEREQ **a, const unsigned char **in, long len);
572 int i2d_OCSP_ONEREQ(OCSP_ONEREQ *a, unsigned char **out);
573 extern const ASN1_ITEM OCSP_ONEREQ_it;
574 OCSP_CERTID *OCSP_CERTID_new(void);
575 void OCSP_CERTID_free(OCSP_CERTID *a);
576 OCSP_CERTID *d2i_OCSP_CERTID(OCSP_CERTID **a, const unsigned char **in, long len);
577 int i2d_OCSP_CERTID(OCSP_CERTID *a, unsigned char **out);
578 extern const ASN1_ITEM OCSP_CERTID_it;
579 OCSP_REQUEST *OCSP_REQUEST_new(void);
580 void OCSP_REQUEST_free(OCSP_REQUEST *a);
581 OCSP_REQUEST *d2i_OCSP_REQUEST(OCSP_REQUEST **a, const unsigned char **in, long len);
582 int i2d_OCSP_REQUEST(OCSP_REQUEST *a, unsigned char **out);
583 extern const ASN1_ITEM OCSP_REQUEST_it;
584 OCSP_SIGNATURE *OCSP_SIGNATURE_new(void);
585 void OCSP_SIGNATURE_free(OCSP_SIGNATURE *a);
586 OCSP_SIGNATURE *d2i_OCSP_SIGNATURE(OCSP_SIGNATURE **a, const unsigned char **in, long len);
587 int i2d_OCSP_SIGNATURE(OCSP_SIGNATURE *a, unsigned char **out);
588 extern const ASN1_ITEM OCSP_SIGNATURE_it;
589 OCSP_REQINFO *OCSP_REQINFO_new(void);
590 void OCSP_REQINFO_free(OCSP_REQINFO *a);
591 OCSP_REQINFO *d2i_OCSP_REQINFO(OCSP_REQINFO **a, const unsigned char **in, long len);
592 int i2d_OCSP_REQINFO(OCSP_REQINFO *a, unsigned char **out);
593 extern const ASN1_ITEM OCSP_REQINFO_it;
594 OCSP_CRLID *OCSP_CRLID_new(void);
595 void OCSP_CRLID_free(OCSP_CRLID *a);
596 OCSP_CRLID *d2i_OCSP_CRLID(OCSP_CRLID **a, const unsigned char **in, long len);
597 int i2d_OCSP_CRLID(OCSP_CRLID *a, unsigned char **out);
598 extern const ASN1_ITEM OCSP_CRLID_it;
599 OCSP_SERVICELOC *OCSP_SERVICELOC_new(void);
600 void OCSP_SERVICELOC_free(OCSP_SERVICELOC *a);
601 OCSP_SERVICELOC *d2i_OCSP_SERVICELOC(OCSP_SERVICELOC **a, const unsigned char **in, long len);
602 int i2d_OCSP_SERVICELOC(OCSP_SERVICELOC *a, unsigned char **out);
603 extern const ASN1_ITEM OCSP_SERVICELOC_it;
604 
605 const char *OCSP_response_status_str(long s);
606 const char *OCSP_cert_status_str(long s);
607 const char *OCSP_crl_reason_str(long s);
608 
609 int	OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST* a, unsigned long flags);
610 int	OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE* o, unsigned long flags);
611 
612 int	OCSP_basic_verify(OCSP_BASICRESP *bs, STACK_OF(X509) *certs,
613 	    X509_STORE *st, unsigned long flags);
614 
615 /* BEGIN ERROR CODES */
616 /* The following lines are auto generated by the script mkerr.pl. Any changes
617  * made after this point may be overwritten when the script is next run.
618  */
619 void ERR_load_OCSP_strings(void);
620 
621 /* Error codes for the OCSP functions. */
622 
623 /* Function codes. */
624 #define OCSP_F_ASN1_STRING_ENCODE			 100
625 #define OCSP_F_D2I_OCSP_NONCE				 102
626 #define OCSP_F_OCSP_BASIC_ADD1_STATUS			 103
627 #define OCSP_F_OCSP_BASIC_SIGN				 104
628 #define OCSP_F_OCSP_BASIC_VERIFY			 105
629 #define OCSP_F_OCSP_CERT_ID_NEW				 101
630 #define OCSP_F_OCSP_CHECK_DELEGATED			 106
631 #define OCSP_F_OCSP_CHECK_IDS				 107
632 #define OCSP_F_OCSP_CHECK_ISSUER			 108
633 #define OCSP_F_OCSP_CHECK_VALIDITY			 115
634 #define OCSP_F_OCSP_MATCH_ISSUERID			 109
635 #define OCSP_F_OCSP_PARSE_URL				 114
636 #define OCSP_F_OCSP_REQUEST_SIGN			 110
637 #define OCSP_F_OCSP_REQUEST_VERIFY			 116
638 #define OCSP_F_OCSP_RESPONSE_GET1_BASIC			 111
639 #define OCSP_F_OCSP_SENDREQ_BIO				 112
640 #define OCSP_F_OCSP_SENDREQ_NBIO			 117
641 #define OCSP_F_PARSE_HTTP_LINE1				 118
642 #define OCSP_F_REQUEST_VERIFY				 113
643 
644 /* Reason codes. */
645 #define OCSP_R_BAD_DATA					 100
646 #define OCSP_R_CERTIFICATE_VERIFY_ERROR			 101
647 #define OCSP_R_DIGEST_ERR				 102
648 #define OCSP_R_ERROR_IN_NEXTUPDATE_FIELD		 122
649 #define OCSP_R_ERROR_IN_THISUPDATE_FIELD		 123
650 #define OCSP_R_ERROR_PARSING_URL			 121
651 #define OCSP_R_MISSING_OCSPSIGNING_USAGE		 103
652 #define OCSP_R_NEXTUPDATE_BEFORE_THISUPDATE		 124
653 #define OCSP_R_NOT_BASIC_RESPONSE			 104
654 #define OCSP_R_NO_CERTIFICATES_IN_CHAIN			 105
655 #define OCSP_R_NO_CONTENT				 106
656 #define OCSP_R_NO_PUBLIC_KEY				 107
657 #define OCSP_R_NO_RESPONSE_DATA				 108
658 #define OCSP_R_NO_REVOKED_TIME				 109
659 #define OCSP_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE	 110
660 #define OCSP_R_REQUEST_NOT_SIGNED			 128
661 #define OCSP_R_RESPONSE_CONTAINS_NO_REVOCATION_DATA	 111
662 #define OCSP_R_ROOT_CA_NOT_TRUSTED			 112
663 #define OCSP_R_SERVER_READ_ERROR			 113
664 #define OCSP_R_SERVER_RESPONSE_ERROR			 114
665 #define OCSP_R_SERVER_RESPONSE_PARSE_ERROR		 115
666 #define OCSP_R_SERVER_WRITE_ERROR			 116
667 #define OCSP_R_SIGNATURE_FAILURE			 117
668 #define OCSP_R_SIGNER_CERTIFICATE_NOT_FOUND		 118
669 #define OCSP_R_STATUS_EXPIRED				 125
670 #define OCSP_R_STATUS_NOT_YET_VALID			 126
671 #define OCSP_R_STATUS_TOO_OLD				 127
672 #define OCSP_R_UNKNOWN_MESSAGE_DIGEST			 119
673 #define OCSP_R_UNKNOWN_NID				 120
674 #define OCSP_R_UNSUPPORTED_REQUESTORNAME_TYPE		 129
675 
676 #ifdef  __cplusplus
677 }
678 #endif
679 #endif
680