ocsp.h revision 296465
1/* ocsp.h */
2/*
3 * Written by Tom Titchener <Tom_Titchener@groove.net> for the OpenSSL
4 * project.
5 */
6
7/*
8 * History: This file was transfered to Richard Levitte from CertCo by Kathy
9 * Weinhold in mid-spring 2000 to be included in OpenSSL or released as a
10 * patch kit.
11 */
12
13/* ====================================================================
14 * Copyright (c) 1998-2000 The OpenSSL Project.  All rights reserved.
15 *
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
18 * are met:
19 *
20 * 1. Redistributions of source code must retain the above copyright
21 *    notice, this list of conditions and the following disclaimer.
22 *
23 * 2. Redistributions in binary form must reproduce the above copyright
24 *    notice, this list of conditions and the following disclaimer in
25 *    the documentation and/or other materials provided with the
26 *    distribution.
27 *
28 * 3. All advertising materials mentioning features or use of this
29 *    software must display the following acknowledgment:
30 *    "This product includes software developed by the OpenSSL Project
31 *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
32 *
33 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
34 *    endorse or promote products derived from this software without
35 *    prior written permission. For written permission, please contact
36 *    openssl-core@openssl.org.
37 *
38 * 5. Products derived from this software may not be called "OpenSSL"
39 *    nor may "OpenSSL" appear in their names without prior written
40 *    permission of the OpenSSL Project.
41 *
42 * 6. Redistributions of any form whatsoever must retain the following
43 *    acknowledgment:
44 *    "This product includes software developed by the OpenSSL Project
45 *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
46 *
47 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
48 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
50 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
51 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
52 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
53 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
54 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
56 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
57 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
58 * OF THE POSSIBILITY OF SUCH DAMAGE.
59 * ====================================================================
60 *
61 * This product includes cryptographic software written by Eric Young
62 * (eay@cryptsoft.com).  This product includes software written by Tim
63 * Hudson (tjh@cryptsoft.com).
64 *
65 */
66
67#ifndef HEADER_OCSP_H
68# define HEADER_OCSP_H
69
70# include <openssl/x509.h>
71# include <openssl/x509v3.h>
72# include <openssl/safestack.h>
73
74#ifdef  __cplusplus
75extern "C" {
76#endif
77
78/* Various flags and values */
79
80# define OCSP_DEFAULT_NONCE_LENGTH       16
81
82# define OCSP_NOCERTS                    0x1
83# define OCSP_NOINTERN                   0x2
84# define OCSP_NOSIGS                     0x4
85# define OCSP_NOCHAIN                    0x8
86# define OCSP_NOVERIFY                   0x10
87# define OCSP_NOEXPLICIT                 0x20
88# define OCSP_NOCASIGN                   0x40
89# define OCSP_NODELEGATED                0x80
90# define OCSP_NOCHECKS                   0x100
91# define OCSP_TRUSTOTHER                 0x200
92# define OCSP_RESPID_KEY                 0x400
93# define OCSP_NOTIME                     0x800
94
95/*-  CertID ::= SEQUENCE {
96 *       hashAlgorithm            AlgorithmIdentifier,
97 *       issuerNameHash     OCTET STRING, -- Hash of Issuer's DN
98 *       issuerKeyHash      OCTET STRING, -- Hash of Issuers public key (excluding the tag & length fields)
99 *       serialNumber       CertificateSerialNumber }
100 */
101typedef struct ocsp_cert_id_st {
102    X509_ALGOR *hashAlgorithm;
103    ASN1_OCTET_STRING *issuerNameHash;
104    ASN1_OCTET_STRING *issuerKeyHash;
105    ASN1_INTEGER *serialNumber;
106} OCSP_CERTID;
107
108DECLARE_STACK_OF(OCSP_CERTID)
109
110/*-  Request ::=     SEQUENCE {
111 *       reqCert                    CertID,
112 *       singleRequestExtensions    [0] EXPLICIT Extensions OPTIONAL }
113 */
114typedef struct ocsp_one_request_st {
115    OCSP_CERTID *reqCert;
116    STACK_OF(X509_EXTENSION) *singleRequestExtensions;
117} OCSP_ONEREQ;
118
119DECLARE_STACK_OF(OCSP_ONEREQ)
120DECLARE_ASN1_SET_OF(OCSP_ONEREQ)
121
122/*-  TBSRequest      ::=     SEQUENCE {
123 *       version             [0] EXPLICIT Version DEFAULT v1,
124 *       requestorName       [1] EXPLICIT GeneralName OPTIONAL,
125 *       requestList             SEQUENCE OF Request,
126 *       requestExtensions   [2] EXPLICIT Extensions OPTIONAL }
127 */
128typedef struct ocsp_req_info_st {
129    ASN1_INTEGER *version;
130    GENERAL_NAME *requestorName;
131    STACK_OF(OCSP_ONEREQ) *requestList;
132    STACK_OF(X509_EXTENSION) *requestExtensions;
133} OCSP_REQINFO;
134
135/*-  Signature       ::=     SEQUENCE {
136 *       signatureAlgorithm   AlgorithmIdentifier,
137 *       signature            BIT STRING,
138 *       certs                [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }
139 */
140typedef struct ocsp_signature_st {
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 */
150typedef struct ocsp_request_st {
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 */
176typedef struct ocsp_resp_bytes_st {
177    ASN1_OBJECT *responseType;
178    ASN1_OCTET_STRING *response;
179} OCSP_RESPBYTES;
180
181/*-  OCSPResponse ::= SEQUENCE {
182 *      responseStatus         OCSPResponseStatus,
183 *      responseBytes          [0] EXPLICIT ResponseBytes OPTIONAL }
184 */
185struct ocsp_response_st {
186    ASN1_ENUMERATED *responseStatus;
187    OCSP_RESPBYTES *responseBytes;
188};
189
190/*-  ResponderID ::= CHOICE {
191 *      byName   [1] Name,
192 *      byKey    [2] KeyHash }
193 */
194# define V_OCSP_RESPID_NAME 0
195# define V_OCSP_RESPID_KEY  1
196struct ocsp_responder_id_st {
197    int type;
198    union {
199        X509_NAME *byName;
200        ASN1_OCTET_STRING *byKey;
201    } value;
202};
203
204DECLARE_STACK_OF(OCSP_RESPID)
205DECLARE_ASN1_FUNCTIONS(OCSP_RESPID)
206
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 */
215typedef struct ocsp_revoked_info_st {
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
228typedef struct ocsp_cert_status_st {
229    int type;
230    union {
231        ASN1_NULL *good;
232        OCSP_REVOKEDINFO *revoked;
233        ASN1_NULL *unknown;
234    } value;
235} OCSP_CERTSTATUS;
236
237/*-  SingleResponse ::= SEQUENCE {
238 *      certID                       CertID,
239 *      certStatus                   CertStatus,
240 *      thisUpdate                   GeneralizedTime,
241 *      nextUpdate           [0]     EXPLICIT GeneralizedTime OPTIONAL,
242 *      singleExtensions     [1]     EXPLICIT Extensions OPTIONAL }
243 */
244typedef struct ocsp_single_response_st {
245    OCSP_CERTID *certId;
246    OCSP_CERTSTATUS *certStatus;
247    ASN1_GENERALIZEDTIME *thisUpdate;
248    ASN1_GENERALIZEDTIME *nextUpdate;
249    STACK_OF(X509_EXTENSION) *singleExtensions;
250} OCSP_SINGLERESP;
251
252DECLARE_STACK_OF(OCSP_SINGLERESP)
253DECLARE_ASN1_SET_OF(OCSP_SINGLERESP)
254
255/*-  ResponseData ::= SEQUENCE {
256 *      version              [0] EXPLICIT Version DEFAULT v1,
257 *      responderID              ResponderID,
258 *      producedAt               GeneralizedTime,
259 *      responses                SEQUENCE OF SingleResponse,
260 *      responseExtensions   [1] EXPLICIT Extensions OPTIONAL }
261 */
262typedef struct ocsp_response_data_st {
263    ASN1_INTEGER *version;
264    OCSP_RESPID *responderId;
265    ASN1_GENERALIZEDTIME *producedAt;
266    STACK_OF(OCSP_SINGLERESP) *responses;
267    STACK_OF(X509_EXTENSION) *responseExtensions;
268} OCSP_RESPDATA;
269
270/*-  BasicOCSPResponse       ::= SEQUENCE {
271 *      tbsResponseData      ResponseData,
272 *      signatureAlgorithm   AlgorithmIdentifier,
273 *      signature            BIT STRING,
274 *      certs                [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }
275 */
276  /*
277   * Note 1: The value for "signature" is specified in the OCSP rfc2560 as
278   * follows: "The value for the signature SHALL be computed on the hash of
279   * the DER encoding ResponseData." This means that you must hash the
280   * DER-encoded tbsResponseData, and then run it through a crypto-signing
281   * function, which will (at least w/RSA) do a hash-'n'-private-encrypt
282   * operation.  This seems a bit odd, but that's the spec.  Also note that
283   * the data structures do not leave anywhere to independently specify the
284   * algorithm used for the initial hash. So, we look at the
285   * signature-specification algorithm, and try to do something intelligent.
286   * -- Kathy Weinhold, CertCo
287   */
288  /*
289   * Note 2: It seems that the mentioned passage from RFC 2560 (section
290   * 4.2.1) is open for interpretation.  I've done tests against another
291   * responder, and found that it doesn't do the double hashing that the RFC
292   * seems to say one should.  Therefore, all relevant functions take a flag
293   * saying which variant should be used.  -- Richard Levitte, OpenSSL team
294   * and CeloCom
295   */
296typedef struct ocsp_basic_response_st {
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/*-
325 * CrlID ::= SEQUENCE {
326 *     crlUrl               [0]     EXPLICIT IA5String OPTIONAL,
327 *     crlNum               [1]     EXPLICIT INTEGER OPTIONAL,
328 *     crlTime              [2]     EXPLICIT GeneralizedTime OPTIONAL }
329 */
330typedef struct ocsp_crl_id_st {
331    ASN1_IA5STRING *crlUrl;
332    ASN1_INTEGER *crlNum;
333    ASN1_GENERALIZEDTIME *crlTime;
334} OCSP_CRLID;
335
336/*-
337 * ServiceLocator ::= SEQUENCE {
338 *      issuer    Name,
339 *      locator   AuthorityInfoAccessSyntax OPTIONAL }
340 */
341typedef struct ocsp_service_locator_st {
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) ASN1_d2i_bio_of(OCSP_REQUEST,OCSP_REQUEST_new,d2i_OCSP_REQUEST,bp,p)
350
351# define d2i_OCSP_RESPONSE_bio(bp,p) ASN1_d2i_bio_of(OCSP_RESPONSE,OCSP_RESPONSE_new,d2i_OCSP_RESPONSE,bp,p)
352
353# define PEM_read_bio_OCSP_REQUEST(bp,x,cb) (OCSP_REQUEST *)PEM_ASN1_read_bio( \
354     (char *(*)())d2i_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,bp,(char **)x,cb,NULL)
355
356# define PEM_read_bio_OCSP_RESPONSE(bp,x,cb)(OCSP_RESPONSE *)PEM_ASN1_read_bio(\
357     (char *(*)())d2i_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,bp,(char **)x,cb,NULL)
358
359# define PEM_write_bio_OCSP_REQUEST(bp,o) \
360    PEM_ASN1_write_bio((int (*)())i2d_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,\
361                        bp,(char *)o, NULL,NULL,0,NULL,NULL)
362
363# define PEM_write_bio_OCSP_RESPONSE(bp,o) \
364    PEM_ASN1_write_bio((int (*)())i2d_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,\
365                        bp,(char *)o, NULL,NULL,0,NULL,NULL)
366
367# define i2d_OCSP_RESPONSE_bio(bp,o) ASN1_i2d_bio_of(OCSP_RESPONSE,i2d_OCSP_RESPONSE,bp,o)
368
369# define i2d_OCSP_REQUEST_bio(bp,o) ASN1_i2d_bio_of(OCSP_REQUEST,i2d_OCSP_REQUEST,bp,o)
370
371# define OCSP_REQUEST_sign(o,pkey,md) \
372        ASN1_item_sign(ASN1_ITEM_rptr(OCSP_REQINFO),\
373                o->optionalSignature->signatureAlgorithm,NULL,\
374                o->optionalSignature->signature,o->tbsRequest,pkey,md)
375
376# define OCSP_BASICRESP_sign(o,pkey,md,d) \
377        ASN1_item_sign(ASN1_ITEM_rptr(OCSP_RESPDATA),o->signatureAlgorithm,NULL,\
378                o->signature,o->tbsResponseData,pkey,md)
379
380# define OCSP_REQUEST_verify(a,r) ASN1_item_verify(ASN1_ITEM_rptr(OCSP_REQINFO),\
381        a->optionalSignature->signatureAlgorithm,\
382        a->optionalSignature->signature,a->tbsRequest,r)
383
384# define OCSP_BASICRESP_verify(a,r,d) ASN1_item_verify(ASN1_ITEM_rptr(OCSP_RESPDATA),\
385        a->signatureAlgorithm,a->signature,a->tbsResponseData,r)
386
387# define ASN1_BIT_STRING_digest(data,type,md,len) \
388        ASN1_item_digest(ASN1_ITEM_rptr(ASN1_BIT_STRING),type,data,md,len)
389
390# define OCSP_CERTID_dup(cid) ASN1_dup_of(OCSP_CERTID,i2d_OCSP_CERTID,d2i_OCSP_CERTID,cid)
391
392# define OCSP_CERTSTATUS_dup(cs)\
393                (OCSP_CERTSTATUS*)ASN1_dup((int(*)())i2d_OCSP_CERTSTATUS,\
394                (char *(*)())d2i_OCSP_CERTSTATUS,(char *)(cs))
395
396OCSP_RESPONSE *OCSP_sendreq_bio(BIO *b, char *path, OCSP_REQUEST *req);
397OCSP_REQ_CTX *OCSP_sendreq_new(BIO *io, char *path, OCSP_REQUEST *req,
398                               int maxline);
399int OCSP_sendreq_nbio(OCSP_RESPONSE **presp, OCSP_REQ_CTX *rctx);
400void OCSP_REQ_CTX_free(OCSP_REQ_CTX *rctx);
401
402OCSP_CERTID *OCSP_cert_to_id(const EVP_MD *dgst, X509 *subject, X509 *issuer);
403
404OCSP_CERTID *OCSP_cert_id_new(const EVP_MD *dgst,
405                              X509_NAME *issuerName,
406                              ASN1_BIT_STRING *issuerKey,
407                              ASN1_INTEGER *serialNumber);
408
409OCSP_ONEREQ *OCSP_request_add0_id(OCSP_REQUEST *req, OCSP_CERTID *cid);
410
411int OCSP_request_add1_nonce(OCSP_REQUEST *req, unsigned char *val, int len);
412int OCSP_basic_add1_nonce(OCSP_BASICRESP *resp, unsigned char *val, int len);
413int OCSP_check_nonce(OCSP_REQUEST *req, OCSP_BASICRESP *bs);
414int OCSP_copy_nonce(OCSP_BASICRESP *resp, OCSP_REQUEST *req);
415
416int OCSP_request_set1_name(OCSP_REQUEST *req, X509_NAME *nm);
417int OCSP_request_add1_cert(OCSP_REQUEST *req, X509 *cert);
418
419int OCSP_request_sign(OCSP_REQUEST *req,
420                      X509 *signer,
421                      EVP_PKEY *key,
422                      const EVP_MD *dgst,
423                      STACK_OF(X509) *certs, unsigned long flags);
424
425int OCSP_response_status(OCSP_RESPONSE *resp);
426OCSP_BASICRESP *OCSP_response_get1_basic(OCSP_RESPONSE *resp);
427
428int OCSP_resp_count(OCSP_BASICRESP *bs);
429OCSP_SINGLERESP *OCSP_resp_get0(OCSP_BASICRESP *bs, int idx);
430int OCSP_resp_find(OCSP_BASICRESP *bs, OCSP_CERTID *id, int last);
431int OCSP_single_get0_status(OCSP_SINGLERESP *single, int *reason,
432                            ASN1_GENERALIZEDTIME **revtime,
433                            ASN1_GENERALIZEDTIME **thisupd,
434                            ASN1_GENERALIZEDTIME **nextupd);
435int OCSP_resp_find_status(OCSP_BASICRESP *bs, OCSP_CERTID *id, int *status,
436                          int *reason,
437                          ASN1_GENERALIZEDTIME **revtime,
438                          ASN1_GENERALIZEDTIME **thisupd,
439                          ASN1_GENERALIZEDTIME **nextupd);
440int OCSP_check_validity(ASN1_GENERALIZEDTIME *thisupd,
441                        ASN1_GENERALIZEDTIME *nextupd, long sec, long maxsec);
442
443int OCSP_request_verify(OCSP_REQUEST *req, STACK_OF(X509) *certs,
444                        X509_STORE *store, unsigned long flags);
445
446int OCSP_parse_url(char *url, char **phost, char **pport, char **ppath,
447                   int *pssl);
448
449int OCSP_id_issuer_cmp(OCSP_CERTID *a, OCSP_CERTID *b);
450int OCSP_id_cmp(OCSP_CERTID *a, OCSP_CERTID *b);
451
452int OCSP_request_onereq_count(OCSP_REQUEST *req);
453OCSP_ONEREQ *OCSP_request_onereq_get0(OCSP_REQUEST *req, int i);
454OCSP_CERTID *OCSP_onereq_get0_id(OCSP_ONEREQ *one);
455int OCSP_id_get0_info(ASN1_OCTET_STRING **piNameHash, ASN1_OBJECT **pmd,
456                      ASN1_OCTET_STRING **pikeyHash,
457                      ASN1_INTEGER **pserial, OCSP_CERTID *cid);
458int OCSP_request_is_signed(OCSP_REQUEST *req);
459OCSP_RESPONSE *OCSP_response_create(int status, OCSP_BASICRESP *bs);
460OCSP_SINGLERESP *OCSP_basic_add1_status(OCSP_BASICRESP *rsp,
461                                        OCSP_CERTID *cid,
462                                        int status, int reason,
463                                        ASN1_TIME *revtime,
464                                        ASN1_TIME *thisupd,
465                                        ASN1_TIME *nextupd);
466int OCSP_basic_add1_cert(OCSP_BASICRESP *resp, X509 *cert);
467int OCSP_basic_sign(OCSP_BASICRESP *brsp,
468                    X509 *signer, EVP_PKEY *key, const EVP_MD *dgst,
469                    STACK_OF(X509) *certs, unsigned long flags);
470
471ASN1_STRING *ASN1_STRING_encode(ASN1_STRING *s, i2d_of_void *i2d,
472                                void *data, STACK_OF(ASN1_OBJECT) *sk);
473# define ASN1_STRING_encode_of(type,s,i2d,data,sk) \
474        ASN1_STRING_encode(s, CHECKED_I2D_OF(type, i2d), data, sk)
475
476X509_EXTENSION *OCSP_crlID_new(char *url, long *n, char *tim);
477
478X509_EXTENSION *OCSP_accept_responses_new(char **oids);
479
480X509_EXTENSION *OCSP_archive_cutoff_new(char *tim);
481
482X509_EXTENSION *OCSP_url_svcloc_new(X509_NAME *issuer, char **urls);
483
484int OCSP_REQUEST_get_ext_count(OCSP_REQUEST *x);
485int OCSP_REQUEST_get_ext_by_NID(OCSP_REQUEST *x, int nid, int lastpos);
486int OCSP_REQUEST_get_ext_by_OBJ(OCSP_REQUEST *x, ASN1_OBJECT *obj,
487                                int lastpos);
488int OCSP_REQUEST_get_ext_by_critical(OCSP_REQUEST *x, int crit, int lastpos);
489X509_EXTENSION *OCSP_REQUEST_get_ext(OCSP_REQUEST *x, int loc);
490X509_EXTENSION *OCSP_REQUEST_delete_ext(OCSP_REQUEST *x, int loc);
491void *OCSP_REQUEST_get1_ext_d2i(OCSP_REQUEST *x, int nid, int *crit,
492                                int *idx);
493int OCSP_REQUEST_add1_ext_i2d(OCSP_REQUEST *x, int nid, void *value, int crit,
494                              unsigned long flags);
495int OCSP_REQUEST_add_ext(OCSP_REQUEST *x, X509_EXTENSION *ex, int loc);
496
497int OCSP_ONEREQ_get_ext_count(OCSP_ONEREQ *x);
498int OCSP_ONEREQ_get_ext_by_NID(OCSP_ONEREQ *x, int nid, int lastpos);
499int OCSP_ONEREQ_get_ext_by_OBJ(OCSP_ONEREQ *x, ASN1_OBJECT *obj, int lastpos);
500int OCSP_ONEREQ_get_ext_by_critical(OCSP_ONEREQ *x, int crit, int lastpos);
501X509_EXTENSION *OCSP_ONEREQ_get_ext(OCSP_ONEREQ *x, int loc);
502X509_EXTENSION *OCSP_ONEREQ_delete_ext(OCSP_ONEREQ *x, int loc);
503void *OCSP_ONEREQ_get1_ext_d2i(OCSP_ONEREQ *x, int nid, int *crit, int *idx);
504int OCSP_ONEREQ_add1_ext_i2d(OCSP_ONEREQ *x, int nid, void *value, int crit,
505                             unsigned long flags);
506int OCSP_ONEREQ_add_ext(OCSP_ONEREQ *x, X509_EXTENSION *ex, int loc);
507
508int OCSP_BASICRESP_get_ext_count(OCSP_BASICRESP *x);
509int OCSP_BASICRESP_get_ext_by_NID(OCSP_BASICRESP *x, int nid, int lastpos);
510int OCSP_BASICRESP_get_ext_by_OBJ(OCSP_BASICRESP *x, ASN1_OBJECT *obj,
511                                  int lastpos);
512int OCSP_BASICRESP_get_ext_by_critical(OCSP_BASICRESP *x, int crit,
513                                       int lastpos);
514X509_EXTENSION *OCSP_BASICRESP_get_ext(OCSP_BASICRESP *x, int loc);
515X509_EXTENSION *OCSP_BASICRESP_delete_ext(OCSP_BASICRESP *x, int loc);
516void *OCSP_BASICRESP_get1_ext_d2i(OCSP_BASICRESP *x, int nid, int *crit,
517                                  int *idx);
518int OCSP_BASICRESP_add1_ext_i2d(OCSP_BASICRESP *x, int nid, void *value,
519                                int crit, unsigned long flags);
520int OCSP_BASICRESP_add_ext(OCSP_BASICRESP *x, X509_EXTENSION *ex, int loc);
521
522int OCSP_SINGLERESP_get_ext_count(OCSP_SINGLERESP *x);
523int OCSP_SINGLERESP_get_ext_by_NID(OCSP_SINGLERESP *x, int nid, int lastpos);
524int OCSP_SINGLERESP_get_ext_by_OBJ(OCSP_SINGLERESP *x, ASN1_OBJECT *obj,
525                                   int lastpos);
526int OCSP_SINGLERESP_get_ext_by_critical(OCSP_SINGLERESP *x, int crit,
527                                        int lastpos);
528X509_EXTENSION *OCSP_SINGLERESP_get_ext(OCSP_SINGLERESP *x, int loc);
529X509_EXTENSION *OCSP_SINGLERESP_delete_ext(OCSP_SINGLERESP *x, int loc);
530void *OCSP_SINGLERESP_get1_ext_d2i(OCSP_SINGLERESP *x, int nid, int *crit,
531                                   int *idx);
532int OCSP_SINGLERESP_add1_ext_i2d(OCSP_SINGLERESP *x, int nid, void *value,
533                                 int crit, unsigned long flags);
534int OCSP_SINGLERESP_add_ext(OCSP_SINGLERESP *x, X509_EXTENSION *ex, int loc);
535
536DECLARE_ASN1_FUNCTIONS(OCSP_SINGLERESP)
537DECLARE_ASN1_FUNCTIONS(OCSP_CERTSTATUS)
538DECLARE_ASN1_FUNCTIONS(OCSP_REVOKEDINFO)
539DECLARE_ASN1_FUNCTIONS(OCSP_BASICRESP)
540DECLARE_ASN1_FUNCTIONS(OCSP_RESPDATA)
541DECLARE_ASN1_FUNCTIONS(OCSP_RESPID)
542DECLARE_ASN1_FUNCTIONS(OCSP_RESPONSE)
543DECLARE_ASN1_FUNCTIONS(OCSP_RESPBYTES)
544DECLARE_ASN1_FUNCTIONS(OCSP_ONEREQ)
545DECLARE_ASN1_FUNCTIONS(OCSP_CERTID)
546DECLARE_ASN1_FUNCTIONS(OCSP_REQUEST)
547DECLARE_ASN1_FUNCTIONS(OCSP_SIGNATURE)
548DECLARE_ASN1_FUNCTIONS(OCSP_REQINFO)
549DECLARE_ASN1_FUNCTIONS(OCSP_CRLID)
550DECLARE_ASN1_FUNCTIONS(OCSP_SERVICELOC)
551
552char *OCSP_response_status_str(long s);
553char *OCSP_cert_status_str(long s);
554char *OCSP_crl_reason_str(long s);
555
556int OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST *a, unsigned long flags);
557int OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE *o, unsigned long flags);
558
559int OCSP_basic_verify(OCSP_BASICRESP *bs, STACK_OF(X509) *certs,
560                      X509_STORE *st, unsigned long flags);
561
562/* BEGIN ERROR CODES */
563/*
564 * The following lines are auto generated by the script mkerr.pl. Any changes
565 * made after this point may be overwritten when the script is next run.
566 */
567void ERR_load_OCSP_strings(void);
568
569/* Error codes for the OCSP functions. */
570
571/* Function codes. */
572# define OCSP_F_ASN1_STRING_ENCODE                        100
573# define OCSP_F_D2I_OCSP_NONCE                            102
574# define OCSP_F_OCSP_BASIC_ADD1_STATUS                    103
575# define OCSP_F_OCSP_BASIC_SIGN                           104
576# define OCSP_F_OCSP_BASIC_VERIFY                         105
577# define OCSP_F_OCSP_CERT_ID_NEW                          101
578# define OCSP_F_OCSP_CHECK_DELEGATED                      106
579# define OCSP_F_OCSP_CHECK_IDS                            107
580# define OCSP_F_OCSP_CHECK_ISSUER                         108
581# define OCSP_F_OCSP_CHECK_VALIDITY                       115
582# define OCSP_F_OCSP_MATCH_ISSUERID                       109
583# define OCSP_F_OCSP_PARSE_URL                            114
584# define OCSP_F_OCSP_REQUEST_SIGN                         110
585# define OCSP_F_OCSP_REQUEST_VERIFY                       116
586# define OCSP_F_OCSP_RESPONSE_GET1_BASIC                  111
587# define OCSP_F_OCSP_SENDREQ_BIO                          112
588# define OCSP_F_PARSE_HTTP_LINE1                          117
589# define OCSP_F_REQUEST_VERIFY                            113
590
591/* Reason codes. */
592# define OCSP_R_BAD_DATA                                  100
593# define OCSP_R_CERTIFICATE_VERIFY_ERROR                  101
594# define OCSP_R_DIGEST_ERR                                102
595# define OCSP_R_ERROR_IN_NEXTUPDATE_FIELD                 122
596# define OCSP_R_ERROR_IN_THISUPDATE_FIELD                 123
597# define OCSP_R_ERROR_PARSING_URL                         121
598# define OCSP_R_MISSING_OCSPSIGNING_USAGE                 103
599# define OCSP_R_NEXTUPDATE_BEFORE_THISUPDATE              124
600# define OCSP_R_NOT_BASIC_RESPONSE                        104
601# define OCSP_R_NO_CERTIFICATES_IN_CHAIN                  105
602# define OCSP_R_NO_CONTENT                                106
603# define OCSP_R_NO_PUBLIC_KEY                             107
604# define OCSP_R_NO_RESPONSE_DATA                          108
605# define OCSP_R_NO_REVOKED_TIME                           109
606# define OCSP_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE    110
607# define OCSP_R_REQUEST_NOT_SIGNED                        128
608# define OCSP_R_RESPONSE_CONTAINS_NO_REVOCATION_DATA      111
609# define OCSP_R_ROOT_CA_NOT_TRUSTED                       112
610# define OCSP_R_SERVER_READ_ERROR                         113
611# define OCSP_R_SERVER_RESPONSE_ERROR                     114
612# define OCSP_R_SERVER_RESPONSE_PARSE_ERROR               115
613# define OCSP_R_SERVER_WRITE_ERROR                        116
614# define OCSP_R_SIGNATURE_FAILURE                         117
615# define OCSP_R_SIGNER_CERTIFICATE_NOT_FOUND              118
616# define OCSP_R_STATUS_EXPIRED                            125
617# define OCSP_R_STATUS_NOT_YET_VALID                      126
618# define OCSP_R_STATUS_TOO_OLD                            127
619# define OCSP_R_UNKNOWN_MESSAGE_DIGEST                    119
620# define OCSP_R_UNKNOWN_NID                               120
621# define OCSP_R_UNSUPPORTED_REQUESTORNAME_TYPE            129
622
623#ifdef  __cplusplus
624}
625#endif
626#endif
627