Clarify why SSL_CTX_use_certificate_chain_file() should be preferred.
[openssl.git] / crypto / ocsp / ocsp.h
1 /* ocsp.h */
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/x509.h>
68 #include <openssl/x509v3.h>
69 #include <openssl/safestack.h>
70
71 #ifdef  __cplusplus
72 extern "C" {
73 #endif
74
75 /* Various flags and values */
76
77 #define OCSP_DEFAULT_NONCE_LENGTH       16
78
79 #define OCSP_NOCERTS                    0x1
80 #define OCSP_NOINTERN                   0x2
81 #define OCSP_NOSIGS                     0x4
82 #define OCSP_NOCHAIN                    0x8
83 #define OCSP_NOVERIFY                   0x10
84 #define OCSP_NOEXPLICIT                 0x20
85 #define OCSP_NOCASIGN                   0x40
86 #define OCSP_NODELEGATED                0x80
87 #define OCSP_NOCHECKS                   0x100
88 #define OCSP_TRUSTOTHER                 0x200
89
90 /*   CertID ::= SEQUENCE {
91  *       hashAlgorithm            AlgorithmIdentifier,
92  *       issuerNameHash     OCTET STRING, -- Hash of Issuer's DN
93  *       issuerKeyHash      OCTET STRING, -- Hash of Issuers public key (excluding the tag & length fields)
94  *       serialNumber       CertificateSerialNumber }
95  */
96 typedef struct ocsp_cert_id_st
97         {
98         X509_ALGOR *hashAlgorithm;
99         ASN1_OCTET_STRING *issuerNameHash;
100         ASN1_OCTET_STRING *issuerKeyHash;
101         ASN1_INTEGER *serialNumber;
102         } OCSP_CERTID;
103
104 DECLARE_STACK_OF(OCSP_CERTID)
105
106 /*   Request ::=     SEQUENCE {
107  *       reqCert                    CertID,
108  *       singleRequestExtensions    [0] EXPLICIT Extensions OPTIONAL }
109  */
110 typedef struct ocsp_one_request_st
111         {
112         OCSP_CERTID *reqCert;
113         STACK_OF(X509_EXTENSION) *singleRequestExtensions;
114         } OCSP_ONEREQ;
115
116 DECLARE_STACK_OF(OCSP_ONEREQ)
117 DECLARE_ASN1_SET_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         {
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         {
141         X509_ALGOR *signatureAlgorithm;
142         ASN1_BIT_STRING *signature;
143         STACK_OF(X509) *certs;
144         } OCSP_SIGNATURE;
145
146 /*   OCSPRequest     ::=     SEQUENCE {
147  *       tbsRequest                  TBSRequest,
148  *       optionalSignature   [0]     EXPLICIT Signature OPTIONAL }
149  */
150 typedef struct ocsp_request_st
151         {
152         OCSP_REQINFO *tbsRequest;
153         OCSP_SIGNATURE *optionalSignature; /* OPTIONAL */
154         } OCSP_REQUEST;
155
156 /*   OCSPResponseStatus ::= ENUMERATED {
157  *       successful            (0),      --Response has valid confirmations
158  *       malformedRequest      (1),      --Illegal confirmation request
159  *       internalError         (2),      --Internal error in issuer
160  *       tryLater              (3),      --Try again later
161  *                                       --(4) is not used
162  *       sigRequired           (5),      --Must sign the request
163  *       unauthorized          (6)       --Request unauthorized
164  *   }
165  */
166 #define OCSP_RESPONSE_STATUS_SUCCESSFUL          0
167 #define OCSP_RESPONSE_STATUS_MALFORMEDREQUEST     1
168 #define OCSP_RESPONSE_STATUS_INTERNALERROR        2
169 #define OCSP_RESPONSE_STATUS_TRYLATER             3
170 #define OCSP_RESPONSE_STATUS_SIGREQUIRED          5
171 #define OCSP_RESPONSE_STATUS_UNAUTHORIZED         6
172
173 /*   ResponseBytes ::=       SEQUENCE {
174  *       responseType   OBJECT IDENTIFIER,
175  *       response       OCTET STRING }
176  */
177 typedef struct ocsp_resp_bytes_st
178         {
179         ASN1_OBJECT *responseType;
180         ASN1_OCTET_STRING *response;
181         } OCSP_RESPBYTES;
182
183 /*   OCSPResponse ::= SEQUENCE {
184  *      responseStatus         OCSPResponseStatus,
185  *      responseBytes          [0] EXPLICIT ResponseBytes OPTIONAL }
186  */
187 typedef struct ocsp_response_st
188         {
189         ASN1_ENUMERATED *responseStatus;
190         OCSP_RESPBYTES  *responseBytes;
191         } OCSP_RESPONSE;
192
193 /*   ResponderID ::= CHOICE {
194  *      byName   [1] Name,
195  *      byKey    [2] KeyHash }
196  */
197 #define V_OCSP_RESPID_NAME 0
198 #define V_OCSP_RESPID_KEY  1
199 typedef struct ocsp_responder_id_st
200         {
201         int type;
202         union   {
203                 X509_NAME* byName;
204                 ASN1_OCTET_STRING *byKey;
205                 } value;
206         } OCSP_RESPID;
207 /*   KeyHash ::= OCTET STRING --SHA-1 hash of responder's public key
208  *                            --(excluding the tag and length fields)
209  */
210
211 /*   RevokedInfo ::= SEQUENCE {
212  *       revocationTime              GeneralizedTime,
213  *       revocationReason    [0]     EXPLICIT CRLReason OPTIONAL }
214  */
215 typedef struct ocsp_revoked_info_st
216         {
217         ASN1_GENERALIZEDTIME *revocationTime;
218         ASN1_ENUMERATED *revocationReason;
219         } OCSP_REVOKEDINFO;
220
221 /*   CertStatus ::= CHOICE {
222  *       good                [0]     IMPLICIT NULL,
223  *       revoked             [1]     IMPLICIT RevokedInfo,
224  *       unknown             [2]     IMPLICIT UnknownInfo }
225  */
226 #define V_OCSP_CERTSTATUS_GOOD    0
227 #define V_OCSP_CERTSTATUS_REVOKED 1
228 #define V_OCSP_CERTSTATUS_UNKNOWN 2
229 typedef struct ocsp_cert_status_st
230         {
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         {
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         {
267         ASN1_INTEGER *version;
268         OCSP_RESPID  *responderId;
269         ASN1_GENERALIZEDTIME *producedAt;
270         STACK_OF(OCSP_SINGLERESP) *responses;
271         STACK_OF(X509_EXTENSION) *responseExtensions;
272         } OCSP_RESPDATA;
273
274 /*   BasicOCSPResponse       ::= SEQUENCE {
275  *      tbsResponseData      ResponseData,
276  *      signatureAlgorithm   AlgorithmIdentifier,
277  *      signature            BIT STRING,
278  *      certs                [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }
279  */
280   /* Note 1:
281      The value for "signature" is specified in the OCSP rfc2560 as follows:
282      "The value for the signature SHALL be computed on the hash of the DER
283      encoding ResponseData."  This means that you must hash the DER-encoded
284      tbsResponseData, and then run it through a crypto-signing function, which
285      will (at least w/RSA) do a hash-'n'-private-encrypt operation.  This seems
286      a bit odd, but that's the spec.  Also note that the data structures do not
287      leave anywhere to independently specify the algorithm used for the initial
288      hash. So, we look at the signature-specification algorithm, and try to do
289      something intelligent.     -- Kathy Weinhold, CertCo */
290   /* Note 2:
291      It seems that the mentioned passage from RFC 2560 (section 4.2.1) is open
292      for interpretation.  I've done tests against another responder, and found
293      that it doesn't do the double hashing that the RFC seems to say one
294      should.  Therefore, all relevant functions take a flag saying which
295      variant should be used.    -- Richard Levitte, OpenSSL team and CeloCom */
296 typedef struct ocsp_basic_response_st
297         {
298         OCSP_RESPDATA *tbsResponseData;
299         X509_ALGOR *signatureAlgorithm;
300         ASN1_BIT_STRING *signature;
301         STACK_OF(X509) *certs;
302         } OCSP_BASICRESP;
303
304 /*
305  *   CRLReason ::= ENUMERATED {
306  *        unspecified             (0),
307  *        keyCompromise           (1),
308  *        cACompromise            (2),
309  *        affiliationChanged      (3),
310  *        superseded              (4),
311  *        cessationOfOperation    (5),
312  *        certificateHold         (6),
313  *        removeFromCRL           (8) }
314  */
315 #define OCSP_REVOKED_STATUS_NOSTATUS               -1
316 #define OCSP_REVOKED_STATUS_UNSPECIFIED             0
317 #define OCSP_REVOKED_STATUS_KEYCOMPROMISE           1
318 #define OCSP_REVOKED_STATUS_CACOMPROMISE            2
319 #define OCSP_REVOKED_STATUS_AFFILIATIONCHANGED      3
320 #define OCSP_REVOKED_STATUS_SUPERSEDED              4
321 #define OCSP_REVOKED_STATUS_CESSATIONOFOPERATION    5
322 #define OCSP_REVOKED_STATUS_CERTIFICATEHOLD         6
323 #define OCSP_REVOKED_STATUS_REMOVEFROMCRL           8
324
325 /* CrlID ::= SEQUENCE {
326  *     crlUrl               [0]     EXPLICIT IA5String OPTIONAL,
327  *     crlNum               [1]     EXPLICIT INTEGER OPTIONAL,
328  *     crlTime              [2]     EXPLICIT GeneralizedTime OPTIONAL }
329  */
330 typedef struct ocsp_crl_id_st
331         {
332         ASN1_IA5STRING *crlUrl;
333         ASN1_INTEGER *crlNum;
334         ASN1_GENERALIZEDTIME *crlTime;
335         } OCSP_CRLID;
336
337 /* ServiceLocator ::= SEQUENCE {
338  *      issuer    Name,
339  *      locator   AuthorityInfoAccessSyntax OPTIONAL }
340  */
341 typedef struct ocsp_service_locator_st
342         {
343         X509_NAME* issuer;
344         STACK_OF(ACCESS_DESCRIPTION) *locator;
345         } OCSP_SERVICELOC;
346  
347 #define PEM_STRING_OCSP_REQUEST "OCSP REQUEST"
348 #define PEM_STRING_OCSP_RESPONSE "OCSP RESPONSE"
349
350 #define d2i_OCSP_REQUEST_bio(bp,p) (OCSP_REQUEST*)ASN1_d2i_bio((char*(*)()) \
351                 OCSP_REQUEST_new,(char *(*)())d2i_OCSP_REQUEST, (bp),\
352                 (unsigned char **)(p))
353
354 #define d2i_OCSP_RESPONSE_bio(bp,p) (OCSP_RESPONSE*)ASN1_d2i_bio((char*(*)())\
355                 OCSP_REQUEST_new,(char *(*)())d2i_OCSP_RESPONSE, (bp),\
356                 (unsigned char **)(p))
357
358 #define PEM_read_bio_OCSP_REQUEST(bp,x,cb) (OCSP_REQUEST *)PEM_ASN1_read_bio( \
359      (char *(*)())d2i_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,bp,(char **)x,cb,NULL)
360
361 #define PEM_read_bio_OCSP_RESPONSE(bp,x,cb)(OCSP_RESPONSE *)PEM_ASN1_read_bio(\
362      (char *(*)())d2i_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,bp,(char **)x,cb,NULL)
363
364 #define PEM_write_bio_OCSP_REQUEST(bp,o) \
365     PEM_ASN1_write_bio((int (*)())i2d_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,\
366                         bp,(char *)o, NULL,NULL,0,NULL,NULL)
367
368 #define PEM_write_bio_OCSP_RESPONSE(bp,o) \
369     PEM_ASN1_write_bio((int (*)())i2d_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,\
370                         bp,(char *)o, NULL,NULL,0,NULL,NULL)
371
372 #define i2d_OCSP_RESPONSE_bio(bp,o) ASN1_i2d_bio(i2d_OCSP_RESPONSE,bp,\
373                 (unsigned char *)o)
374
375 #define i2d_OCSP_REQUEST_bio(bp,o) ASN1_i2d_bio(i2d_OCSP_REQUEST,bp,\
376                 (unsigned char *)o)
377
378 #define OCSP_REQUEST_sign(o,pkey,md) \
379         ASN1_item_sign(&OCSP_REQINFO_it,\
380                 o->optionalSignature->signatureAlgorithm,NULL,\
381                 o->optionalSignature->signature,o->tbsRequest,pkey,md)
382
383 #define OCSP_BASICRESP_sign(o,pkey,md,d) \
384         ASN1_item_sign(&OCSP_RESPDATA_it,o->signatureAlgorithm,NULL,\
385                 o->signature,o->tbsResponseData,pkey,md)
386
387 #define OCSP_REQUEST_verify(a,r) ASN1_item_verify(&OCSP_REQINFO_it,\
388         a->optionalSignature->signatureAlgorithm,\
389         a->optionalSignature->signature,a->tbsRequest,r)
390
391 #define OCSP_BASICRESP_verify(a,r,d) ASN1_item_verify(&OCSP_RESPDATA_it,\
392         a->signatureAlgorithm,a->signature,a->tbsResponseData,r)
393
394 #define ASN1_BIT_STRING_digest(data,type,md,len) \
395         ASN1_item_digest(&ASN1_BIT_STRING_it,type,data,md,len)
396
397 #define OCSP_CERTID_dup(cid) (OCSP_CERTID*)ASN1_dup((int(*)())i2d_OCSP_CERTID,\
398                 (char *(*)())d2i_OCSP_CERTID,(char *)(cid))
399
400 #define OCSP_CERTSTATUS_dup(cs)\
401                 (OCSP_CERTSTATUS*)ASN1_dup((int(*)())i2d_OCSP_CERTSTATUS,\
402                 (char *(*)())d2i_OCSP_CERTSTATUS,(char *)(cs))
403
404 OCSP_RESPONSE *OCSP_sendreq_bio(BIO *b, char *path, OCSP_REQUEST *req);
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, 
409                               X509_NAME *issuerName, 
410                               ASN1_BIT_STRING* issuerKey, 
411                               ASN1_INTEGER *serialNumber);
412
413 OCSP_CERTSTATUS *OCSP_cert_status_new(int status, int reason, char *tim);
414
415 OCSP_ONEREQ *OCSP_request_add0_id(OCSP_REQUEST *req, OCSP_CERTID *cid);
416 int OCSP_request_add1_nonce(OCSP_REQUEST *req, unsigned char *val, int len);
417 int OCSP_check_nonce(OCSP_REQUEST *req, OCSP_BASICRESP *bs);
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,
422                       X509           *signer,
423                       EVP_PKEY       *key,
424                       const EVP_MD   *dgst,
425                       STACK_OF(X509) *certs,
426                       unsigned long flags);
427
428 int OCSP_response_status(OCSP_RESPONSE *resp);
429 OCSP_BASICRESP *OCSP_response_get1_basic(OCSP_RESPONSE *resp);
430
431 int OCSP_resp_count(OCSP_BASICRESP *bs);
432 OCSP_SINGLERESP *OCSP_resp_get0(OCSP_BASICRESP *bs, int idx);
433 int OCSP_resp_find(OCSP_BASICRESP *bs, OCSP_CERTID *id, int last);
434 int OCSP_single_get0_status(OCSP_SINGLERESP *single, int *reason,
435                                 ASN1_GENERALIZEDTIME **revtime,
436                                 ASN1_GENERALIZEDTIME **thisupd,
437                                 ASN1_GENERALIZEDTIME **nextupd);
438 int OCSP_resp_find_status(OCSP_BASICRESP *bs, OCSP_CERTID *id, int *status,
439                                 int *reason,
440                                 ASN1_GENERALIZEDTIME **revtime,
441                                 ASN1_GENERALIZEDTIME **thisupd,
442                                 ASN1_GENERALIZEDTIME **nextupd);
443
444 int OCSP_request_verify(OCSP_REQUEST *req, EVP_PKEY *pkey);
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 OCSP_BASICRESP *OCSP_basic_response_new(int tag,
450                                         X509* cert);
451
452 int OCSP_basic_response_add(OCSP_BASICRESP           *rsp,
453                             OCSP_CERTID              *cid,
454                             OCSP_CERTSTATUS          *cst,
455                             char                     *thisUpdate,
456                             char                     *nextUpdate);
457
458 int OCSP_basic_response_sign(OCSP_BASICRESP *brsp, 
459                              EVP_PKEY       *key,
460                              const EVP_MD   *dgst,
461                              STACK_OF(X509) *certs);
462
463 int OCSP_response_verify(OCSP_RESPONSE *rsp, EVP_PKEY *pkey);
464
465 int OCSP_basic_response_verify(OCSP_BASICRESP *rsp, EVP_PKEY *pkey);
466
467
468 OCSP_RESPONSE *OCSP_response_new(int status,
469                                  int nid,
470                                  int (*i2d)(),
471                                  char *data);
472
473 ASN1_STRING *ASN1_STRING_encode(ASN1_STRING *s, int (*i2d)(), 
474                                 char *data, STACK_OF(ASN1_OBJECT) *sk);
475
476 X509_EXTENSION *OCSP_crlID_new(char *url, long *n, char *tim);
477
478 X509_EXTENSION *OCSP_accept_responses_new(char **oids);
479
480 X509_EXTENSION *OCSP_archive_cutoff_new(char* tim);
481
482 X509_EXTENSION *OCSP_url_svcloc_new(X509_NAME* issuer, char **urls);
483
484 int OCSP_REQUEST_get_ext_count(OCSP_REQUEST *x);
485 int OCSP_REQUEST_get_ext_by_NID(OCSP_REQUEST *x, int nid, int lastpos);
486 int OCSP_REQUEST_get_ext_by_OBJ(OCSP_REQUEST *x, ASN1_OBJECT *obj, int lastpos);
487 int OCSP_REQUEST_get_ext_by_critical(OCSP_REQUEST *x, int crit, int lastpos);
488 X509_EXTENSION *OCSP_REQUEST_get_ext(OCSP_REQUEST *x, int loc);
489 X509_EXTENSION *OCSP_REQUEST_delete_ext(OCSP_REQUEST *x, int loc);
490 void *OCSP_REQUEST_get1_ext_d2i(OCSP_REQUEST *x, int nid, int *crit, int *idx);
491 int OCSP_REQUEST_add1_ext_i2d(OCSP_REQUEST *x, int nid, void *value, int crit,
492                                                         unsigned long flags);
493 int OCSP_REQUEST_add_ext(OCSP_REQUEST *x, X509_EXTENSION *ex, int loc);
494
495 int OCSP_ONEREQ_get_ext_count(OCSP_ONEREQ *x);
496 int OCSP_ONEREQ_get_ext_by_NID(OCSP_ONEREQ *x, int nid, int lastpos);
497 int OCSP_ONEREQ_get_ext_by_OBJ(OCSP_ONEREQ *x, ASN1_OBJECT *obj, int lastpos);
498 int OCSP_ONEREQ_get_ext_by_critical(OCSP_ONEREQ *x, int crit, int lastpos);
499 X509_EXTENSION *OCSP_ONEREQ_get_ext(OCSP_ONEREQ *x, int loc);
500 X509_EXTENSION *OCSP_ONEREQ_delete_ext(OCSP_ONEREQ *x, int loc);
501 void *OCSP_ONEREQ_get1_ext_d2i(OCSP_ONEREQ *x, int nid, int *crit, int *idx);
502 int OCSP_ONEREQ_add1_ext_i2d(OCSP_ONEREQ *x, int nid, void *value, int crit,
503                                                         unsigned long flags);
504 int OCSP_ONEREQ_add_ext(OCSP_ONEREQ *x, X509_EXTENSION *ex, int loc);
505
506 int OCSP_BASICRESP_get_ext_count(OCSP_BASICRESP *x);
507 int OCSP_BASICRESP_get_ext_by_NID(OCSP_BASICRESP *x, int nid, int lastpos);
508 int OCSP_BASICRESP_get_ext_by_OBJ(OCSP_BASICRESP *x, ASN1_OBJECT *obj, int lastpos);
509 int OCSP_BASICRESP_get_ext_by_critical(OCSP_BASICRESP *x, int crit, int lastpos);
510 X509_EXTENSION *OCSP_BASICRESP_get_ext(OCSP_BASICRESP *x, int loc);
511 X509_EXTENSION *OCSP_BASICRESP_delete_ext(OCSP_BASICRESP *x, int loc);
512 void *OCSP_BASICRESP_get1_ext_d2i(OCSP_BASICRESP *x, int nid, int *crit, int *idx);
513 int OCSP_BASICRESP_add1_ext_i2d(OCSP_BASICRESP *x, int nid, void *value, int crit,
514                                                         unsigned long flags);
515 int OCSP_BASICRESP_add_ext(OCSP_BASICRESP *x, X509_EXTENSION *ex, int loc);
516
517 int OCSP_SINGLERESP_get_ext_count(OCSP_SINGLERESP *x);
518 int OCSP_SINGLERESP_get_ext_by_NID(OCSP_SINGLERESP *x, int nid, int lastpos);
519 int OCSP_SINGLERESP_get_ext_by_OBJ(OCSP_SINGLERESP *x, ASN1_OBJECT *obj, int lastpos);
520 int OCSP_SINGLERESP_get_ext_by_critical(OCSP_SINGLERESP *x, int crit, int lastpos);
521 X509_EXTENSION *OCSP_SINGLERESP_get_ext(OCSP_SINGLERESP *x, int loc);
522 X509_EXTENSION *OCSP_SINGLERESP_delete_ext(OCSP_SINGLERESP *x, int loc);
523 void *OCSP_SINGLERESP_get1_ext_d2i(OCSP_SINGLERESP *x, int nid, int *crit, int *idx);
524 int OCSP_SINGLERESP_add1_ext_i2d(OCSP_SINGLERESP *x, int nid, void *value, int crit,
525                                                         unsigned long flags);
526 int OCSP_SINGLERESP_add_ext(OCSP_SINGLERESP *x, X509_EXTENSION *ex, int loc);
527
528 DECLARE_ASN1_FUNCTIONS(OCSP_SINGLERESP)
529 DECLARE_ASN1_FUNCTIONS(OCSP_CERTSTATUS)
530 DECLARE_ASN1_FUNCTIONS(OCSP_REVOKEDINFO)
531 DECLARE_ASN1_FUNCTIONS(OCSP_BASICRESP)
532 DECLARE_ASN1_FUNCTIONS(OCSP_RESPDATA)
533 DECLARE_ASN1_FUNCTIONS(OCSP_RESPID)
534 DECLARE_ASN1_FUNCTIONS(OCSP_RESPONSE)
535 DECLARE_ASN1_FUNCTIONS(OCSP_RESPBYTES)
536 DECLARE_ASN1_FUNCTIONS(OCSP_ONEREQ)
537 DECLARE_ASN1_FUNCTIONS(OCSP_CERTID)
538 DECLARE_ASN1_FUNCTIONS(OCSP_REQUEST)
539 DECLARE_ASN1_FUNCTIONS(OCSP_SIGNATURE)
540 DECLARE_ASN1_FUNCTIONS(OCSP_REQINFO)
541 DECLARE_ASN1_FUNCTIONS(OCSP_CRLID)
542 DECLARE_ASN1_FUNCTIONS(OCSP_SERVICELOC)
543
544 char *OCSP_response_status_str(long s);
545 char *OCSP_cert_status_str(long s);
546 char *OCSP_crl_reason_str(long s);
547
548 int OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST* a, unsigned long flags);
549 int OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE* o, unsigned long flags);
550
551 int OCSP_basic_verify(OCSP_BASICRESP *bs, STACK_OF(X509) *certs,
552                                 X509_STORE *st, unsigned long flags);
553
554 void ERR_load_OCSP_strings(void);
555
556 /* BEGIN ERROR CODES */
557 /* The following lines are auto generated by the script mkerr.pl. Any changes
558  * made after this point may be overwritten when the script is next run.
559  */
560
561 /* Error codes for the OCSP functions. */
562
563 /* Function codes. */
564 #define OCSP_F_ASN1_STRING_ENCODE                        106
565 #define OCSP_F_BASIC_RESPONSE_NEW                        100
566 #define OCSP_F_BASIC_RESPONSE_VERIFY                     101
567 #define OCSP_F_CERT_ID_NEW                               102
568 #define OCSP_F_CERT_STATUS_NEW                           103
569 #define OCSP_F_D2I_OCSP_NONCE                            109
570 #define OCSP_F_OCSP_BASIC_VERIFY                         113
571 #define OCSP_F_OCSP_CHECK_DELEGATED                      117
572 #define OCSP_F_OCSP_CHECK_IDS                            114
573 #define OCSP_F_OCSP_CHECK_ISSUER                         115
574 #define OCSP_F_OCSP_CHECK_NONCE                          112
575 #define OCSP_F_OCSP_MATCH_ISSUERID                       116
576 #define OCSP_F_OCSP_RESPONSE_GET1_BASIC                  111
577 #define OCSP_F_OCSP_SENDREQ_BIO                          110
578 #define OCSP_F_REQUEST_VERIFY                            104
579 #define OCSP_F_RESPONSE_VERIFY                           105
580 #define OCSP_F_S2I_OCSP_NONCE                            107
581 #define OCSP_F_V2I_OCSP_CRLID                            108
582
583 /* Reason codes. */
584 #define OCSP_R_BAD_DATA                                  108
585 #define OCSP_R_BAD_TAG                                   100
586 #define OCSP_R_CERTIFICATE_VERIFY_ERROR                  126
587 #define OCSP_R_DIGEST_ERR                                101
588 #define OCSP_R_FAILED_TO_OPEN                            109
589 #define OCSP_R_FAILED_TO_READ                            110
590 #define OCSP_R_FAILED_TO_STAT                            111
591 #define OCSP_R_MISSING_OCSPSIGNING_USAGE                 131
592 #define OCSP_R_MISSING_VALUE                             112
593 #define OCSP_R_NONCE_MISSING_IN_RESPONSE                 121
594 #define OCSP_R_NONCE_VALUE_MISMATCH                      122
595 #define OCSP_R_NOT_BASIC_RESPONSE                        120
596 #define OCSP_R_NO_CERTIFICATE                            102
597 #define OCSP_R_NO_CERTIFICATES_IN_CHAIN                  128
598 #define OCSP_R_NO_CONTENT                                115
599 #define OCSP_R_NO_PUBLIC_KEY                             103
600 #define OCSP_R_NO_RESPONSE_DATA                          104
601 #define OCSP_R_NO_SIGNATURE                              105
602 #define OCSP_R_RESPONSE_CONTAINS_NO_REVOCATION_DATA      129
603 #define OCSP_R_REVOKED_NO_TIME                           106
604 #define OCSP_R_ROOT_CA_NOT_TRUSTED                       127
605 #define OCSP_R_SERVER_READ_ERROR                         116
606 #define OCSP_R_SERVER_RESPONSE_ERROR                     117
607 #define OCSP_R_SERVER_RESPONSE_PARSE_ERROR               118
608 #define OCSP_R_SERVER_WRITE_ERROR                        119
609 #define OCSP_R_SIGNATURE_FAILURE                         124
610 #define OCSP_R_SIGNER_CERTIFICATE_NOT_FOUND              125
611 #define OCSP_R_UNEXPECTED_NONCE_IN_RESPONSE              123
612 #define OCSP_R_UNKNOWN_MESSAGE_DIGEST                    130
613 #define OCSP_R_UNKNOWN_NID                               107
614 #define OCSP_R_UNSUPPORTED_OPTION                        113
615 #define OCSP_R_VALUE_ALREADY                             114
616
617 #ifdef  __cplusplus
618 }
619 #endif
620 #endif
621