1 /* $OpenBSD: ocsp.h,v 1.16 2018/08/24 20:03:21 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 int	OCSP_resp_count(OCSP_BASICRESP *bs);
418 OCSP_SINGLERESP *OCSP_resp_get0(OCSP_BASICRESP *bs, int idx);
419 int	OCSP_resp_find(OCSP_BASICRESP *bs, OCSP_CERTID *id, int last);
420 int	OCSP_single_get0_status(OCSP_SINGLERESP *single, int *reason,
421 	    ASN1_GENERALIZEDTIME **revtime, ASN1_GENERALIZEDTIME **thisupd,
422 	    ASN1_GENERALIZEDTIME **nextupd);
423 int	OCSP_resp_find_status(OCSP_BASICRESP *bs, OCSP_CERTID *id, int *status,
424 	    int *reason, ASN1_GENERALIZEDTIME **revtime,
425 	    ASN1_GENERALIZEDTIME **thisupd, ASN1_GENERALIZEDTIME **nextupd);
426 int	OCSP_check_validity(ASN1_GENERALIZEDTIME *thisupd,
427 	    ASN1_GENERALIZEDTIME *nextupd, long sec, long maxsec);
428 
429 int	OCSP_request_verify(OCSP_REQUEST *req, STACK_OF(X509) *certs,
430 	    X509_STORE *store, unsigned long flags);
431 
432 int	OCSP_parse_url(const char *url, char **phost, char **pport,
433 	    char **ppath, int *pssl);
434 
435 int	OCSP_id_issuer_cmp(OCSP_CERTID *a, OCSP_CERTID *b);
436 int	OCSP_id_cmp(OCSP_CERTID *a, OCSP_CERTID *b);
437 
438 int	OCSP_request_onereq_count(OCSP_REQUEST *req);
439 OCSP_ONEREQ *OCSP_request_onereq_get0(OCSP_REQUEST *req, int i);
440 OCSP_CERTID *OCSP_onereq_get0_id(OCSP_ONEREQ *one);
441 int	OCSP_id_get0_info(ASN1_OCTET_STRING **piNameHash, ASN1_OBJECT **pmd,
442 	    ASN1_OCTET_STRING **pikeyHash, ASN1_INTEGER **pserial,
443 	    OCSP_CERTID *cid);
444 int	OCSP_request_is_signed(OCSP_REQUEST *req);
445 OCSP_RESPONSE *OCSP_response_create(int status, OCSP_BASICRESP *bs);
446 OCSP_SINGLERESP *OCSP_basic_add1_status(OCSP_BASICRESP *rsp, OCSP_CERTID *cid,
447 	    int status, int reason, ASN1_TIME *revtime, ASN1_TIME *thisupd,
448 	    ASN1_TIME *nextupd);
449 int	OCSP_basic_add1_cert(OCSP_BASICRESP *resp, X509 *cert);
450 int	OCSP_basic_sign(OCSP_BASICRESP *brsp, X509 *signer, EVP_PKEY *key,
451 	    const EVP_MD *dgst, STACK_OF(X509) *certs, unsigned long flags);
452 
453 X509_EXTENSION *OCSP_crlID_new(const char *url, long *n, char *tim);
454 
455 X509_EXTENSION *OCSP_accept_responses_new(char **oids);
456 
457 X509_EXTENSION *OCSP_archive_cutoff_new(char* tim);
458 
459 X509_EXTENSION *OCSP_url_svcloc_new(X509_NAME* issuer, const char **urls);
460 
461 int	OCSP_REQUEST_get_ext_count(OCSP_REQUEST *x);
462 int	OCSP_REQUEST_get_ext_by_NID(OCSP_REQUEST *x, int nid, int lastpos);
463 int	OCSP_REQUEST_get_ext_by_OBJ(OCSP_REQUEST *x, const ASN1_OBJECT *obj,
464 	    int lastpos);
465 int	OCSP_REQUEST_get_ext_by_critical(OCSP_REQUEST *x, int crit,
466 	    int lastpos);
467 X509_EXTENSION *OCSP_REQUEST_get_ext(OCSP_REQUEST *x, int loc);
468 X509_EXTENSION *OCSP_REQUEST_delete_ext(OCSP_REQUEST *x, int loc);
469 void *OCSP_REQUEST_get1_ext_d2i(OCSP_REQUEST *x, int nid, int *crit, int *idx);
470 int	OCSP_REQUEST_add1_ext_i2d(OCSP_REQUEST *x, int nid, void *value,
471 	    int crit, unsigned long flags);
472 int	OCSP_REQUEST_add_ext(OCSP_REQUEST *x, X509_EXTENSION *ex, int loc);
473 
474 int	OCSP_ONEREQ_get_ext_count(OCSP_ONEREQ *x);
475 int	OCSP_ONEREQ_get_ext_by_NID(OCSP_ONEREQ *x, int nid, int lastpos);
476 int	OCSP_ONEREQ_get_ext_by_OBJ(OCSP_ONEREQ *x, const ASN1_OBJECT *obj,
477 	    int lastpos);
478 int	OCSP_ONEREQ_get_ext_by_critical(OCSP_ONEREQ *x, int crit, int lastpos);
479 X509_EXTENSION *OCSP_ONEREQ_get_ext(OCSP_ONEREQ *x, int loc);
480 X509_EXTENSION *OCSP_ONEREQ_delete_ext(OCSP_ONEREQ *x, int loc);
481 void *OCSP_ONEREQ_get1_ext_d2i(OCSP_ONEREQ *x, int nid, int *crit, int *idx);
482 int	OCSP_ONEREQ_add1_ext_i2d(OCSP_ONEREQ *x, int nid, void *value, int crit,
483 	    unsigned long flags);
484 int	OCSP_ONEREQ_add_ext(OCSP_ONEREQ *x, X509_EXTENSION *ex, int loc);
485 
486 int	OCSP_BASICRESP_get_ext_count(OCSP_BASICRESP *x);
487 int	OCSP_BASICRESP_get_ext_by_NID(OCSP_BASICRESP *x, int nid, int lastpos);
488 int	OCSP_BASICRESP_get_ext_by_OBJ(OCSP_BASICRESP *x, const ASN1_OBJECT *obj,
489 	    int lastpos);
490 int	OCSP_BASICRESP_get_ext_by_critical(OCSP_BASICRESP *x, int crit,
491 	    int lastpos);
492 X509_EXTENSION *OCSP_BASICRESP_get_ext(OCSP_BASICRESP *x, int loc);
493 X509_EXTENSION *OCSP_BASICRESP_delete_ext(OCSP_BASICRESP *x, int loc);
494 void *OCSP_BASICRESP_get1_ext_d2i(OCSP_BASICRESP *x, int nid, int *crit,
495 	    int *idx);
496 int	OCSP_BASICRESP_add1_ext_i2d(OCSP_BASICRESP *x, int nid, void *value,
497 	    int crit, unsigned long flags);
498 int	OCSP_BASICRESP_add_ext(OCSP_BASICRESP *x, X509_EXTENSION *ex, int loc);
499 
500 int	OCSP_SINGLERESP_get_ext_count(OCSP_SINGLERESP *x);
501 int	OCSP_SINGLERESP_get_ext_by_NID(OCSP_SINGLERESP *x, int nid,
502 	    int lastpos);
503 int	OCSP_SINGLERESP_get_ext_by_OBJ(OCSP_SINGLERESP *x,
504 	    const ASN1_OBJECT *obj, int lastpos);
505 int	OCSP_SINGLERESP_get_ext_by_critical(OCSP_SINGLERESP *x, int crit,
506 	    int lastpos);
507 X509_EXTENSION *OCSP_SINGLERESP_get_ext(OCSP_SINGLERESP *x, int loc);
508 X509_EXTENSION *OCSP_SINGLERESP_delete_ext(OCSP_SINGLERESP *x, int loc);
509 void *OCSP_SINGLERESP_get1_ext_d2i(OCSP_SINGLERESP *x, int nid, int *crit,
510 	    int *idx);
511 int	OCSP_SINGLERESP_add1_ext_i2d(OCSP_SINGLERESP *x, int nid, void *value,
512 	    int crit, unsigned long flags);
513 int	OCSP_SINGLERESP_add_ext(OCSP_SINGLERESP *x, X509_EXTENSION *ex,
514 	    int loc);
515 const OCSP_CERTID *OCSP_SINGLERESP_get0_id(const OCSP_SINGLERESP *x);
516 
517 OCSP_SINGLERESP *OCSP_SINGLERESP_new(void);
518 void OCSP_SINGLERESP_free(OCSP_SINGLERESP *a);
519 OCSP_SINGLERESP *d2i_OCSP_SINGLERESP(OCSP_SINGLERESP **a, const unsigned char **in, long len);
520 int i2d_OCSP_SINGLERESP(OCSP_SINGLERESP *a, unsigned char **out);
521 extern const ASN1_ITEM OCSP_SINGLERESP_it;
522 OCSP_CERTSTATUS *OCSP_CERTSTATUS_new(void);
523 void OCSP_CERTSTATUS_free(OCSP_CERTSTATUS *a);
524 OCSP_CERTSTATUS *d2i_OCSP_CERTSTATUS(OCSP_CERTSTATUS **a, const unsigned char **in, long len);
525 int i2d_OCSP_CERTSTATUS(OCSP_CERTSTATUS *a, unsigned char **out);
526 extern const ASN1_ITEM OCSP_CERTSTATUS_it;
527 OCSP_REVOKEDINFO *OCSP_REVOKEDINFO_new(void);
528 void OCSP_REVOKEDINFO_free(OCSP_REVOKEDINFO *a);
529 OCSP_REVOKEDINFO *d2i_OCSP_REVOKEDINFO(OCSP_REVOKEDINFO **a, const unsigned char **in, long len);
530 int i2d_OCSP_REVOKEDINFO(OCSP_REVOKEDINFO *a, unsigned char **out);
531 extern const ASN1_ITEM OCSP_REVOKEDINFO_it;
532 OCSP_BASICRESP *OCSP_BASICRESP_new(void);
533 void OCSP_BASICRESP_free(OCSP_BASICRESP *a);
534 OCSP_BASICRESP *d2i_OCSP_BASICRESP(OCSP_BASICRESP **a, const unsigned char **in, long len);
535 int i2d_OCSP_BASICRESP(OCSP_BASICRESP *a, unsigned char **out);
536 extern const ASN1_ITEM OCSP_BASICRESP_it;
537 OCSP_RESPDATA *OCSP_RESPDATA_new(void);
538 void OCSP_RESPDATA_free(OCSP_RESPDATA *a);
539 OCSP_RESPDATA *d2i_OCSP_RESPDATA(OCSP_RESPDATA **a, const unsigned char **in, long len);
540 int i2d_OCSP_RESPDATA(OCSP_RESPDATA *a, unsigned char **out);
541 extern const ASN1_ITEM OCSP_RESPDATA_it;
542 OCSP_RESPID *OCSP_RESPID_new(void);
543 void OCSP_RESPID_free(OCSP_RESPID *a);
544 OCSP_RESPID *d2i_OCSP_RESPID(OCSP_RESPID **a, const unsigned char **in, long len);
545 int i2d_OCSP_RESPID(OCSP_RESPID *a, unsigned char **out);
546 extern const ASN1_ITEM OCSP_RESPID_it;
547 OCSP_RESPONSE *OCSP_RESPONSE_new(void);
548 void OCSP_RESPONSE_free(OCSP_RESPONSE *a);
549 OCSP_RESPONSE *d2i_OCSP_RESPONSE(OCSP_RESPONSE **a, const unsigned char **in, long len);
550 int i2d_OCSP_RESPONSE(OCSP_RESPONSE *a, unsigned char **out);
551 OCSP_RESPONSE *d2i_OCSP_RESPONSE_bio(BIO *bp, OCSP_RESPONSE **a);
552 int i2d_OCSP_RESPONSE_bio(BIO *bp, OCSP_RESPONSE *a);
553 extern const ASN1_ITEM OCSP_RESPONSE_it;
554 OCSP_RESPBYTES *OCSP_RESPBYTES_new(void);
555 void OCSP_RESPBYTES_free(OCSP_RESPBYTES *a);
556 OCSP_RESPBYTES *d2i_OCSP_RESPBYTES(OCSP_RESPBYTES **a, const unsigned char **in, long len);
557 int i2d_OCSP_RESPBYTES(OCSP_RESPBYTES *a, unsigned char **out);
558 extern const ASN1_ITEM OCSP_RESPBYTES_it;
559 OCSP_ONEREQ *OCSP_ONEREQ_new(void);
560 void OCSP_ONEREQ_free(OCSP_ONEREQ *a);
561 OCSP_ONEREQ *d2i_OCSP_ONEREQ(OCSP_ONEREQ **a, const unsigned char **in, long len);
562 int i2d_OCSP_ONEREQ(OCSP_ONEREQ *a, unsigned char **out);
563 extern const ASN1_ITEM OCSP_ONEREQ_it;
564 OCSP_CERTID *OCSP_CERTID_new(void);
565 void OCSP_CERTID_free(OCSP_CERTID *a);
566 OCSP_CERTID *d2i_OCSP_CERTID(OCSP_CERTID **a, const unsigned char **in, long len);
567 int i2d_OCSP_CERTID(OCSP_CERTID *a, unsigned char **out);
568 extern const ASN1_ITEM OCSP_CERTID_it;
569 OCSP_REQUEST *OCSP_REQUEST_new(void);
570 void OCSP_REQUEST_free(OCSP_REQUEST *a);
571 OCSP_REQUEST *d2i_OCSP_REQUEST(OCSP_REQUEST **a, const unsigned char **in, long len);
572 int i2d_OCSP_REQUEST(OCSP_REQUEST *a, unsigned char **out);
573 OCSP_REQUEST *d2i_OCSP_REQUEST_bio(BIO *bp, OCSP_REQUEST **a);
574 int i2d_OCSP_REQUEST_bio(BIO *bp, OCSP_REQUEST *a);
575 extern const ASN1_ITEM OCSP_REQUEST_it;
576 OCSP_SIGNATURE *OCSP_SIGNATURE_new(void);
577 void OCSP_SIGNATURE_free(OCSP_SIGNATURE *a);
578 OCSP_SIGNATURE *d2i_OCSP_SIGNATURE(OCSP_SIGNATURE **a, const unsigned char **in, long len);
579 int i2d_OCSP_SIGNATURE(OCSP_SIGNATURE *a, unsigned char **out);
580 extern const ASN1_ITEM OCSP_SIGNATURE_it;
581 OCSP_REQINFO *OCSP_REQINFO_new(void);
582 void OCSP_REQINFO_free(OCSP_REQINFO *a);
583 OCSP_REQINFO *d2i_OCSP_REQINFO(OCSP_REQINFO **a, const unsigned char **in, long len);
584 int i2d_OCSP_REQINFO(OCSP_REQINFO *a, unsigned char **out);
585 extern const ASN1_ITEM OCSP_REQINFO_it;
586 OCSP_CRLID *OCSP_CRLID_new(void);
587 void OCSP_CRLID_free(OCSP_CRLID *a);
588 OCSP_CRLID *d2i_OCSP_CRLID(OCSP_CRLID **a, const unsigned char **in, long len);
589 int i2d_OCSP_CRLID(OCSP_CRLID *a, unsigned char **out);
590 extern const ASN1_ITEM OCSP_CRLID_it;
591 OCSP_SERVICELOC *OCSP_SERVICELOC_new(void);
592 void OCSP_SERVICELOC_free(OCSP_SERVICELOC *a);
593 OCSP_SERVICELOC *d2i_OCSP_SERVICELOC(OCSP_SERVICELOC **a, const unsigned char **in, long len);
594 int i2d_OCSP_SERVICELOC(OCSP_SERVICELOC *a, unsigned char **out);
595 extern const ASN1_ITEM OCSP_SERVICELOC_it;
596 
597 const char *OCSP_response_status_str(long s);
598 const char *OCSP_cert_status_str(long s);
599 const char *OCSP_crl_reason_str(long s);
600 
601 int	OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST* a, unsigned long flags);
602 int	OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE* o, unsigned long flags);
603 
604 int	OCSP_basic_verify(OCSP_BASICRESP *bs, STACK_OF(X509) *certs,
605 	    X509_STORE *st, unsigned long flags);
606 
607 /* BEGIN ERROR CODES */
608 /* The following lines are auto generated by the script mkerr.pl. Any changes
609  * made after this point may be overwritten when the script is next run.
610  */
611 void ERR_load_OCSP_strings(void);
612 
613 /* Error codes for the OCSP functions. */
614 
615 /* Function codes. */
616 #define OCSP_F_ASN1_STRING_ENCODE			 100
617 #define OCSP_F_D2I_OCSP_NONCE				 102
618 #define OCSP_F_OCSP_BASIC_ADD1_STATUS			 103
619 #define OCSP_F_OCSP_BASIC_SIGN				 104
620 #define OCSP_F_OCSP_BASIC_VERIFY			 105
621 #define OCSP_F_OCSP_CERT_ID_NEW				 101
622 #define OCSP_F_OCSP_CHECK_DELEGATED			 106
623 #define OCSP_F_OCSP_CHECK_IDS				 107
624 #define OCSP_F_OCSP_CHECK_ISSUER			 108
625 #define OCSP_F_OCSP_CHECK_VALIDITY			 115
626 #define OCSP_F_OCSP_MATCH_ISSUERID			 109
627 #define OCSP_F_OCSP_PARSE_URL				 114
628 #define OCSP_F_OCSP_REQUEST_SIGN			 110
629 #define OCSP_F_OCSP_REQUEST_VERIFY			 116
630 #define OCSP_F_OCSP_RESPONSE_GET1_BASIC			 111
631 #define OCSP_F_OCSP_SENDREQ_BIO				 112
632 #define OCSP_F_OCSP_SENDREQ_NBIO			 117
633 #define OCSP_F_PARSE_HTTP_LINE1				 118
634 #define OCSP_F_REQUEST_VERIFY				 113
635 
636 /* Reason codes. */
637 #define OCSP_R_BAD_DATA					 100
638 #define OCSP_R_CERTIFICATE_VERIFY_ERROR			 101
639 #define OCSP_R_DIGEST_ERR				 102
640 #define OCSP_R_ERROR_IN_NEXTUPDATE_FIELD		 122
641 #define OCSP_R_ERROR_IN_THISUPDATE_FIELD		 123
642 #define OCSP_R_ERROR_PARSING_URL			 121
643 #define OCSP_R_MISSING_OCSPSIGNING_USAGE		 103
644 #define OCSP_R_NEXTUPDATE_BEFORE_THISUPDATE		 124
645 #define OCSP_R_NOT_BASIC_RESPONSE			 104
646 #define OCSP_R_NO_CERTIFICATES_IN_CHAIN			 105
647 #define OCSP_R_NO_CONTENT				 106
648 #define OCSP_R_NO_PUBLIC_KEY				 107
649 #define OCSP_R_NO_RESPONSE_DATA				 108
650 #define OCSP_R_NO_REVOKED_TIME				 109
651 #define OCSP_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE	 110
652 #define OCSP_R_REQUEST_NOT_SIGNED			 128
653 #define OCSP_R_RESPONSE_CONTAINS_NO_REVOCATION_DATA	 111
654 #define OCSP_R_ROOT_CA_NOT_TRUSTED			 112
655 #define OCSP_R_SERVER_READ_ERROR			 113
656 #define OCSP_R_SERVER_RESPONSE_ERROR			 114
657 #define OCSP_R_SERVER_RESPONSE_PARSE_ERROR		 115
658 #define OCSP_R_SERVER_WRITE_ERROR			 116
659 #define OCSP_R_SIGNATURE_FAILURE			 117
660 #define OCSP_R_SIGNER_CERTIFICATE_NOT_FOUND		 118
661 #define OCSP_R_STATUS_EXPIRED				 125
662 #define OCSP_R_STATUS_NOT_YET_VALID			 126
663 #define OCSP_R_STATUS_TOO_OLD				 127
664 #define OCSP_R_UNKNOWN_MESSAGE_DIGEST			 119
665 #define OCSP_R_UNKNOWN_NID				 120
666 #define OCSP_R_UNSUPPORTED_REQUESTORNAME_TYPE		 129
667 
668 #ifdef  __cplusplus
669 }
670 #endif
671 #endif
672