1 /* ====================================================================
2 * Copyright (c) 2015 The OpenSSL Project. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
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
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/)"
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.
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.
30 * 6. Redistributions of any form whatsoever must retain the following
32 * "This product includes software developed by the OpenSSL Project
33 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
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 * ====================================================================
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).
57 * MessageImprint ::= SEQUENCE {
58 * hashAlgorithm AlgorithmIdentifier,
59 * hashedMessage OCTET STRING }
61 struct TS_msg_imprint_st {
62 X509_ALGOR *hash_algo;
63 ASN1_OCTET_STRING *hashed_msg;
67 * TimeStampResp ::= SEQUENCE {
68 * status PKIStatusInfo,
69 * timeStampToken TimeStampToken OPTIONAL }
72 TS_STATUS_INFO *status_info;
74 TS_TST_INFO *tst_info;
78 * TimeStampReq ::= SEQUENCE {
79 * version INTEGER { v1(1) },
80 * messageImprint MessageImprint,
81 * --a hash algorithm OID and the hash value of the data to be
83 * reqPolicy TSAPolicyId OPTIONAL,
84 * nonce INTEGER OPTIONAL,
85 * certReq BOOLEAN DEFAULT FALSE,
86 * extensions [0] IMPLICIT Extensions OPTIONAL }
89 ASN1_INTEGER *version;
90 TS_MSG_IMPRINT *msg_imprint;
91 ASN1_OBJECT *policy_id;
93 ASN1_BOOLEAN cert_req;
94 STACK_OF(X509_EXTENSION) *extensions;
98 * Accuracy ::= SEQUENCE {
99 * seconds INTEGER OPTIONAL,
100 * millis [0] INTEGER (1..999) OPTIONAL,
101 * micros [1] INTEGER (1..999) OPTIONAL }
103 struct TS_accuracy_st {
104 ASN1_INTEGER *seconds;
105 ASN1_INTEGER *millis;
106 ASN1_INTEGER *micros;
110 * TSTInfo ::= SEQUENCE {
111 * version INTEGER { v1(1) },
112 * policy TSAPolicyId,
113 * messageImprint MessageImprint,
114 * -- MUST have the same value as the similar field in
116 * serialNumber INTEGER,
117 * -- Time-Stamping users MUST be ready to accommodate integers
119 * genTime GeneralizedTime,
120 * accuracy Accuracy OPTIONAL,
121 * ordering BOOLEAN DEFAULT FALSE,
122 * nonce INTEGER OPTIONAL,
123 * -- MUST be present if the similar field was present
124 * -- in TimeStampReq. In that case it MUST have the same value.
125 * tsa [0] GeneralName OPTIONAL,
126 * extensions [1] IMPLICIT Extensions OPTIONAL }
128 struct TS_tst_info_st {
129 ASN1_INTEGER *version;
130 ASN1_OBJECT *policy_id;
131 TS_MSG_IMPRINT *msg_imprint;
132 ASN1_INTEGER *serial;
133 ASN1_GENERALIZEDTIME *time;
134 TS_ACCURACY *accuracy;
135 ASN1_BOOLEAN ordering;
138 STACK_OF(X509_EXTENSION) *extensions;
141 struct TS_status_info_st {
142 ASN1_INTEGER *status;
143 STACK_OF(ASN1_UTF8STRING) *text;
144 ASN1_BIT_STRING *failure_info;
147 DEFINE_STACK_OF(ASN1_UTF8STRING)
150 * IssuerSerial ::= SEQUENCE {
151 * issuer GeneralNames,
152 * serialNumber CertificateSerialNumber
155 struct ESS_issuer_serial {
156 STACK_OF(GENERAL_NAME) *issuer;
157 ASN1_INTEGER *serial;
161 * ESSCertID ::= SEQUENCE {
163 * issuerSerial IssuerSerial OPTIONAL
167 ASN1_OCTET_STRING *hash; /* Always SHA-1 digest. */
168 ESS_ISSUER_SERIAL *issuer_serial;
172 * SigningCertificate ::= SEQUENCE {
173 * certs SEQUENCE OF ESSCertID,
174 * policies SEQUENCE OF PolicyInformation OPTIONAL
177 struct ESS_signing_cert {
178 STACK_OF(ESS_CERT_ID) *cert_ids;
179 STACK_OF(POLICYINFO) *policy_info;
185 EVP_PKEY *signer_key;
186 const EVP_MD *signer_md;
187 STACK_OF(X509) *certs; /* Certs to include in signed data. */
188 STACK_OF(ASN1_OBJECT) *policies; /* Acceptable policies. */
189 ASN1_OBJECT *default_policy; /* It may appear in policies, too. */
190 STACK_OF(EVP_MD) *mds; /* Acceptable message digests. */
191 ASN1_INTEGER *seconds; /* accuracy, 0 means not specified. */
192 ASN1_INTEGER *millis; /* accuracy, 0 means not specified. */
193 ASN1_INTEGER *micros; /* accuracy, 0 means not specified. */
194 unsigned clock_precision_digits; /* fraction of seconds in time stamp
196 unsigned flags; /* Optional info, see values above. */
197 /* Callback functions. */
198 TS_serial_cb serial_cb;
199 void *serial_cb_data; /* User data for serial_cb. */
201 void *time_cb_data; /* User data for time_cb. */
202 TS_extension_cb extension_cb;
203 void *extension_cb_data; /* User data for extension_cb. */
204 /* These members are used only while creating the response. */
207 TS_TST_INFO *tst_info;
210 struct TS_verify_ctx {
211 /* Set this to the union of TS_VFY_... flags you want to carry out. */
213 /* Must be set only with TS_VFY_SIGNATURE. certs is optional. */
215 STACK_OF(X509) *certs;
216 /* Must be set only with TS_VFY_POLICY. */
219 * Must be set only with TS_VFY_IMPRINT. If md_alg is NULL, the
220 * algorithm from the response is used.
223 unsigned char *imprint;
224 unsigned imprint_len;
225 /* Must be set only with TS_VFY_DATA. */
227 /* Must be set only with TS_VFY_TSA_NAME. */
229 /* Must be set only with TS_VFY_TSA_NAME. */
230 GENERAL_NAME *tsa_name;