2
0

ocsp.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  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) ASN1_d2i_bio_of(OCSP_REQUEST,OCSP_REQUEST_new,d2i_OCSP_REQUEST,bp,p)
  322. #define d2i_OCSP_RESPONSE_bio(bp,p) ASN1_d2i_bio_of(OCSP_RESPONSE,OCSP_RESPONSE_new,d2i_OCSP_RESPONSE,bp,p)
  323. #define PEM_read_bio_OCSP_REQUEST(bp,x,cb) (OCSP_REQUEST *)PEM_ASN1_read_bio( \
  324. (char *(*)())d2i_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,bp,(char **)x,cb,NULL)
  325. #define PEM_read_bio_OCSP_RESPONSE(bp,x,cb)(OCSP_RESPONSE *)PEM_ASN1_read_bio(\
  326. (char *(*)())d2i_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,bp,(char **)x,cb,NULL)
  327. #define PEM_write_bio_OCSP_REQUEST(bp,o) \
  328. PEM_ASN1_write_bio((int (*)())i2d_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,\
  329. bp,(char *)o, NULL,NULL,0,NULL,NULL)
  330. #define PEM_write_bio_OCSP_RESPONSE(bp,o) \
  331. PEM_ASN1_write_bio((int (*)())i2d_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,\
  332. bp,(char *)o, NULL,NULL,0,NULL,NULL)
  333. #define i2d_OCSP_RESPONSE_bio(bp,o) ASN1_i2d_bio_of(OCSP_RESPONSE,i2d_OCSP_RESPONSE,bp,o)
  334. #define i2d_OCSP_REQUEST_bio(bp,o) ASN1_i2d_bio_of(OCSP_REQUEST,i2d_OCSP_REQUEST,bp,o)
  335. #define OCSP_REQUEST_sign(o,pkey,md) \
  336. ASN1_item_sign(ASN1_ITEM_rptr(OCSP_REQINFO),\
  337. o->optionalSignature->signatureAlgorithm,NULL,\
  338. o->optionalSignature->signature,o->tbsRequest,pkey,md)
  339. #define OCSP_BASICRESP_sign(o,pkey,md,d) \
  340. ASN1_item_sign(ASN1_ITEM_rptr(OCSP_RESPDATA),o->signatureAlgorithm,NULL,\
  341. o->signature,o->tbsResponseData,pkey,md)
  342. #define OCSP_REQUEST_verify(a,r) ASN1_item_verify(ASN1_ITEM_rptr(OCSP_REQINFO),\
  343. a->optionalSignature->signatureAlgorithm,\
  344. a->optionalSignature->signature,a->tbsRequest,r)
  345. #define OCSP_BASICRESP_verify(a,r,d) ASN1_item_verify(ASN1_ITEM_rptr(OCSP_RESPDATA),\
  346. a->signatureAlgorithm,a->signature,a->tbsResponseData,r)
  347. #define ASN1_BIT_STRING_digest(data,type,md,len) \
  348. ASN1_item_digest(ASN1_ITEM_rptr(ASN1_BIT_STRING),type,data,md,len)
  349. #define OCSP_CERTID_dup(cid) ASN1_dup_of(OCSP_CERTID,i2d_OCSP_CERTID,d2i_OCSP_CERTID,cid)
  350. #define OCSP_CERTSTATUS_dup(cs)\
  351. (OCSP_CERTSTATUS*)ASN1_dup((int(*)())i2d_OCSP_CERTSTATUS,\
  352. (char *(*)())d2i_OCSP_CERTSTATUS,(char *)(cs))
  353. OCSP_RESPONSE *OCSP_sendreq_bio(BIO *b, char *path, OCSP_REQUEST *req);
  354. OCSP_CERTID *OCSP_cert_to_id(const EVP_MD *dgst, X509 *subject, X509 *issuer);
  355. OCSP_CERTID *OCSP_cert_id_new(const EVP_MD *dgst,
  356. X509_NAME *issuerName,
  357. ASN1_BIT_STRING* issuerKey,
  358. ASN1_INTEGER *serialNumber);
  359. OCSP_ONEREQ *OCSP_request_add0_id(OCSP_REQUEST *req, OCSP_CERTID *cid);
  360. int OCSP_request_add1_nonce(OCSP_REQUEST *req, unsigned char *val, int len);
  361. int OCSP_basic_add1_nonce(OCSP_BASICRESP *resp, unsigned char *val, int len);
  362. int OCSP_check_nonce(OCSP_REQUEST *req, OCSP_BASICRESP *bs);
  363. int OCSP_copy_nonce(OCSP_BASICRESP *resp, OCSP_REQUEST *req);
  364. int OCSP_request_set1_name(OCSP_REQUEST *req, X509_NAME *nm);
  365. int OCSP_request_add1_cert(OCSP_REQUEST *req, X509 *cert);
  366. int OCSP_request_sign(OCSP_REQUEST *req,
  367. X509 *signer,
  368. EVP_PKEY *key,
  369. const EVP_MD *dgst,
  370. STACK_OF(X509) *certs,
  371. unsigned long flags);
  372. int OCSP_response_status(OCSP_RESPONSE *resp);
  373. OCSP_BASICRESP *OCSP_response_get1_basic(OCSP_RESPONSE *resp);
  374. int OCSP_resp_count(OCSP_BASICRESP *bs);
  375. OCSP_SINGLERESP *OCSP_resp_get0(OCSP_BASICRESP *bs, int idx);
  376. int OCSP_resp_find(OCSP_BASICRESP *bs, OCSP_CERTID *id, int last);
  377. int OCSP_single_get0_status(OCSP_SINGLERESP *single, int *reason,
  378. ASN1_GENERALIZEDTIME **revtime,
  379. ASN1_GENERALIZEDTIME **thisupd,
  380. ASN1_GENERALIZEDTIME **nextupd);
  381. int OCSP_resp_find_status(OCSP_BASICRESP *bs, OCSP_CERTID *id, int *status,
  382. int *reason,
  383. ASN1_GENERALIZEDTIME **revtime,
  384. ASN1_GENERALIZEDTIME **thisupd,
  385. ASN1_GENERALIZEDTIME **nextupd);
  386. int OCSP_check_validity(ASN1_GENERALIZEDTIME *thisupd,
  387. ASN1_GENERALIZEDTIME *nextupd,
  388. long sec, long maxsec);
  389. int OCSP_request_verify(OCSP_REQUEST *req, STACK_OF(X509) *certs, X509_STORE *store, unsigned long flags);
  390. int OCSP_parse_url(char *url, char **phost, char **pport, char **ppath, int *pssl);
  391. int OCSP_id_issuer_cmp(OCSP_CERTID *a, OCSP_CERTID *b);
  392. int OCSP_id_cmp(OCSP_CERTID *a, OCSP_CERTID *b);
  393. int OCSP_request_onereq_count(OCSP_REQUEST *req);
  394. OCSP_ONEREQ *OCSP_request_onereq_get0(OCSP_REQUEST *req, int i);
  395. OCSP_CERTID *OCSP_onereq_get0_id(OCSP_ONEREQ *one);
  396. int OCSP_id_get0_info(ASN1_OCTET_STRING **piNameHash, ASN1_OBJECT **pmd,
  397. ASN1_OCTET_STRING **pikeyHash,
  398. ASN1_INTEGER **pserial, OCSP_CERTID *cid);
  399. int OCSP_request_is_signed(OCSP_REQUEST *req);
  400. OCSP_RESPONSE *OCSP_response_create(int status, OCSP_BASICRESP *bs);
  401. OCSP_SINGLERESP *OCSP_basic_add1_status(OCSP_BASICRESP *rsp,
  402. OCSP_CERTID *cid,
  403. int status, int reason,
  404. ASN1_TIME *revtime,
  405. ASN1_TIME *thisupd, ASN1_TIME *nextupd);
  406. int OCSP_basic_add1_cert(OCSP_BASICRESP *resp, X509 *cert);
  407. int OCSP_basic_sign(OCSP_BASICRESP *brsp,
  408. X509 *signer, EVP_PKEY *key, const EVP_MD *dgst,
  409. STACK_OF(X509) *certs, unsigned long flags);
  410. ASN1_STRING *ASN1_STRING_encode(ASN1_STRING *s, i2d_of_void *i2d,
  411. void *data, STACK_OF(ASN1_OBJECT) *sk);
  412. #define ASN1_STRING_encode_of(type,s,i2d,data,sk) \
  413. ((ASN1_STRING *(*)(ASN1_STRING *,I2D_OF(type),type *,STACK_OF(ASN1_OBJECT) *))openssl_fcast(ASN1_STRING_encode))(s,i2d,data,sk)
  414. X509_EXTENSION *OCSP_crlID_new(char *url, long *n, char *tim);
  415. X509_EXTENSION *OCSP_accept_responses_new(char **oids);
  416. X509_EXTENSION *OCSP_archive_cutoff_new(char* tim);
  417. X509_EXTENSION *OCSP_url_svcloc_new(X509_NAME* issuer, char **urls);
  418. int OCSP_REQUEST_get_ext_count(OCSP_REQUEST *x);
  419. int OCSP_REQUEST_get_ext_by_NID(OCSP_REQUEST *x, int nid, int lastpos);
  420. int OCSP_REQUEST_get_ext_by_OBJ(OCSP_REQUEST *x, ASN1_OBJECT *obj, int lastpos);
  421. int OCSP_REQUEST_get_ext_by_critical(OCSP_REQUEST *x, int crit, int lastpos);
  422. X509_EXTENSION *OCSP_REQUEST_get_ext(OCSP_REQUEST *x, int loc);
  423. X509_EXTENSION *OCSP_REQUEST_delete_ext(OCSP_REQUEST *x, int loc);
  424. void *OCSP_REQUEST_get1_ext_d2i(OCSP_REQUEST *x, int nid, int *crit, int *idx);
  425. int OCSP_REQUEST_add1_ext_i2d(OCSP_REQUEST *x, int nid, void *value, int crit,
  426. unsigned long flags);
  427. int OCSP_REQUEST_add_ext(OCSP_REQUEST *x, X509_EXTENSION *ex, int loc);
  428. int OCSP_ONEREQ_get_ext_count(OCSP_ONEREQ *x);
  429. int OCSP_ONEREQ_get_ext_by_NID(OCSP_ONEREQ *x, int nid, int lastpos);
  430. int OCSP_ONEREQ_get_ext_by_OBJ(OCSP_ONEREQ *x, ASN1_OBJECT *obj, int lastpos);
  431. int OCSP_ONEREQ_get_ext_by_critical(OCSP_ONEREQ *x, int crit, int lastpos);
  432. X509_EXTENSION *OCSP_ONEREQ_get_ext(OCSP_ONEREQ *x, int loc);
  433. X509_EXTENSION *OCSP_ONEREQ_delete_ext(OCSP_ONEREQ *x, int loc);
  434. void *OCSP_ONEREQ_get1_ext_d2i(OCSP_ONEREQ *x, int nid, int *crit, int *idx);
  435. int OCSP_ONEREQ_add1_ext_i2d(OCSP_ONEREQ *x, int nid, void *value, int crit,
  436. unsigned long flags);
  437. int OCSP_ONEREQ_add_ext(OCSP_ONEREQ *x, X509_EXTENSION *ex, int loc);
  438. int OCSP_BASICRESP_get_ext_count(OCSP_BASICRESP *x);
  439. int OCSP_BASICRESP_get_ext_by_NID(OCSP_BASICRESP *x, int nid, int lastpos);
  440. int OCSP_BASICRESP_get_ext_by_OBJ(OCSP_BASICRESP *x, ASN1_OBJECT *obj, int lastpos);
  441. int OCSP_BASICRESP_get_ext_by_critical(OCSP_BASICRESP *x, int crit, int lastpos);
  442. X509_EXTENSION *OCSP_BASICRESP_get_ext(OCSP_BASICRESP *x, int loc);
  443. X509_EXTENSION *OCSP_BASICRESP_delete_ext(OCSP_BASICRESP *x, int loc);
  444. void *OCSP_BASICRESP_get1_ext_d2i(OCSP_BASICRESP *x, int nid, int *crit, int *idx);
  445. int OCSP_BASICRESP_add1_ext_i2d(OCSP_BASICRESP *x, int nid, void *value, int crit,
  446. unsigned long flags);
  447. int OCSP_BASICRESP_add_ext(OCSP_BASICRESP *x, X509_EXTENSION *ex, int loc);
  448. int OCSP_SINGLERESP_get_ext_count(OCSP_SINGLERESP *x);
  449. int OCSP_SINGLERESP_get_ext_by_NID(OCSP_SINGLERESP *x, int nid, int lastpos);
  450. int OCSP_SINGLERESP_get_ext_by_OBJ(OCSP_SINGLERESP *x, ASN1_OBJECT *obj, int lastpos);
  451. int OCSP_SINGLERESP_get_ext_by_critical(OCSP_SINGLERESP *x, int crit, int lastpos);
  452. X509_EXTENSION *OCSP_SINGLERESP_get_ext(OCSP_SINGLERESP *x, int loc);
  453. X509_EXTENSION *OCSP_SINGLERESP_delete_ext(OCSP_SINGLERESP *x, int loc);
  454. void *OCSP_SINGLERESP_get1_ext_d2i(OCSP_SINGLERESP *x, int nid, int *crit, int *idx);
  455. int OCSP_SINGLERESP_add1_ext_i2d(OCSP_SINGLERESP *x, int nid, void *value, int crit,
  456. unsigned long flags);
  457. int OCSP_SINGLERESP_add_ext(OCSP_SINGLERESP *x, X509_EXTENSION *ex, int loc);
  458. DECLARE_ASN1_FUNCTIONS(OCSP_SINGLERESP)
  459. DECLARE_ASN1_FUNCTIONS(OCSP_CERTSTATUS)
  460. DECLARE_ASN1_FUNCTIONS(OCSP_REVOKEDINFO)
  461. DECLARE_ASN1_FUNCTIONS(OCSP_BASICRESP)
  462. DECLARE_ASN1_FUNCTIONS(OCSP_RESPDATA)
  463. DECLARE_ASN1_FUNCTIONS(OCSP_RESPID)
  464. DECLARE_ASN1_FUNCTIONS(OCSP_RESPONSE)
  465. DECLARE_ASN1_FUNCTIONS(OCSP_RESPBYTES)
  466. DECLARE_ASN1_FUNCTIONS(OCSP_ONEREQ)
  467. DECLARE_ASN1_FUNCTIONS(OCSP_CERTID)
  468. DECLARE_ASN1_FUNCTIONS(OCSP_REQUEST)
  469. DECLARE_ASN1_FUNCTIONS(OCSP_SIGNATURE)
  470. DECLARE_ASN1_FUNCTIONS(OCSP_REQINFO)
  471. DECLARE_ASN1_FUNCTIONS(OCSP_CRLID)
  472. DECLARE_ASN1_FUNCTIONS(OCSP_SERVICELOC)
  473. char *OCSP_response_status_str(long s);
  474. char *OCSP_cert_status_str(long s);
  475. char *OCSP_crl_reason_str(long s);
  476. int OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST* a, unsigned long flags);
  477. int OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE* o, unsigned long flags);
  478. int OCSP_basic_verify(OCSP_BASICRESP *bs, STACK_OF(X509) *certs,
  479. X509_STORE *st, unsigned long flags);
  480. /* BEGIN ERROR CODES */
  481. /* The following lines are auto generated by the script mkerr.pl. Any changes
  482. * made after this point may be overwritten when the script is next run.
  483. */
  484. void ERR_load_OCSP_strings(void);
  485. /* Error codes for the OCSP functions. */
  486. /* Function codes. */
  487. #define OCSP_F_ASN1_STRING_ENCODE 100
  488. #define OCSP_F_D2I_OCSP_NONCE 102
  489. #define OCSP_F_OCSP_BASIC_ADD1_STATUS 103
  490. #define OCSP_F_OCSP_BASIC_SIGN 104
  491. #define OCSP_F_OCSP_BASIC_VERIFY 105
  492. #define OCSP_F_OCSP_CERT_ID_NEW 101
  493. #define OCSP_F_OCSP_CHECK_DELEGATED 106
  494. #define OCSP_F_OCSP_CHECK_IDS 107
  495. #define OCSP_F_OCSP_CHECK_ISSUER 108
  496. #define OCSP_F_OCSP_CHECK_VALIDITY 115
  497. #define OCSP_F_OCSP_MATCH_ISSUERID 109
  498. #define OCSP_F_OCSP_PARSE_URL 114
  499. #define OCSP_F_OCSP_REQUEST_SIGN 110
  500. #define OCSP_F_OCSP_REQUEST_VERIFY 116
  501. #define OCSP_F_OCSP_RESPONSE_GET1_BASIC 111
  502. #define OCSP_F_OCSP_SENDREQ_BIO 112
  503. #define OCSP_F_REQUEST_VERIFY 113
  504. /* Reason codes. */
  505. #define OCSP_R_BAD_DATA 100
  506. #define OCSP_R_CERTIFICATE_VERIFY_ERROR 101
  507. #define OCSP_R_DIGEST_ERR 102
  508. #define OCSP_R_ERROR_IN_NEXTUPDATE_FIELD 122
  509. #define OCSP_R_ERROR_IN_THISUPDATE_FIELD 123
  510. #define OCSP_R_ERROR_PARSING_URL 121
  511. #define OCSP_R_MISSING_OCSPSIGNING_USAGE 103
  512. #define OCSP_R_NEXTUPDATE_BEFORE_THISUPDATE 124
  513. #define OCSP_R_NOT_BASIC_RESPONSE 104
  514. #define OCSP_R_NO_CERTIFICATES_IN_CHAIN 105
  515. #define OCSP_R_NO_CONTENT 106
  516. #define OCSP_R_NO_PUBLIC_KEY 107
  517. #define OCSP_R_NO_RESPONSE_DATA 108
  518. #define OCSP_R_NO_REVOKED_TIME 109
  519. #define OCSP_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 110
  520. #define OCSP_R_REQUEST_NOT_SIGNED 128
  521. #define OCSP_R_RESPONSE_CONTAINS_NO_REVOCATION_DATA 111
  522. #define OCSP_R_ROOT_CA_NOT_TRUSTED 112
  523. #define OCSP_R_SERVER_READ_ERROR 113
  524. #define OCSP_R_SERVER_RESPONSE_ERROR 114
  525. #define OCSP_R_SERVER_RESPONSE_PARSE_ERROR 115
  526. #define OCSP_R_SERVER_WRITE_ERROR 116
  527. #define OCSP_R_SIGNATURE_FAILURE 117
  528. #define OCSP_R_SIGNER_CERTIFICATE_NOT_FOUND 118
  529. #define OCSP_R_STATUS_EXPIRED 125
  530. #define OCSP_R_STATUS_NOT_YET_VALID 126
  531. #define OCSP_R_STATUS_TOO_OLD 127
  532. #define OCSP_R_UNKNOWN_MESSAGE_DIGEST 119
  533. #define OCSP_R_UNKNOWN_NID 120
  534. #define OCSP_R_UNSUPPORTED_REQUESTORNAME_TYPE 129
  535. #ifdef __cplusplus
  536. }
  537. #endif
  538. #endif