ocsp_lcl.h 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. /*
  2. * Written by Tom Titchener <Tom_Titchener@groove.net> for the OpenSSL
  3. * project.
  4. */
  5. /*
  6. * History: This file was transfered to Richard Levitte from CertCo by Kathy
  7. * Weinhold in mid-spring 2000 to be included in OpenSSL or released as a
  8. * 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. /*- CertID ::= SEQUENCE {
  64. * hashAlgorithm AlgorithmIdentifier,
  65. * issuerNameHash OCTET STRING, -- Hash of Issuer's DN
  66. * issuerKeyHash OCTET STRING, -- Hash of Issuers public key (excluding the tag & length fields)
  67. * serialNumber CertificateSerialNumber }
  68. */
  69. struct ocsp_cert_id_st {
  70. X509_ALGOR hashAlgorithm;
  71. ASN1_OCTET_STRING issuerNameHash;
  72. ASN1_OCTET_STRING issuerKeyHash;
  73. ASN1_INTEGER serialNumber;
  74. };
  75. /*- Request ::= SEQUENCE {
  76. * reqCert CertID,
  77. * singleRequestExtensions [0] EXPLICIT Extensions OPTIONAL }
  78. */
  79. struct ocsp_one_request_st {
  80. OCSP_CERTID *reqCert;
  81. STACK_OF(X509_EXTENSION) *singleRequestExtensions;
  82. };
  83. /*- TBSRequest ::= SEQUENCE {
  84. * version [0] EXPLICIT Version DEFAULT v1,
  85. * requestorName [1] EXPLICIT GeneralName OPTIONAL,
  86. * requestList SEQUENCE OF Request,
  87. * requestExtensions [2] EXPLICIT Extensions OPTIONAL }
  88. */
  89. struct ocsp_req_info_st {
  90. ASN1_INTEGER *version;
  91. GENERAL_NAME *requestorName;
  92. STACK_OF(OCSP_ONEREQ) *requestList;
  93. STACK_OF(X509_EXTENSION) *requestExtensions;
  94. };
  95. /*- Signature ::= SEQUENCE {
  96. * signatureAlgorithm AlgorithmIdentifier,
  97. * signature BIT STRING,
  98. * certs [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }
  99. */
  100. struct ocsp_signature_st {
  101. X509_ALGOR signatureAlgorithm;
  102. ASN1_BIT_STRING *signature;
  103. STACK_OF(X509) *certs;
  104. };
  105. /*- OCSPRequest ::= SEQUENCE {
  106. * tbsRequest TBSRequest,
  107. * optionalSignature [0] EXPLICIT Signature OPTIONAL }
  108. */
  109. struct ocsp_request_st {
  110. OCSP_REQINFO tbsRequest;
  111. OCSP_SIGNATURE *optionalSignature; /* OPTIONAL */
  112. };
  113. /*- OCSPResponseStatus ::= ENUMERATED {
  114. * successful (0), --Response has valid confirmations
  115. * malformedRequest (1), --Illegal confirmation request
  116. * internalError (2), --Internal error in issuer
  117. * tryLater (3), --Try again later
  118. * --(4) is not used
  119. * sigRequired (5), --Must sign the request
  120. * unauthorized (6) --Request unauthorized
  121. * }
  122. */
  123. /*- ResponseBytes ::= SEQUENCE {
  124. * responseType OBJECT IDENTIFIER,
  125. * response OCTET STRING }
  126. */
  127. struct ocsp_resp_bytes_st {
  128. ASN1_OBJECT *responseType;
  129. ASN1_OCTET_STRING *response;
  130. };
  131. /*- OCSPResponse ::= SEQUENCE {
  132. * responseStatus OCSPResponseStatus,
  133. * responseBytes [0] EXPLICIT ResponseBytes OPTIONAL }
  134. */
  135. struct ocsp_response_st {
  136. ASN1_ENUMERATED *responseStatus;
  137. OCSP_RESPBYTES *responseBytes;
  138. };
  139. /*- ResponderID ::= CHOICE {
  140. * byName [1] Name,
  141. * byKey [2] KeyHash }
  142. */
  143. struct ocsp_responder_id_st {
  144. int type;
  145. union {
  146. X509_NAME *byName;
  147. ASN1_OCTET_STRING *byKey;
  148. } value;
  149. };
  150. /*- KeyHash ::= OCTET STRING --SHA-1 hash of responder's public key
  151. * --(excluding the tag and length fields)
  152. */
  153. /*- RevokedInfo ::= SEQUENCE {
  154. * revocationTime GeneralizedTime,
  155. * revocationReason [0] EXPLICIT CRLReason OPTIONAL }
  156. */
  157. struct ocsp_revoked_info_st {
  158. ASN1_GENERALIZEDTIME *revocationTime;
  159. ASN1_ENUMERATED *revocationReason;
  160. };
  161. /*- CertStatus ::= CHOICE {
  162. * good [0] IMPLICIT NULL,
  163. * revoked [1] IMPLICIT RevokedInfo,
  164. * unknown [2] IMPLICIT UnknownInfo }
  165. */
  166. struct ocsp_cert_status_st {
  167. int type;
  168. union {
  169. ASN1_NULL *good;
  170. OCSP_REVOKEDINFO *revoked;
  171. ASN1_NULL *unknown;
  172. } value;
  173. };
  174. /*- SingleResponse ::= SEQUENCE {
  175. * certID CertID,
  176. * certStatus CertStatus,
  177. * thisUpdate GeneralizedTime,
  178. * nextUpdate [0] EXPLICIT GeneralizedTime OPTIONAL,
  179. * singleExtensions [1] EXPLICIT Extensions OPTIONAL }
  180. */
  181. struct ocsp_single_response_st {
  182. OCSP_CERTID *certId;
  183. OCSP_CERTSTATUS *certStatus;
  184. ASN1_GENERALIZEDTIME *thisUpdate;
  185. ASN1_GENERALIZEDTIME *nextUpdate;
  186. STACK_OF(X509_EXTENSION) *singleExtensions;
  187. };
  188. /*- ResponseData ::= SEQUENCE {
  189. * version [0] EXPLICIT Version DEFAULT v1,
  190. * responderID ResponderID,
  191. * producedAt GeneralizedTime,
  192. * responses SEQUENCE OF SingleResponse,
  193. * responseExtensions [1] EXPLICIT Extensions OPTIONAL }
  194. */
  195. struct ocsp_response_data_st {
  196. ASN1_INTEGER *version;
  197. OCSP_RESPID responderId;
  198. ASN1_GENERALIZEDTIME *producedAt;
  199. STACK_OF(OCSP_SINGLERESP) *responses;
  200. STACK_OF(X509_EXTENSION) *responseExtensions;
  201. };
  202. /*- BasicOCSPResponse ::= SEQUENCE {
  203. * tbsResponseData ResponseData,
  204. * signatureAlgorithm AlgorithmIdentifier,
  205. * signature BIT STRING,
  206. * certs [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }
  207. */
  208. /*
  209. * Note 1: The value for "signature" is specified in the OCSP rfc2560 as
  210. * follows: "The value for the signature SHALL be computed on the hash of
  211. * the DER encoding ResponseData." This means that you must hash the
  212. * DER-encoded tbsResponseData, and then run it through a crypto-signing
  213. * function, which will (at least w/RSA) do a hash-'n'-private-encrypt
  214. * operation. This seems a bit odd, but that's the spec. Also note that
  215. * the data structures do not leave anywhere to independently specify the
  216. * algorithm used for the initial hash. So, we look at the
  217. * signature-specification algorithm, and try to do something intelligent.
  218. * -- Kathy Weinhold, CertCo
  219. */
  220. /*
  221. * Note 2: It seems that the mentioned passage from RFC 2560 (section
  222. * 4.2.1) is open for interpretation. I've done tests against another
  223. * responder, and found that it doesn't do the double hashing that the RFC
  224. * seems to say one should. Therefore, all relevant functions take a flag
  225. * saying which variant should be used. -- Richard Levitte, OpenSSL team
  226. * and CeloCom
  227. */
  228. struct ocsp_basic_response_st {
  229. OCSP_RESPDATA tbsResponseData;
  230. X509_ALGOR signatureAlgorithm;
  231. ASN1_BIT_STRING *signature;
  232. STACK_OF(X509) *certs;
  233. };
  234. /*-
  235. * CrlID ::= SEQUENCE {
  236. * crlUrl [0] EXPLICIT IA5String OPTIONAL,
  237. * crlNum [1] EXPLICIT INTEGER OPTIONAL,
  238. * crlTime [2] EXPLICIT GeneralizedTime OPTIONAL }
  239. */
  240. struct ocsp_crl_id_st {
  241. ASN1_IA5STRING *crlUrl;
  242. ASN1_INTEGER *crlNum;
  243. ASN1_GENERALIZEDTIME *crlTime;
  244. };
  245. /*-
  246. * ServiceLocator ::= SEQUENCE {
  247. * issuer Name,
  248. * locator AuthorityInfoAccessSyntax OPTIONAL }
  249. */
  250. struct ocsp_service_locator_st {
  251. X509_NAME *issuer;
  252. STACK_OF(ACCESS_DESCRIPTION) *locator;
  253. };