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