Documentation language corrections, contributed by Chris Pepper <pepper@mail.reppep...
[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
89 /*   CertID ::= SEQUENCE {
90  *       hashAlgorithm            AlgorithmIdentifier,
91  *       issuerNameHash     OCTET STRING, -- Hash of Issuer's DN
92  *       issuerKeyHash      OCTET STRING, -- Hash of Issuers public key (excluding the tag & length fields)
93  *       serialNumber       CertificateSerialNumber }
94  */
95 typedef struct ocsp_cert_id_st
96         {
97         X509_ALGOR *hashAlgorithm;
98         ASN1_OCTET_STRING *issuerNameHash;
99         ASN1_OCTET_STRING *issuerKeyHash;
100         ASN1_INTEGER *serialNumber;
101         } OCSP_CERTID;
102
103 DECLARE_STACK_OF(OCSP_CERTID)
104
105 /*   Request ::=     SEQUENCE {
106  *       reqCert                    CertID,
107  *       singleRequestExtensions    [0] EXPLICIT Extensions OPTIONAL }
108  */
109 typedef struct ocsp_one_request_st
110         {
111         OCSP_CERTID *reqCert;
112         STACK_OF(X509_EXTENSION) *singleRequestExtensions;
113         } OCSP_ONEREQ;
114
115 DECLARE_STACK_OF(OCSP_ONEREQ)
116 DECLARE_ASN1_SET_OF(OCSP_ONEREQ)
117
118
119 /*   TBSRequest      ::=     SEQUENCE {
120  *       version             [0] EXPLICIT Version DEFAULT v1,
121  *       requestorName       [1] EXPLICIT GeneralName OPTIONAL,
122  *       requestList             SEQUENCE OF Request,
123  *       requestExtensions   [2] EXPLICIT Extensions OPTIONAL }
124  */
125 typedef struct ocsp_req_info_st
126         {
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         {
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         {
151         OCSP_REQINFO *tbsRequest;
152         OCSP_SIGNATURE *optionalSignature; /* OPTIONAL */
153         } OCSP_REQUEST;
154
155 /*   OCSPResponseStatus ::= ENUMERATED {
156  *       successful            (0),      --Response has valid confirmations
157  *       malformedRequest      (1),      --Illegal confirmation request
158  *       internalError         (2),      --Internal error in issuer
159  *       tryLater              (3),      --Try again later
160  *                                       --(4) is not used
161  *       sigRequired           (5),      --Must sign the request
162  *       unauthorized          (6)       --Request unauthorized
163  *   }
164  */
165 #define OCSP_RESPONSE_STATUS_SUCCESSFUL          0
166 #define OCSP_RESPONSE_STATUS_MALFORMEDREQUEST     1
167 #define OCSP_RESPONSE_STATUS_INTERNALERROR        2
168 #define OCSP_RESPONSE_STATUS_TRYLATER             3
169 #define OCSP_RESPONSE_STATUS_SIGREQUIRED          5
170 #define OCSP_RESPONSE_STATUS_UNAUTHORIZED         6
171
172 /*   ResponseBytes ::=       SEQUENCE {
173  *       responseType   OBJECT IDENTIFIER,
174  *       response       OCTET STRING }
175  */
176 typedef struct ocsp_resp_bytes_st
177         {
178         ASN1_OBJECT *responseType;
179         ASN1_OCTET_STRING *response;
180         } OCSP_RESPBYTES;
181
182 /*   OCSPResponse ::= SEQUENCE {
183  *      responseStatus         OCSPResponseStatus,
184  *      responseBytes          [0] EXPLICIT ResponseBytes OPTIONAL }
185  */
186 typedef struct ocsp_response_st
187         {
188         ASN1_ENUMERATED *responseStatus;
189         OCSP_RESPBYTES  *responseBytes;
190         } OCSP_RESPONSE;
191
192 /*   ResponderID ::= CHOICE {
193  *      byName   [1] Name,
194  *      byKey    [2] KeyHash }
195  */
196 #define V_OCSP_RESPID_NAME 0
197 #define V_OCSP_RESPID_KEY  1
198 typedef struct ocsp_responder_id_st
199         {
200         int type;
201         union   {
202                 X509_NAME* byName;
203                 ASN1_OCTET_STRING *byKey;
204                 } value;
205         } OCSP_RESPID;
206 /*   KeyHash ::= OCTET STRING --SHA-1 hash of responder's public key
207  *                            --(excluding the tag and length fields)
208  */
209
210 /*   RevokedInfo ::= SEQUENCE {
211  *       revocationTime              GeneralizedTime,
212  *       revocationReason    [0]     EXPLICIT CRLReason OPTIONAL }
213  */
214 typedef struct ocsp_revoked_info_st
215         {
216         ASN1_GENERALIZEDTIME *revocationTime;
217         ASN1_ENUMERATED *revocationReason;
218         } OCSP_REVOKEDINFO;
219
220 /*   CertStatus ::= CHOICE {
221  *       good                [0]     IMPLICIT NULL,
222  *       revoked             [1]     IMPLICIT RevokedInfo,
223  *       unknown             [2]     IMPLICIT UnknownInfo }
224  */
225 #define V_OCSP_CERTSTATUS_GOOD    0
226 #define V_OCSP_CERTSTATUS_REVOKED 1
227 #define V_OCSP_CERTSTATUS_UNKNOWN 2
228 typedef struct ocsp_cert_status_st
229         {
230         int type;
231         union   {
232                 ASN1_NULL *good;
233                 OCSP_REVOKEDINFO *revoked;
234                 ASN1_NULL *unknown;
235                 } value;
236         } OCSP_CERTSTATUS;
237
238 /*   SingleResponse ::= SEQUENCE {
239  *      certID                       CertID,
240  *      certStatus                   CertStatus,
241  *      thisUpdate                   GeneralizedTime,
242  *      nextUpdate           [0]     EXPLICIT GeneralizedTime OPTIONAL,
243  *      singleExtensions     [1]     EXPLICIT Extensions OPTIONAL }
244  */
245 typedef struct ocsp_single_response_st
246         {
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 DECLARE_ASN1_SET_OF(OCSP_SINGLERESP)
256
257 /*   ResponseData ::= SEQUENCE {
258  *      version              [0] EXPLICIT Version DEFAULT v1,
259  *      responderID              ResponderID,
260  *      producedAt               GeneralizedTime,
261  *      responses                SEQUENCE OF SingleResponse,
262  *      responseExtensions   [1] EXPLICIT Extensions OPTIONAL }
263  */
264 typedef struct ocsp_response_data_st
265         {
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         {
297         OCSP_RESPDATA *tbsResponseData;
298         X509_ALGOR *signatureAlgorithm;
299         ASN1_BIT_STRING *signature;
300         STACK_OF(X509) *certs;
301         } OCSP_BASICRESP;
302
303 /*
304  *   CRLReason ::= ENUMERATED {
305  *        unspecified             (0),
306  *        keyCompromise           (1),
307  *        cACompromise            (2),
308  *        affiliationChanged      (3),
309  *        superseded              (4),
310  *        cessationOfOperation    (5),
311  *        certificateHold         (6),
312  *        removeFromCRL           (8) }
313  */
314 #define OCSP_REVOKED_STATUS_NOSTATUS               -1
315 #define OCSP_REVOKED_STATUS_UNSPECIFIED             0
316 #define OCSP_REVOKED_STATUS_KEYCOMPROMISE           1
317 #define OCSP_REVOKED_STATUS_CACOMPROMISE            2
318 #define OCSP_REVOKED_STATUS_AFFILIATIONCHANGED      3
319 #define OCSP_REVOKED_STATUS_SUPERSEDED              4
320 #define OCSP_REVOKED_STATUS_CESSATIONOFOPERATION    5
321 #define OCSP_REVOKED_STATUS_CERTIFICATEHOLD         6
322 #define OCSP_REVOKED_STATUS_REMOVEFROMCRL           8
323
324 /* CrlID ::= SEQUENCE {
325  *     crlUrl               [0]     EXPLICIT IA5String OPTIONAL,
326  *     crlNum               [1]     EXPLICIT INTEGER OPTIONAL,
327  *     crlTime              [2]     EXPLICIT GeneralizedTime OPTIONAL }
328  */
329 typedef struct ocsp_crl_id_st
330         {
331         ASN1_IA5STRING *crlUrl;
332         ASN1_INTEGER *crlNum;
333         ASN1_GENERALIZEDTIME *crlTime;
334         } OCSP_CRLID;
335
336 /* ServiceLocator ::= SEQUENCE {
337  *      issuer    Name,
338  *      locator   AuthorityInfoAccessSyntax OPTIONAL }
339  */
340 typedef struct ocsp_service_locator_st
341         {
342         X509_NAME* issuer;
343         STACK_OF(ACCESS_DESCRIPTION) *locator;
344         } OCSP_SERVICELOC;
345  
346 #define PEM_STRING_OCSP_REQUEST "OCSP REQUEST"
347 #define PEM_STRING_OCSP_RESPONSE "OCSP RESPONSE"
348
349 #define d2i_OCSP_REQUEST_bio(bp,p) (OCSP_REQUEST*)ASN1_d2i_bio((char*(*)()) \
350                 OCSP_REQUEST_new,(char *(*)())d2i_OCSP_REQUEST, (bp),\
351                 (unsigned char **)(p))
352
353 #define d2i_OCSP_RESPONSE_bio(bp,p) (OCSP_RESPONSE*)ASN1_d2i_bio((char*(*)())\
354                 OCSP_REQUEST_new,(char *(*)())d2i_OCSP_RESPONSE, (bp),\
355                 (unsigned char **)(p))
356
357 #define PEM_read_bio_OCSP_REQUEST(bp,x,cb) (OCSP_REQUEST *)PEM_ASN1_read_bio( \
358      (char *(*)())d2i_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,bp,(char **)x,cb,NULL)
359
360 #define PEM_read_bio_OCSP_RESPONSE(bp,x,cb)(OCSP_RESPONSE *)PEM_ASN1_read_bio(\
361      (char *(*)())d2i_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,bp,(char **)x,cb,NULL)
362
363 #define PEM_write_bio_OCSP_REQUEST(bp,o) \
364     PEM_ASN1_write_bio((int (*)())i2d_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,\
365                         bp,(char *)o, NULL,NULL,0,NULL,NULL)
366
367 #define PEM_write_bio_OCSP_RESPONSE(bp,o) \
368     PEM_ASN1_write_bio((int (*)())i2d_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,\
369                         bp,(char *)o, NULL,NULL,0,NULL,NULL)
370
371 #define i2d_OCSP_RESPONSE_bio(bp,o) ASN1_i2d_bio(i2d_OCSP_RESPONSE,bp,\
372                 (unsigned char *)o)
373
374 #define i2d_OCSP_REQUEST_bio(bp,o) ASN1_i2d_bio(i2d_OCSP_REQUEST,bp,\
375                 (unsigned char *)o)
376
377 #define OCSP_REQUEST_sign(o,pkey,md) \
378         ASN1_item_sign(&OCSP_REQINFO_it,\
379                 o->optionalSignature->signatureAlgorithm,NULL,\
380                 o->optionalSignature->signature,o->tbsRequest,pkey,md)
381
382 #define OCSP_BASICRESP_sign(o,pkey,md,d) \
383         ASN1_item_sign(&OCSP_RESPDATA_it,o->signatureAlgorithm,NULL,\
384                 o->signature,o->tbsResponseData,pkey,md)
385
386 #define OCSP_REQUEST_verify(a,r) ASN1_item_verify(&OCSP_REQINFO_it,\
387         a->optionalSignature->signatureAlgorithm,\
388         a->optionalSignature->signature,a->tbsRequest,r)
389
390 #define OCSP_BASICRESP_verify(a,r,d) ASN1_item_verify(&OCSP_RESPDATA_it,\
391         a->signatureAlgorithm,a->signature,a->tbsResponseData,r)
392
393 #define ASN1_BIT_STRING_digest(data,type,md,len) \
394         ASN1_item_digest(&ASN1_BIT_STRING_it,type,data,md,len)
395
396 #define OCSP_CERTID_dup(cid) (OCSP_CERTID*)ASN1_dup((int(*)())i2d_OCSP_CERTID,\
397                 (char *(*)())d2i_OCSP_CERTID,(char *)(cid))
398
399 #define OCSP_CERTSTATUS_dup(cs)\
400                 (OCSP_CERTSTATUS*)ASN1_dup((int(*)())i2d_OCSP_CERTSTATUS,\
401                 (char *(*)())d2i_OCSP_CERTSTATUS,(char *)(cs))
402
403 OCSP_RESPONSE *OCSP_sendreq_bio(BIO *b, char *path, OCSP_REQUEST *req);
404
405 OCSP_CERTID *OCSP_cert_to_id(const EVP_MD *dgst, X509 *subject, X509 *issuer);
406
407 OCSP_CERTID *OCSP_cert_id_new(const EVP_MD *dgst, 
408                               X509_NAME *issuerName, 
409                               ASN1_BIT_STRING* issuerKey, 
410                               ASN1_INTEGER *serialNumber);
411
412 OCSP_CERTSTATUS *OCSP_cert_status_new(int status, int reason, char *tim);
413
414 OCSP_ONEREQ *OCSP_request_add0_id(OCSP_REQUEST *req, OCSP_CERTID *cid);
415 int OCSP_request_add1_nonce(OCSP_REQUEST *req, unsigned char *val, int len);
416 int OCSP_check_nonce(OCSP_REQUEST *req, OCSP_BASICRESP *bs);
417 int OCSP_request_set1_name(OCSP_REQUEST *req, X509_NAME *nm);
418 int OCSP_request_add1_cert(OCSP_REQUEST *req, X509 *cert);
419
420 int OCSP_request_sign(OCSP_REQUEST   *req,
421                       X509           *signer,
422                       EVP_PKEY       *key,
423                       const EVP_MD   *dgst,
424                       STACK_OF(X509) *certs,
425                       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,
435                                 ASN1_GENERALIZEDTIME **thisupd,
436                                 ASN1_GENERALIZEDTIME **nextupd);
437 int OCSP_resp_find_status(OCSP_BASICRESP *bs, OCSP_CERTID *id, int *status,
438                                 int *reason,
439                                 ASN1_GENERALIZEDTIME **revtime,
440                                 ASN1_GENERALIZEDTIME **thisupd,
441                                 ASN1_GENERALIZEDTIME **nextupd);
442
443 int OCSP_request_verify(OCSP_REQUEST *req, EVP_PKEY *pkey);
444
445 int OCSP_id_issuer_cmp(OCSP_CERTID *a, OCSP_CERTID *b);
446 int OCSP_id_cmp(OCSP_CERTID *a, OCSP_CERTID *b);
447
448 OCSP_BASICRESP *OCSP_basic_response_new(int tag,
449                                         X509* cert);
450
451 int OCSP_basic_response_add(OCSP_BASICRESP           *rsp,
452                             OCSP_CERTID              *cid,
453                             OCSP_CERTSTATUS          *cst,
454                             char                     *thisUpdate,
455                             char                     *nextUpdate);
456
457 int OCSP_basic_response_sign(OCSP_BASICRESP *brsp, 
458                              EVP_PKEY       *key,
459                              const EVP_MD   *dgst,
460                              STACK_OF(X509) *certs);
461
462 int OCSP_response_verify(OCSP_RESPONSE *rsp, EVP_PKEY *pkey);
463
464 int OCSP_basic_response_verify(OCSP_BASICRESP *rsp, EVP_PKEY *pkey);
465
466
467 OCSP_RESPONSE *OCSP_response_new(int status,
468                                  int nid,
469                                  int (*i2d)(),
470                                  char *data);
471
472 ASN1_STRING *ASN1_STRING_encode(ASN1_STRING *s, int (*i2d)(), 
473                                 char *data, STACK_OF(ASN1_OBJECT) *sk);
474
475 X509_EXTENSION *OCSP_crlID_new(char *url, long *n, char *tim);
476
477 X509_EXTENSION *OCSP_accept_responses_new(char **oids);
478
479 X509_EXTENSION *OCSP_archive_cutoff_new(char* tim);
480
481 X509_EXTENSION *OCSP_url_svcloc_new(X509_NAME* issuer, char **urls);
482
483 int OCSP_REQUEST_get_ext_count(OCSP_REQUEST *x);
484 int OCSP_REQUEST_get_ext_by_NID(OCSP_REQUEST *x, int nid, int lastpos);
485 int OCSP_REQUEST_get_ext_by_OBJ(OCSP_REQUEST *x, ASN1_OBJECT *obj, int lastpos);
486 int OCSP_REQUEST_get_ext_by_critical(OCSP_REQUEST *x, int crit, int lastpos);
487 X509_EXTENSION *OCSP_REQUEST_get_ext(OCSP_REQUEST *x, int loc);
488 X509_EXTENSION *OCSP_REQUEST_delete_ext(OCSP_REQUEST *x, int loc);
489 void *OCSP_REQUEST_get1_ext_d2i(OCSP_REQUEST *x, int nid, int *crit, int *idx);
490 int OCSP_REQUEST_add1_ext_i2d(OCSP_REQUEST *x, int nid, void *value, int crit,
491                                                         unsigned long flags);
492 int OCSP_REQUEST_add_ext(OCSP_REQUEST *x, X509_EXTENSION *ex, int loc);
493
494 int OCSP_ONEREQ_get_ext_count(OCSP_ONEREQ *x);
495 int OCSP_ONEREQ_get_ext_by_NID(OCSP_ONEREQ *x, int nid, int lastpos);
496 int OCSP_ONEREQ_get_ext_by_OBJ(OCSP_ONEREQ *x, ASN1_OBJECT *obj, int lastpos);
497 int OCSP_ONEREQ_get_ext_by_critical(OCSP_ONEREQ *x, int crit, int lastpos);
498 X509_EXTENSION *OCSP_ONEREQ_get_ext(OCSP_ONEREQ *x, int loc);
499 X509_EXTENSION *OCSP_ONEREQ_delete_ext(OCSP_ONEREQ *x, int loc);
500 void *OCSP_ONEREQ_get1_ext_d2i(OCSP_ONEREQ *x, int nid, int *crit, int *idx);
501 int OCSP_ONEREQ_add1_ext_i2d(OCSP_ONEREQ *x, int nid, void *value, int crit,
502                                                         unsigned long flags);
503 int OCSP_ONEREQ_add_ext(OCSP_ONEREQ *x, X509_EXTENSION *ex, int loc);
504
505 int OCSP_BASICRESP_get_ext_count(OCSP_BASICRESP *x);
506 int OCSP_BASICRESP_get_ext_by_NID(OCSP_BASICRESP *x, int nid, int lastpos);
507 int OCSP_BASICRESP_get_ext_by_OBJ(OCSP_BASICRESP *x, ASN1_OBJECT *obj, int lastpos);
508 int OCSP_BASICRESP_get_ext_by_critical(OCSP_BASICRESP *x, int crit, int lastpos);
509 X509_EXTENSION *OCSP_BASICRESP_get_ext(OCSP_BASICRESP *x, int loc);
510 X509_EXTENSION *OCSP_BASICRESP_delete_ext(OCSP_BASICRESP *x, int loc);
511 void *OCSP_BASICRESP_get1_ext_d2i(OCSP_BASICRESP *x, int nid, int *crit, int *idx);
512 int OCSP_BASICRESP_add1_ext_i2d(OCSP_BASICRESP *x, int nid, void *value, int crit,
513                                                         unsigned long flags);
514 int OCSP_BASICRESP_add_ext(OCSP_BASICRESP *x, X509_EXTENSION *ex, int loc);
515
516 int OCSP_SINGLERESP_get_ext_count(OCSP_SINGLERESP *x);
517 int OCSP_SINGLERESP_get_ext_by_NID(OCSP_SINGLERESP *x, int nid, int lastpos);
518 int OCSP_SINGLERESP_get_ext_by_OBJ(OCSP_SINGLERESP *x, ASN1_OBJECT *obj, int lastpos);
519 int OCSP_SINGLERESP_get_ext_by_critical(OCSP_SINGLERESP *x, int crit, 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, int *idx);
523 int OCSP_SINGLERESP_add1_ext_i2d(OCSP_SINGLERESP *x, int nid, void *value, int crit,
524                                                         unsigned long flags);
525 int OCSP_SINGLERESP_add_ext(OCSP_SINGLERESP *x, X509_EXTENSION *ex, int loc);
526
527 DECLARE_ASN1_FUNCTIONS(OCSP_SINGLERESP)
528 DECLARE_ASN1_FUNCTIONS(OCSP_CERTSTATUS)
529 DECLARE_ASN1_FUNCTIONS(OCSP_REVOKEDINFO)
530 DECLARE_ASN1_FUNCTIONS(OCSP_BASICRESP)
531 DECLARE_ASN1_FUNCTIONS(OCSP_RESPDATA)
532 DECLARE_ASN1_FUNCTIONS(OCSP_RESPID)
533 DECLARE_ASN1_FUNCTIONS(OCSP_RESPONSE)
534 DECLARE_ASN1_FUNCTIONS(OCSP_RESPBYTES)
535 DECLARE_ASN1_FUNCTIONS(OCSP_ONEREQ)
536 DECLARE_ASN1_FUNCTIONS(OCSP_CERTID)
537 DECLARE_ASN1_FUNCTIONS(OCSP_REQUEST)
538 DECLARE_ASN1_FUNCTIONS(OCSP_SIGNATURE)
539 DECLARE_ASN1_FUNCTIONS(OCSP_REQINFO)
540 DECLARE_ASN1_FUNCTIONS(OCSP_CRLID)
541 DECLARE_ASN1_FUNCTIONS(OCSP_SERVICELOC)
542
543 char *OCSP_response_status_str(long s);
544 char *OCSP_cert_status_str(long s);
545 char *OCSP_crl_reason_str(long s);
546
547 int OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST* a, unsigned long flags);
548 int OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE* o, unsigned long flags);
549
550 int OCSP_basic_verify(OCSP_BASICRESP *bs, STACK_OF(X509) *certs,
551                                 X509_STORE *st, unsigned long flags);
552
553 void ERR_load_OCSP_strings(void);
554
555 /* BEGIN ERROR CODES */
556 /* The following lines are auto generated by the script mkerr.pl. Any changes
557  * made after this point may be overwritten when the script is next run.
558  */
559
560 /* Error codes for the OCSP functions. */
561
562 /* Function codes. */
563 #define OCSP_F_ASN1_STRING_ENCODE                        106
564 #define OCSP_F_BASIC_RESPONSE_NEW                        100
565 #define OCSP_F_BASIC_RESPONSE_VERIFY                     101
566 #define OCSP_F_CERT_ID_NEW                               102
567 #define OCSP_F_CERT_STATUS_NEW                           103
568 #define OCSP_F_D2I_OCSP_NONCE                            109
569 #define OCSP_F_OCSP_BASIC_VERIFY                         113
570 #define OCSP_F_OCSP_CHECK_DELEGATED                      117
571 #define OCSP_F_OCSP_CHECK_IDS                            114
572 #define OCSP_F_OCSP_CHECK_ISSUER                         115
573 #define OCSP_F_OCSP_CHECK_NONCE                          112
574 #define OCSP_F_OCSP_MATCH_ISSUERID                       116
575 #define OCSP_F_OCSP_RESPONSE_GET1_BASIC                  111
576 #define OCSP_F_OCSP_SENDREQ_BIO                          110
577 #define OCSP_F_REQUEST_VERIFY                            104
578 #define OCSP_F_RESPONSE_VERIFY                           105
579 #define OCSP_F_S2I_OCSP_NONCE                            107
580 #define OCSP_F_V2I_OCSP_CRLID                            108
581
582 /* Reason codes. */
583 #define OCSP_R_BAD_DATA                                  108
584 #define OCSP_R_BAD_TAG                                   100
585 #define OCSP_R_CERTIFICATE_VERIFY_ERROR                  126
586 #define OCSP_R_DIGEST_ERR                                101
587 #define OCSP_R_FAILED_TO_OPEN                            109
588 #define OCSP_R_FAILED_TO_READ                            110
589 #define OCSP_R_FAILED_TO_STAT                            111
590 #define OCSP_R_MISSING_OCSPSIGNING_USAGE                 131
591 #define OCSP_R_MISSING_VALUE                             112
592 #define OCSP_R_NONCE_MISSING_IN_RESPONSE                 121
593 #define OCSP_R_NONCE_VALUE_MISMATCH                      122
594 #define OCSP_R_NOT_BASIC_RESPONSE                        120
595 #define OCSP_R_NO_CERTIFICATE                            102
596 #define OCSP_R_NO_CERTIFICATES_IN_CHAIN                  128
597 #define OCSP_R_NO_CONTENT                                115
598 #define OCSP_R_NO_PUBLIC_KEY                             103
599 #define OCSP_R_NO_RESPONSE_DATA                          104
600 #define OCSP_R_NO_SIGNATURE                              105
601 #define OCSP_R_RESPONSE_CONTAINS_NO_REVOCATION_DATA      129
602 #define OCSP_R_REVOKED_NO_TIME                           106
603 #define OCSP_R_ROOT_CA_NOT_TRUSTED                       127
604 #define OCSP_R_SERVER_READ_ERROR                         116
605 #define OCSP_R_SERVER_RESPONSE_ERROR                     117
606 #define OCSP_R_SERVER_RESPONSE_PARSE_ERROR               118
607 #define OCSP_R_SERVER_WRITE_ERROR                        119
608 #define OCSP_R_SIGNATURE_FAILURE                         124
609 #define OCSP_R_SIGNER_CERTIFICATE_NOT_FOUND              125
610 #define OCSP_R_UNEXPECTED_NONCE_IN_RESPONSE              123
611 #define OCSP_R_UNKNOWN_MESSAGE_DIGEST                    130
612 #define OCSP_R_UNKNOWN_NID                               107
613 #define OCSP_R_UNSUPPORTED_OPTION                        113
614 #define OCSP_R_VALUE_ALREADY                             114
615
616 #ifdef  __cplusplus
617 }
618 #endif
619 #endif
620