ocsp.h 23 KB

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