ocsp_lcl.h 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. /* ocsp_lcl.h */
  2. /*
  3. * Written by Tom Titchener <Tom_Titchener@groove.net> for the OpenSSL
  4. * project.
  5. */
  6. /*
  7. * History: This file was transfered to Richard Levitte from CertCo by Kathy
  8. * Weinhold in mid-spring 2000 to be included in OpenSSL or released as a
  9. * patch kit.
  10. */
  11. /* ====================================================================
  12. * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved.
  13. *
  14. * Redistribution and use in source and binary forms, with or without
  15. * modification, are permitted provided that the following conditions
  16. * are met:
  17. *
  18. * 1. Redistributions of source code must retain the above copyright
  19. * notice, this list of conditions and the following disclaimer.
  20. *
  21. * 2. Redistributions in binary form must reproduce the above copyright
  22. * notice, this list of conditions and the following disclaimer in
  23. * the documentation and/or other materials provided with the
  24. * distribution.
  25. *
  26. * 3. All advertising materials mentioning features or use of this
  27. * software must display the following acknowledgment:
  28. * "This product includes software developed by the OpenSSL Project
  29. * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
  30. *
  31. * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
  32. * endorse or promote products derived from this software without
  33. * prior written permission. For written permission, please contact
  34. * openssl-core@openssl.org.
  35. *
  36. * 5. Products derived from this software may not be called "OpenSSL"
  37. * nor may "OpenSSL" appear in their names without prior written
  38. * permission of the OpenSSL Project.
  39. *
  40. * 6. Redistributions of any form whatsoever must retain the following
  41. * acknowledgment:
  42. * "This product includes software developed by the OpenSSL Project
  43. * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
  44. *
  45. * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
  46. * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  47. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  48. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
  49. * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  50. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  51. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  52. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  53. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  54. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  55. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  56. * OF THE POSSIBILITY OF SUCH DAMAGE.
  57. * ====================================================================
  58. *
  59. * This product includes cryptographic software written by Eric Young
  60. * (eay@cryptsoft.com). This product includes software written by Tim
  61. * Hudson (tjh@cryptsoft.com).
  62. *
  63. */
  64. /*- CertID ::= SEQUENCE {
  65. * hashAlgorithm AlgorithmIdentifier,
  66. * issuerNameHash OCTET STRING, -- Hash of Issuer's DN
  67. * issuerKeyHash OCTET STRING, -- Hash of Issuers public key (excluding the tag & length fields)
  68. * serialNumber CertificateSerialNumber }
  69. */
  70. struct ocsp_cert_id_st {
  71. X509_ALGOR hashAlgorithm;
  72. ASN1_OCTET_STRING issuerNameHash;
  73. ASN1_OCTET_STRING issuerKeyHash;
  74. ASN1_INTEGER serialNumber;
  75. };
  76. /*- Request ::= SEQUENCE {
  77. * reqCert CertID,
  78. * singleRequestExtensions [0] EXPLICIT Extensions OPTIONAL }
  79. */
  80. struct ocsp_one_request_st {
  81. OCSP_CERTID *reqCert;
  82. STACK_OF(X509_EXTENSION) *singleRequestExtensions;
  83. };
  84. /*- TBSRequest ::= SEQUENCE {
  85. * version [0] EXPLICIT Version DEFAULT v1,
  86. * requestorName [1] EXPLICIT GeneralName OPTIONAL,
  87. * requestList SEQUENCE OF Request,
  88. * requestExtensions [2] EXPLICIT Extensions OPTIONAL }
  89. */
  90. struct ocsp_req_info_st {
  91. ASN1_INTEGER *version;
  92. GENERAL_NAME *requestorName;
  93. STACK_OF(OCSP_ONEREQ) *requestList;
  94. STACK_OF(X509_EXTENSION) *requestExtensions;
  95. };
  96. /*- Signature ::= SEQUENCE {
  97. * signatureAlgorithm AlgorithmIdentifier,
  98. * signature BIT STRING,
  99. * certs [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }
  100. */
  101. struct ocsp_signature_st {
  102. X509_ALGOR signatureAlgorithm;
  103. ASN1_BIT_STRING *signature;
  104. STACK_OF(X509) *certs;
  105. };
  106. /*- OCSPRequest ::= SEQUENCE {
  107. * tbsRequest TBSRequest,
  108. * optionalSignature [0] EXPLICIT Signature OPTIONAL }
  109. */
  110. struct ocsp_request_st {
  111. OCSP_REQINFO tbsRequest;
  112. OCSP_SIGNATURE *optionalSignature; /* OPTIONAL */
  113. };
  114. /*- OCSPResponseStatus ::= ENUMERATED {
  115. * successful (0), --Response has valid confirmations
  116. * malformedRequest (1), --Illegal confirmation request
  117. * internalError (2), --Internal error in issuer
  118. * tryLater (3), --Try again later
  119. * --(4) is not used
  120. * sigRequired (5), --Must sign the request
  121. * unauthorized (6) --Request unauthorized
  122. * }
  123. */
  124. /*- ResponseBytes ::= SEQUENCE {
  125. * responseType OBJECT IDENTIFIER,
  126. * response OCTET STRING }
  127. */
  128. struct ocsp_resp_bytes_st {
  129. ASN1_OBJECT *responseType;
  130. ASN1_OCTET_STRING *response;
  131. };
  132. /*- OCSPResponse ::= SEQUENCE {
  133. * responseStatus OCSPResponseStatus,
  134. * responseBytes [0] EXPLICIT ResponseBytes OPTIONAL }
  135. */
  136. struct ocsp_response_st {
  137. ASN1_ENUMERATED *responseStatus;
  138. OCSP_RESPBYTES *responseBytes;
  139. };
  140. /*- ResponderID ::= CHOICE {
  141. * byName [1] Name,
  142. * byKey [2] KeyHash }
  143. */
  144. struct ocsp_responder_id_st {
  145. int type;
  146. union {
  147. X509_NAME *byName;
  148. ASN1_OCTET_STRING *byKey;
  149. } value;
  150. };
  151. /*- KeyHash ::= OCTET STRING --SHA-1 hash of responder's public key
  152. * --(excluding the tag and length fields)
  153. */
  154. /*- RevokedInfo ::= SEQUENCE {
  155. * revocationTime GeneralizedTime,
  156. * revocationReason [0] EXPLICIT CRLReason OPTIONAL }
  157. */
  158. struct ocsp_revoked_info_st {
  159. ASN1_GENERALIZEDTIME *revocationTime;
  160. ASN1_ENUMERATED *revocationReason;
  161. };
  162. /*- CertStatus ::= CHOICE {
  163. * good [0] IMPLICIT NULL,
  164. * revoked [1] IMPLICIT RevokedInfo,
  165. * unknown [2] IMPLICIT UnknownInfo }
  166. */
  167. struct ocsp_cert_status_st {
  168. int type;
  169. union {
  170. ASN1_NULL *good;
  171. OCSP_REVOKEDINFO *revoked;
  172. ASN1_NULL *unknown;
  173. } value;
  174. };
  175. /*- SingleResponse ::= SEQUENCE {
  176. * certID CertID,
  177. * certStatus CertStatus,
  178. * thisUpdate GeneralizedTime,
  179. * nextUpdate [0] EXPLICIT GeneralizedTime OPTIONAL,
  180. * singleExtensions [1] EXPLICIT Extensions OPTIONAL }
  181. */
  182. struct ocsp_single_response_st {
  183. OCSP_CERTID *certId;
  184. OCSP_CERTSTATUS *certStatus;
  185. ASN1_GENERALIZEDTIME *thisUpdate;
  186. ASN1_GENERALIZEDTIME *nextUpdate;
  187. STACK_OF(X509_EXTENSION) *singleExtensions;
  188. };
  189. /*- ResponseData ::= SEQUENCE {
  190. * version [0] EXPLICIT Version DEFAULT v1,
  191. * responderID ResponderID,
  192. * producedAt GeneralizedTime,
  193. * responses SEQUENCE OF SingleResponse,
  194. * responseExtensions [1] EXPLICIT Extensions OPTIONAL }
  195. */
  196. struct ocsp_response_data_st {
  197. ASN1_INTEGER *version;
  198. OCSP_RESPID responderId;
  199. ASN1_GENERALIZEDTIME *producedAt;
  200. STACK_OF(OCSP_SINGLERESP) *responses;
  201. STACK_OF(X509_EXTENSION) *responseExtensions;
  202. };
  203. /*- BasicOCSPResponse ::= SEQUENCE {
  204. * tbsResponseData ResponseData,
  205. * signatureAlgorithm AlgorithmIdentifier,
  206. * signature BIT STRING,
  207. * certs [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }
  208. */
  209. /*
  210. * Note 1: The value for "signature" is specified in the OCSP rfc2560 as
  211. * follows: "The value for the signature SHALL be computed on the hash of
  212. * the DER encoding ResponseData." This means that you must hash the
  213. * DER-encoded tbsResponseData, and then run it through a crypto-signing
  214. * function, which will (at least w/RSA) do a hash-'n'-private-encrypt
  215. * operation. This seems a bit odd, but that's the spec. Also note that
  216. * the data structures do not leave anywhere to independently specify the
  217. * algorithm used for the initial hash. So, we look at the
  218. * signature-specification algorithm, and try to do something intelligent.
  219. * -- Kathy Weinhold, CertCo
  220. */
  221. /*
  222. * Note 2: It seems that the mentioned passage from RFC 2560 (section
  223. * 4.2.1) is open for interpretation. I've done tests against another
  224. * responder, and found that it doesn't do the double hashing that the RFC
  225. * seems to say one should. Therefore, all relevant functions take a flag
  226. * saying which variant should be used. -- Richard Levitte, OpenSSL team
  227. * and CeloCom
  228. */
  229. struct ocsp_basic_response_st {
  230. OCSP_RESPDATA tbsResponseData;
  231. X509_ALGOR signatureAlgorithm;
  232. ASN1_BIT_STRING *signature;
  233. STACK_OF(X509) *certs;
  234. };
  235. /*-
  236. * CrlID ::= SEQUENCE {
  237. * crlUrl [0] EXPLICIT IA5String OPTIONAL,
  238. * crlNum [1] EXPLICIT INTEGER OPTIONAL,
  239. * crlTime [2] EXPLICIT GeneralizedTime OPTIONAL }
  240. */
  241. struct ocsp_crl_id_st {
  242. ASN1_IA5STRING *crlUrl;
  243. ASN1_INTEGER *crlNum;
  244. ASN1_GENERALIZEDTIME *crlTime;
  245. };
  246. /*-
  247. * ServiceLocator ::= SEQUENCE {
  248. * issuer Name,
  249. * locator AuthorityInfoAccessSyntax OPTIONAL }
  250. */
  251. struct ocsp_service_locator_st {
  252. X509_NAME *issuer;
  253. STACK_OF(ACCESS_DESCRIPTION) *locator;
  254. };