ts_lcl.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. /* ====================================================================
  2. * Copyright (c) 2015 The OpenSSL Project. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. *
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. *
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in
  13. * the documentation and/or other materials provided with the
  14. * distribution.
  15. *
  16. * 3. All advertising materials mentioning features or use of this
  17. * software must display the following acknowledgment:
  18. * "This product includes software developed by the OpenSSL Project
  19. * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
  20. *
  21. * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
  22. * endorse or promote products derived from this software without
  23. * prior written permission. For written permission, please contact
  24. * licensing@OpenSSL.org.
  25. *
  26. * 5. Products derived from this software may not be called "OpenSSL"
  27. * nor may "OpenSSL" appear in their names without prior written
  28. * permission of the OpenSSL Project.
  29. *
  30. * 6. Redistributions of any form whatsoever must retain the following
  31. * acknowledgment:
  32. * "This product includes software developed by the OpenSSL Project
  33. * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
  34. *
  35. * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
  36. * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  37. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  38. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
  39. * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  40. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  41. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  42. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  43. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  44. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  45. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  46. * OF THE POSSIBILITY OF SUCH DAMAGE.
  47. * ====================================================================
  48. *
  49. * This product includes cryptographic software written by Eric Young
  50. * (eay@cryptsoft.com). This product includes software written by Tim
  51. * Hudson (tjh@cryptsoft.com).
  52. *
  53. */
  54. /*-
  55. * MessageImprint ::= SEQUENCE {
  56. * hashAlgorithm AlgorithmIdentifier,
  57. * hashedMessage OCTET STRING }
  58. */
  59. struct TS_msg_imprint_st {
  60. X509_ALGOR *hash_algo;
  61. ASN1_OCTET_STRING *hashed_msg;
  62. };
  63. /*-
  64. * TimeStampResp ::= SEQUENCE {
  65. * status PKIStatusInfo,
  66. * timeStampToken TimeStampToken OPTIONAL }
  67. */
  68. struct TS_resp_st {
  69. TS_STATUS_INFO *status_info;
  70. PKCS7 *token;
  71. TS_TST_INFO *tst_info;
  72. };
  73. /*-
  74. * TimeStampReq ::= SEQUENCE {
  75. * version INTEGER { v1(1) },
  76. * messageImprint MessageImprint,
  77. * --a hash algorithm OID and the hash value of the data to be
  78. * --time-stamped
  79. * reqPolicy TSAPolicyId OPTIONAL,
  80. * nonce INTEGER OPTIONAL,
  81. * certReq BOOLEAN DEFAULT FALSE,
  82. * extensions [0] IMPLICIT Extensions OPTIONAL }
  83. */
  84. struct TS_req_st {
  85. ASN1_INTEGER *version;
  86. TS_MSG_IMPRINT *msg_imprint;
  87. ASN1_OBJECT *policy_id;
  88. ASN1_INTEGER *nonce;
  89. ASN1_BOOLEAN cert_req;
  90. STACK_OF(X509_EXTENSION) *extensions;
  91. };
  92. /*-
  93. * Accuracy ::= SEQUENCE {
  94. * seconds INTEGER OPTIONAL,
  95. * millis [0] INTEGER (1..999) OPTIONAL,
  96. * micros [1] INTEGER (1..999) OPTIONAL }
  97. */
  98. struct TS_accuracy_st {
  99. ASN1_INTEGER *seconds;
  100. ASN1_INTEGER *millis;
  101. ASN1_INTEGER *micros;
  102. };
  103. /*-
  104. * TSTInfo ::= SEQUENCE {
  105. * version INTEGER { v1(1) },
  106. * policy TSAPolicyId,
  107. * messageImprint MessageImprint,
  108. * -- MUST have the same value as the similar field in
  109. * -- TimeStampReq
  110. * serialNumber INTEGER,
  111. * -- Time-Stamping users MUST be ready to accommodate integers
  112. * -- up to 160 bits.
  113. * genTime GeneralizedTime,
  114. * accuracy Accuracy OPTIONAL,
  115. * ordering BOOLEAN DEFAULT FALSE,
  116. * nonce INTEGER OPTIONAL,
  117. * -- MUST be present if the similar field was present
  118. * -- in TimeStampReq. In that case it MUST have the same value.
  119. * tsa [0] GeneralName OPTIONAL,
  120. * extensions [1] IMPLICIT Extensions OPTIONAL }
  121. */
  122. struct TS_tst_info_st {
  123. ASN1_INTEGER *version;
  124. ASN1_OBJECT *policy_id;
  125. TS_MSG_IMPRINT *msg_imprint;
  126. ASN1_INTEGER *serial;
  127. ASN1_GENERALIZEDTIME *time;
  128. TS_ACCURACY *accuracy;
  129. ASN1_BOOLEAN ordering;
  130. ASN1_INTEGER *nonce;
  131. GENERAL_NAME *tsa;
  132. STACK_OF(X509_EXTENSION) *extensions;
  133. };
  134. struct TS_status_info_st {
  135. ASN1_INTEGER *status;
  136. STACK_OF(ASN1_UTF8STRING) *text;
  137. ASN1_BIT_STRING *failure_info;
  138. };
  139. DEFINE_STACK_OF(ASN1_UTF8STRING)
  140. /*-
  141. * IssuerSerial ::= SEQUENCE {
  142. * issuer GeneralNames,
  143. * serialNumber CertificateSerialNumber
  144. * }
  145. */
  146. struct ESS_issuer_serial {
  147. STACK_OF(GENERAL_NAME) *issuer;
  148. ASN1_INTEGER *serial;
  149. };
  150. /*-
  151. * ESSCertID ::= SEQUENCE {
  152. * certHash Hash,
  153. * issuerSerial IssuerSerial OPTIONAL
  154. * }
  155. */
  156. struct ESS_cert_id {
  157. ASN1_OCTET_STRING *hash; /* Always SHA-1 digest. */
  158. ESS_ISSUER_SERIAL *issuer_serial;
  159. };
  160. /*-
  161. * SigningCertificate ::= SEQUENCE {
  162. * certs SEQUENCE OF ESSCertID,
  163. * policies SEQUENCE OF PolicyInformation OPTIONAL
  164. * }
  165. */
  166. struct ESS_signing_cert {
  167. STACK_OF(ESS_CERT_ID) *cert_ids;
  168. STACK_OF(POLICYINFO) *policy_info;
  169. };
  170. struct TS_resp_ctx {
  171. X509 *signer_cert;
  172. EVP_PKEY *signer_key;
  173. const EVP_MD *signer_md;
  174. STACK_OF(X509) *certs; /* Certs to include in signed data. */
  175. STACK_OF(ASN1_OBJECT) *policies; /* Acceptable policies. */
  176. ASN1_OBJECT *default_policy; /* It may appear in policies, too. */
  177. STACK_OF(EVP_MD) *mds; /* Acceptable message digests. */
  178. ASN1_INTEGER *seconds; /* accuracy, 0 means not specified. */
  179. ASN1_INTEGER *millis; /* accuracy, 0 means not specified. */
  180. ASN1_INTEGER *micros; /* accuracy, 0 means not specified. */
  181. unsigned clock_precision_digits; /* fraction of seconds in time stamp
  182. * token. */
  183. unsigned flags; /* Optional info, see values above. */
  184. /* Callback functions. */
  185. TS_serial_cb serial_cb;
  186. void *serial_cb_data; /* User data for serial_cb. */
  187. TS_time_cb time_cb;
  188. void *time_cb_data; /* User data for time_cb. */
  189. TS_extension_cb extension_cb;
  190. void *extension_cb_data; /* User data for extension_cb. */
  191. /* These members are used only while creating the response. */
  192. TS_REQ *request;
  193. TS_RESP *response;
  194. TS_TST_INFO *tst_info;
  195. };
  196. struct TS_verify_ctx {
  197. /* Set this to the union of TS_VFY_... flags you want to carry out. */
  198. unsigned flags;
  199. /* Must be set only with TS_VFY_SIGNATURE. certs is optional. */
  200. X509_STORE *store;
  201. STACK_OF(X509) *certs;
  202. /* Must be set only with TS_VFY_POLICY. */
  203. ASN1_OBJECT *policy;
  204. /*
  205. * Must be set only with TS_VFY_IMPRINT. If md_alg is NULL, the
  206. * algorithm from the response is used.
  207. */
  208. X509_ALGOR *md_alg;
  209. unsigned char *imprint;
  210. unsigned imprint_len;
  211. /* Must be set only with TS_VFY_DATA. */
  212. BIO *data;
  213. /* Must be set only with TS_VFY_TSA_NAME. */
  214. ASN1_INTEGER *nonce;
  215. /* Must be set only with TS_VFY_TSA_NAME. */
  216. GENERAL_NAME *tsa_name;
  217. };