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