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