2
0

ocsp.h 23 KB

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