1 |
|
|
/* $OpenBSD: ts_asn1.c,v 1.11 2017/01/29 17:49:23 beck Exp $ */ |
2 |
|
|
/* Written by Nils Larsch for the OpenSSL project 2004. |
3 |
|
|
*/ |
4 |
|
|
/* ==================================================================== |
5 |
|
|
* Copyright (c) 2006 The OpenSSL Project. All rights reserved. |
6 |
|
|
* |
7 |
|
|
* Redistribution and use in source and binary forms, with or without |
8 |
|
|
* modification, are permitted provided that the following conditions |
9 |
|
|
* are met: |
10 |
|
|
* |
11 |
|
|
* 1. Redistributions of source code must retain the above copyright |
12 |
|
|
* notice, this list of conditions and the following disclaimer. |
13 |
|
|
* |
14 |
|
|
* 2. Redistributions in binary form must reproduce the above copyright |
15 |
|
|
* notice, this list of conditions and the following disclaimer in |
16 |
|
|
* the documentation and/or other materials provided with the |
17 |
|
|
* distribution. |
18 |
|
|
* |
19 |
|
|
* 3. All advertising materials mentioning features or use of this |
20 |
|
|
* software must display the following acknowledgment: |
21 |
|
|
* "This product includes software developed by the OpenSSL Project |
22 |
|
|
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" |
23 |
|
|
* |
24 |
|
|
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to |
25 |
|
|
* endorse or promote products derived from this software without |
26 |
|
|
* prior written permission. For written permission, please contact |
27 |
|
|
* licensing@OpenSSL.org. |
28 |
|
|
* |
29 |
|
|
* 5. Products derived from this software may not be called "OpenSSL" |
30 |
|
|
* nor may "OpenSSL" appear in their names without prior written |
31 |
|
|
* permission of the OpenSSL Project. |
32 |
|
|
* |
33 |
|
|
* 6. Redistributions of any form whatsoever must retain the following |
34 |
|
|
* acknowledgment: |
35 |
|
|
* "This product includes software developed by the OpenSSL Project |
36 |
|
|
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" |
37 |
|
|
* |
38 |
|
|
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY |
39 |
|
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
40 |
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
41 |
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR |
42 |
|
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
43 |
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
44 |
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
45 |
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
46 |
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
47 |
|
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
48 |
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
49 |
|
|
* OF THE POSSIBILITY OF SUCH DAMAGE. |
50 |
|
|
* ==================================================================== |
51 |
|
|
* |
52 |
|
|
* This product includes cryptographic software written by Eric Young |
53 |
|
|
* (eay@cryptsoft.com). This product includes software written by Tim |
54 |
|
|
* Hudson (tjh@cryptsoft.com). |
55 |
|
|
* |
56 |
|
|
*/ |
57 |
|
|
|
58 |
|
|
#include <openssl/opensslconf.h> |
59 |
|
|
|
60 |
|
|
#include <openssl/ts.h> |
61 |
|
|
#include <openssl/err.h> |
62 |
|
|
#include <openssl/asn1t.h> |
63 |
|
|
|
64 |
|
|
static const ASN1_TEMPLATE TS_MSG_IMPRINT_seq_tt[] = { |
65 |
|
|
{ |
66 |
|
|
.flags = 0, |
67 |
|
|
.tag = 0, |
68 |
|
|
.offset = offsetof(TS_MSG_IMPRINT, hash_algo), |
69 |
|
|
.field_name = "hash_algo", |
70 |
|
|
.item = &X509_ALGOR_it, |
71 |
|
|
}, |
72 |
|
|
{ |
73 |
|
|
.flags = 0, |
74 |
|
|
.tag = 0, |
75 |
|
|
.offset = offsetof(TS_MSG_IMPRINT, hashed_msg), |
76 |
|
|
.field_name = "hashed_msg", |
77 |
|
|
.item = &ASN1_OCTET_STRING_it, |
78 |
|
|
}, |
79 |
|
|
}; |
80 |
|
|
|
81 |
|
|
const ASN1_ITEM TS_MSG_IMPRINT_it = { |
82 |
|
|
.itype = ASN1_ITYPE_SEQUENCE, |
83 |
|
|
.utype = V_ASN1_SEQUENCE, |
84 |
|
|
.templates = TS_MSG_IMPRINT_seq_tt, |
85 |
|
|
.tcount = sizeof(TS_MSG_IMPRINT_seq_tt) / sizeof(ASN1_TEMPLATE), |
86 |
|
|
.funcs = NULL, |
87 |
|
|
.size = sizeof(TS_MSG_IMPRINT), |
88 |
|
|
.sname = "TS_MSG_IMPRINT", |
89 |
|
|
}; |
90 |
|
|
|
91 |
|
|
|
92 |
|
|
TS_MSG_IMPRINT * |
93 |
|
|
d2i_TS_MSG_IMPRINT(TS_MSG_IMPRINT **a, const unsigned char **in, long len) |
94 |
|
|
{ |
95 |
|
|
return (TS_MSG_IMPRINT *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, |
96 |
|
|
&TS_MSG_IMPRINT_it); |
97 |
|
|
} |
98 |
|
|
|
99 |
|
|
int |
100 |
|
|
i2d_TS_MSG_IMPRINT(const TS_MSG_IMPRINT *a, unsigned char **out) |
101 |
|
|
{ |
102 |
|
|
return ASN1_item_i2d((ASN1_VALUE *)a, out, &TS_MSG_IMPRINT_it); |
103 |
|
|
} |
104 |
|
|
|
105 |
|
|
TS_MSG_IMPRINT * |
106 |
|
|
TS_MSG_IMPRINT_new(void) |
107 |
|
|
{ |
108 |
|
4 |
return (TS_MSG_IMPRINT *)ASN1_item_new(&TS_MSG_IMPRINT_it); |
109 |
|
|
} |
110 |
|
|
|
111 |
|
|
void |
112 |
|
|
TS_MSG_IMPRINT_free(TS_MSG_IMPRINT *a) |
113 |
|
|
{ |
114 |
|
12 |
ASN1_item_free((ASN1_VALUE *)a, &TS_MSG_IMPRINT_it); |
115 |
|
6 |
} |
116 |
|
|
|
117 |
|
|
TS_MSG_IMPRINT * |
118 |
|
|
TS_MSG_IMPRINT_dup(TS_MSG_IMPRINT *x) |
119 |
|
|
{ |
120 |
|
8 |
return ASN1_item_dup(&TS_MSG_IMPRINT_it, x); |
121 |
|
|
} |
122 |
|
|
|
123 |
|
|
#ifndef OPENSSL_NO_BIO |
124 |
|
|
TS_MSG_IMPRINT * |
125 |
|
|
d2i_TS_MSG_IMPRINT_bio(BIO *bp, TS_MSG_IMPRINT **a) |
126 |
|
|
{ |
127 |
|
|
return ASN1_item_d2i_bio(&TS_MSG_IMPRINT_it, bp, a); |
128 |
|
|
} |
129 |
|
|
|
130 |
|
|
int |
131 |
|
|
i2d_TS_MSG_IMPRINT_bio(BIO *bp, TS_MSG_IMPRINT *a) |
132 |
|
|
{ |
133 |
|
|
return ASN1_item_i2d_bio(&TS_MSG_IMPRINT_it, bp, a); |
134 |
|
|
} |
135 |
|
|
#endif |
136 |
|
|
|
137 |
|
|
TS_MSG_IMPRINT * |
138 |
|
|
d2i_TS_MSG_IMPRINT_fp(FILE *fp, TS_MSG_IMPRINT **a) |
139 |
|
|
{ |
140 |
|
|
return ASN1_item_d2i_fp(&TS_MSG_IMPRINT_it, fp, a); |
141 |
|
|
} |
142 |
|
|
|
143 |
|
|
int |
144 |
|
|
i2d_TS_MSG_IMPRINT_fp(FILE *fp, TS_MSG_IMPRINT *a) |
145 |
|
|
{ |
146 |
|
|
return ASN1_item_i2d_fp(&TS_MSG_IMPRINT_it, fp, a); |
147 |
|
|
} |
148 |
|
|
|
149 |
|
|
static const ASN1_TEMPLATE TS_REQ_seq_tt[] = { |
150 |
|
|
{ |
151 |
|
|
.flags = 0, |
152 |
|
|
.tag = 0, |
153 |
|
|
.offset = offsetof(TS_REQ, version), |
154 |
|
|
.field_name = "version", |
155 |
|
|
.item = &ASN1_INTEGER_it, |
156 |
|
|
}, |
157 |
|
|
{ |
158 |
|
|
.flags = 0, |
159 |
|
|
.tag = 0, |
160 |
|
|
.offset = offsetof(TS_REQ, msg_imprint), |
161 |
|
|
.field_name = "msg_imprint", |
162 |
|
|
.item = &TS_MSG_IMPRINT_it, |
163 |
|
|
}, |
164 |
|
|
{ |
165 |
|
|
.flags = ASN1_TFLG_OPTIONAL, |
166 |
|
|
.tag = 0, |
167 |
|
|
.offset = offsetof(TS_REQ, policy_id), |
168 |
|
|
.field_name = "policy_id", |
169 |
|
|
.item = &ASN1_OBJECT_it, |
170 |
|
|
}, |
171 |
|
|
{ |
172 |
|
|
.flags = ASN1_TFLG_OPTIONAL, |
173 |
|
|
.tag = 0, |
174 |
|
|
.offset = offsetof(TS_REQ, nonce), |
175 |
|
|
.field_name = "nonce", |
176 |
|
|
.item = &ASN1_INTEGER_it, |
177 |
|
|
}, |
178 |
|
|
{ |
179 |
|
|
.flags = ASN1_TFLG_OPTIONAL, |
180 |
|
|
.tag = 0, |
181 |
|
|
.offset = offsetof(TS_REQ, cert_req), |
182 |
|
|
.field_name = "cert_req", |
183 |
|
|
.item = &ASN1_FBOOLEAN_it, |
184 |
|
|
}, |
185 |
|
|
{ |
186 |
|
|
.flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SEQUENCE_OF | ASN1_TFLG_OPTIONAL, |
187 |
|
|
.tag = 0, |
188 |
|
|
.offset = offsetof(TS_REQ, extensions), |
189 |
|
|
.field_name = "extensions", |
190 |
|
|
.item = &X509_EXTENSION_it, |
191 |
|
|
}, |
192 |
|
|
}; |
193 |
|
|
|
194 |
|
|
const ASN1_ITEM TS_REQ_it = { |
195 |
|
|
.itype = ASN1_ITYPE_SEQUENCE, |
196 |
|
|
.utype = V_ASN1_SEQUENCE, |
197 |
|
|
.templates = TS_REQ_seq_tt, |
198 |
|
|
.tcount = sizeof(TS_REQ_seq_tt) / sizeof(ASN1_TEMPLATE), |
199 |
|
|
.funcs = NULL, |
200 |
|
|
.size = sizeof(TS_REQ), |
201 |
|
|
.sname = "TS_REQ", |
202 |
|
|
}; |
203 |
|
|
|
204 |
|
|
|
205 |
|
|
TS_REQ * |
206 |
|
|
d2i_TS_REQ(TS_REQ **a, const unsigned char **in, long len) |
207 |
|
|
{ |
208 |
|
|
return (TS_REQ *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, |
209 |
|
|
&TS_REQ_it); |
210 |
|
|
} |
211 |
|
|
|
212 |
|
|
int |
213 |
|
|
i2d_TS_REQ(const TS_REQ *a, unsigned char **out) |
214 |
|
|
{ |
215 |
|
|
return ASN1_item_i2d((ASN1_VALUE *)a, out, &TS_REQ_it); |
216 |
|
|
} |
217 |
|
|
|
218 |
|
|
TS_REQ * |
219 |
|
|
TS_REQ_new(void) |
220 |
|
|
{ |
221 |
|
4 |
return (TS_REQ *)ASN1_item_new(&TS_REQ_it); |
222 |
|
|
} |
223 |
|
|
|
224 |
|
|
void |
225 |
|
|
TS_REQ_free(TS_REQ *a) |
226 |
|
|
{ |
227 |
|
16 |
ASN1_item_free((ASN1_VALUE *)a, &TS_REQ_it); |
228 |
|
8 |
} |
229 |
|
|
|
230 |
|
|
TS_REQ * |
231 |
|
|
TS_REQ_dup(TS_REQ *x) |
232 |
|
|
{ |
233 |
|
|
return ASN1_item_dup(&TS_REQ_it, x); |
234 |
|
|
} |
235 |
|
|
|
236 |
|
|
#ifndef OPENSSL_NO_BIO |
237 |
|
|
TS_REQ * |
238 |
|
|
d2i_TS_REQ_bio(BIO *bp, TS_REQ **a) |
239 |
|
|
{ |
240 |
|
12 |
return ASN1_item_d2i_bio(&TS_REQ_it, bp, a); |
241 |
|
|
} |
242 |
|
|
|
243 |
|
|
int |
244 |
|
|
i2d_TS_REQ_bio(BIO *bp, TS_REQ *a) |
245 |
|
|
{ |
246 |
|
4 |
return ASN1_item_i2d_bio(&TS_REQ_it, bp, a); |
247 |
|
|
} |
248 |
|
|
#endif |
249 |
|
|
|
250 |
|
|
TS_REQ * |
251 |
|
|
d2i_TS_REQ_fp(FILE *fp, TS_REQ **a) |
252 |
|
|
{ |
253 |
|
|
return ASN1_item_d2i_fp(&TS_REQ_it, fp, a); |
254 |
|
|
} |
255 |
|
|
|
256 |
|
|
int |
257 |
|
|
i2d_TS_REQ_fp(FILE *fp, TS_REQ *a) |
258 |
|
|
{ |
259 |
|
|
return ASN1_item_i2d_fp(&TS_REQ_it, fp, a); |
260 |
|
|
} |
261 |
|
|
|
262 |
|
|
static const ASN1_TEMPLATE TS_ACCURACY_seq_tt[] = { |
263 |
|
|
{ |
264 |
|
|
.flags = ASN1_TFLG_OPTIONAL, |
265 |
|
|
.tag = 0, |
266 |
|
|
.offset = offsetof(TS_ACCURACY, seconds), |
267 |
|
|
.field_name = "seconds", |
268 |
|
|
.item = &ASN1_INTEGER_it, |
269 |
|
|
}, |
270 |
|
|
{ |
271 |
|
|
.flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_OPTIONAL, |
272 |
|
|
.tag = 0, |
273 |
|
|
.offset = offsetof(TS_ACCURACY, millis), |
274 |
|
|
.field_name = "millis", |
275 |
|
|
.item = &ASN1_INTEGER_it, |
276 |
|
|
}, |
277 |
|
|
{ |
278 |
|
|
.flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_OPTIONAL, |
279 |
|
|
.tag = 1, |
280 |
|
|
.offset = offsetof(TS_ACCURACY, micros), |
281 |
|
|
.field_name = "micros", |
282 |
|
|
.item = &ASN1_INTEGER_it, |
283 |
|
|
}, |
284 |
|
|
}; |
285 |
|
|
|
286 |
|
|
const ASN1_ITEM TS_ACCURACY_it = { |
287 |
|
|
.itype = ASN1_ITYPE_SEQUENCE, |
288 |
|
|
.utype = V_ASN1_SEQUENCE, |
289 |
|
|
.templates = TS_ACCURACY_seq_tt, |
290 |
|
|
.tcount = sizeof(TS_ACCURACY_seq_tt) / sizeof(ASN1_TEMPLATE), |
291 |
|
|
.funcs = NULL, |
292 |
|
|
.size = sizeof(TS_ACCURACY), |
293 |
|
|
.sname = "TS_ACCURACY", |
294 |
|
|
}; |
295 |
|
|
|
296 |
|
|
|
297 |
|
|
TS_ACCURACY * |
298 |
|
|
d2i_TS_ACCURACY(TS_ACCURACY **a, const unsigned char **in, long len) |
299 |
|
|
{ |
300 |
|
|
return (TS_ACCURACY *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, |
301 |
|
|
&TS_ACCURACY_it); |
302 |
|
|
} |
303 |
|
|
|
304 |
|
|
int |
305 |
|
|
i2d_TS_ACCURACY(const TS_ACCURACY *a, unsigned char **out) |
306 |
|
|
{ |
307 |
|
|
return ASN1_item_i2d((ASN1_VALUE *)a, out, &TS_ACCURACY_it); |
308 |
|
|
} |
309 |
|
|
|
310 |
|
|
TS_ACCURACY * |
311 |
|
|
TS_ACCURACY_new(void) |
312 |
|
|
{ |
313 |
|
|
return (TS_ACCURACY *)ASN1_item_new(&TS_ACCURACY_it); |
314 |
|
|
} |
315 |
|
|
|
316 |
|
|
void |
317 |
|
|
TS_ACCURACY_free(TS_ACCURACY *a) |
318 |
|
|
{ |
319 |
|
4 |
ASN1_item_free((ASN1_VALUE *)a, &TS_ACCURACY_it); |
320 |
|
2 |
} |
321 |
|
|
|
322 |
|
|
TS_ACCURACY * |
323 |
|
|
TS_ACCURACY_dup(TS_ACCURACY *x) |
324 |
|
|
{ |
325 |
|
|
return ASN1_item_dup(&TS_ACCURACY_it, x); |
326 |
|
|
} |
327 |
|
|
|
328 |
|
|
static const ASN1_TEMPLATE TS_TST_INFO_seq_tt[] = { |
329 |
|
|
{ |
330 |
|
|
.flags = 0, |
331 |
|
|
.tag = 0, |
332 |
|
|
.offset = offsetof(TS_TST_INFO, version), |
333 |
|
|
.field_name = "version", |
334 |
|
|
.item = &ASN1_INTEGER_it, |
335 |
|
|
}, |
336 |
|
|
{ |
337 |
|
|
.flags = 0, |
338 |
|
|
.tag = 0, |
339 |
|
|
.offset = offsetof(TS_TST_INFO, policy_id), |
340 |
|
|
.field_name = "policy_id", |
341 |
|
|
.item = &ASN1_OBJECT_it, |
342 |
|
|
}, |
343 |
|
|
{ |
344 |
|
|
.flags = 0, |
345 |
|
|
.tag = 0, |
346 |
|
|
.offset = offsetof(TS_TST_INFO, msg_imprint), |
347 |
|
|
.field_name = "msg_imprint", |
348 |
|
|
.item = &TS_MSG_IMPRINT_it, |
349 |
|
|
}, |
350 |
|
|
{ |
351 |
|
|
.flags = 0, |
352 |
|
|
.tag = 0, |
353 |
|
|
.offset = offsetof(TS_TST_INFO, serial), |
354 |
|
|
.field_name = "serial", |
355 |
|
|
.item = &ASN1_INTEGER_it, |
356 |
|
|
}, |
357 |
|
|
{ |
358 |
|
|
.flags = 0, |
359 |
|
|
.tag = 0, |
360 |
|
|
.offset = offsetof(TS_TST_INFO, time), |
361 |
|
|
.field_name = "time", |
362 |
|
|
.item = &ASN1_GENERALIZEDTIME_it, |
363 |
|
|
}, |
364 |
|
|
{ |
365 |
|
|
.flags = ASN1_TFLG_OPTIONAL, |
366 |
|
|
.tag = 0, |
367 |
|
|
.offset = offsetof(TS_TST_INFO, accuracy), |
368 |
|
|
.field_name = "accuracy", |
369 |
|
|
.item = &TS_ACCURACY_it, |
370 |
|
|
}, |
371 |
|
|
{ |
372 |
|
|
.flags = ASN1_TFLG_OPTIONAL, |
373 |
|
|
.tag = 0, |
374 |
|
|
.offset = offsetof(TS_TST_INFO, ordering), |
375 |
|
|
.field_name = "ordering", |
376 |
|
|
.item = &ASN1_FBOOLEAN_it, |
377 |
|
|
}, |
378 |
|
|
{ |
379 |
|
|
.flags = ASN1_TFLG_OPTIONAL, |
380 |
|
|
.tag = 0, |
381 |
|
|
.offset = offsetof(TS_TST_INFO, nonce), |
382 |
|
|
.field_name = "nonce", |
383 |
|
|
.item = &ASN1_INTEGER_it, |
384 |
|
|
}, |
385 |
|
|
{ |
386 |
|
|
.flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_OPTIONAL, |
387 |
|
|
.tag = 0, |
388 |
|
|
.offset = offsetof(TS_TST_INFO, tsa), |
389 |
|
|
.field_name = "tsa", |
390 |
|
|
.item = &GENERAL_NAME_it, |
391 |
|
|
}, |
392 |
|
|
{ |
393 |
|
|
.flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SEQUENCE_OF | ASN1_TFLG_OPTIONAL, |
394 |
|
|
.tag = 1, |
395 |
|
|
.offset = offsetof(TS_TST_INFO, extensions), |
396 |
|
|
.field_name = "extensions", |
397 |
|
|
.item = &X509_EXTENSION_it, |
398 |
|
|
}, |
399 |
|
|
}; |
400 |
|
|
|
401 |
|
|
const ASN1_ITEM TS_TST_INFO_it = { |
402 |
|
|
.itype = ASN1_ITYPE_SEQUENCE, |
403 |
|
|
.utype = V_ASN1_SEQUENCE, |
404 |
|
|
.templates = TS_TST_INFO_seq_tt, |
405 |
|
|
.tcount = sizeof(TS_TST_INFO_seq_tt) / sizeof(ASN1_TEMPLATE), |
406 |
|
|
.funcs = NULL, |
407 |
|
|
.size = sizeof(TS_TST_INFO), |
408 |
|
|
.sname = "TS_TST_INFO", |
409 |
|
|
}; |
410 |
|
|
|
411 |
|
|
|
412 |
|
|
TS_TST_INFO * |
413 |
|
|
d2i_TS_TST_INFO(TS_TST_INFO **a, const unsigned char **in, long len) |
414 |
|
|
{ |
415 |
|
4 |
return (TS_TST_INFO *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, |
416 |
|
|
&TS_TST_INFO_it); |
417 |
|
|
} |
418 |
|
|
|
419 |
|
|
int |
420 |
|
|
i2d_TS_TST_INFO(const TS_TST_INFO *a, unsigned char **out) |
421 |
|
|
{ |
422 |
|
|
return ASN1_item_i2d((ASN1_VALUE *)a, out, &TS_TST_INFO_it); |
423 |
|
|
} |
424 |
|
|
|
425 |
|
|
TS_TST_INFO * |
426 |
|
|
TS_TST_INFO_new(void) |
427 |
|
|
{ |
428 |
|
4 |
return (TS_TST_INFO *)ASN1_item_new(&TS_TST_INFO_it); |
429 |
|
|
} |
430 |
|
|
|
431 |
|
|
void |
432 |
|
|
TS_TST_INFO_free(TS_TST_INFO *a) |
433 |
|
|
{ |
434 |
|
16 |
ASN1_item_free((ASN1_VALUE *)a, &TS_TST_INFO_it); |
435 |
|
8 |
} |
436 |
|
|
|
437 |
|
|
TS_TST_INFO * |
438 |
|
|
TS_TST_INFO_dup(TS_TST_INFO *x) |
439 |
|
|
{ |
440 |
|
|
return ASN1_item_dup(&TS_TST_INFO_it, x); |
441 |
|
|
} |
442 |
|
|
|
443 |
|
|
#ifndef OPENSSL_NO_BIO |
444 |
|
|
TS_TST_INFO * |
445 |
|
|
d2i_TS_TST_INFO_bio(BIO *bp, TS_TST_INFO **a) |
446 |
|
|
{ |
447 |
|
|
return ASN1_item_d2i_bio(&TS_TST_INFO_it, bp, a); |
448 |
|
|
} |
449 |
|
|
|
450 |
|
|
int |
451 |
|
|
i2d_TS_TST_INFO_bio(BIO *bp, TS_TST_INFO *a) |
452 |
|
|
{ |
453 |
|
4 |
return ASN1_item_i2d_bio(&TS_TST_INFO_it, bp, a); |
454 |
|
|
} |
455 |
|
|
#endif |
456 |
|
|
|
457 |
|
|
TS_TST_INFO * |
458 |
|
|
d2i_TS_TST_INFO_fp(FILE *fp, TS_TST_INFO **a) |
459 |
|
|
{ |
460 |
|
|
return ASN1_item_d2i_fp(&TS_TST_INFO_it, fp, a); |
461 |
|
|
} |
462 |
|
|
|
463 |
|
|
int |
464 |
|
|
i2d_TS_TST_INFO_fp(FILE *fp, TS_TST_INFO *a) |
465 |
|
|
{ |
466 |
|
|
return ASN1_item_i2d_fp(&TS_TST_INFO_it, fp, a); |
467 |
|
|
} |
468 |
|
|
|
469 |
|
|
static const ASN1_TEMPLATE TS_STATUS_INFO_seq_tt[] = { |
470 |
|
|
{ |
471 |
|
|
.flags = 0, |
472 |
|
|
.tag = 0, |
473 |
|
|
.offset = offsetof(TS_STATUS_INFO, status), |
474 |
|
|
.field_name = "status", |
475 |
|
|
.item = &ASN1_INTEGER_it, |
476 |
|
|
}, |
477 |
|
|
{ |
478 |
|
|
.flags = ASN1_TFLG_SEQUENCE_OF | ASN1_TFLG_OPTIONAL, |
479 |
|
|
.tag = 0, |
480 |
|
|
.offset = offsetof(TS_STATUS_INFO, text), |
481 |
|
|
.field_name = "text", |
482 |
|
|
.item = &ASN1_UTF8STRING_it, |
483 |
|
|
}, |
484 |
|
|
{ |
485 |
|
|
.flags = ASN1_TFLG_OPTIONAL, |
486 |
|
|
.tag = 0, |
487 |
|
|
.offset = offsetof(TS_STATUS_INFO, failure_info), |
488 |
|
|
.field_name = "failure_info", |
489 |
|
|
.item = &ASN1_BIT_STRING_it, |
490 |
|
|
}, |
491 |
|
|
}; |
492 |
|
|
|
493 |
|
|
const ASN1_ITEM TS_STATUS_INFO_it = { |
494 |
|
|
.itype = ASN1_ITYPE_SEQUENCE, |
495 |
|
|
.utype = V_ASN1_SEQUENCE, |
496 |
|
|
.templates = TS_STATUS_INFO_seq_tt, |
497 |
|
|
.tcount = sizeof(TS_STATUS_INFO_seq_tt) / sizeof(ASN1_TEMPLATE), |
498 |
|
|
.funcs = NULL, |
499 |
|
|
.size = sizeof(TS_STATUS_INFO), |
500 |
|
|
.sname = "TS_STATUS_INFO", |
501 |
|
|
}; |
502 |
|
|
|
503 |
|
|
|
504 |
|
|
TS_STATUS_INFO * |
505 |
|
|
d2i_TS_STATUS_INFO(TS_STATUS_INFO **a, const unsigned char **in, long len) |
506 |
|
|
{ |
507 |
|
|
return (TS_STATUS_INFO *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, |
508 |
|
|
&TS_STATUS_INFO_it); |
509 |
|
|
} |
510 |
|
|
|
511 |
|
|
int |
512 |
|
|
i2d_TS_STATUS_INFO(const TS_STATUS_INFO *a, unsigned char **out) |
513 |
|
|
{ |
514 |
|
|
return ASN1_item_i2d((ASN1_VALUE *)a, out, &TS_STATUS_INFO_it); |
515 |
|
|
} |
516 |
|
|
|
517 |
|
|
TS_STATUS_INFO * |
518 |
|
|
TS_STATUS_INFO_new(void) |
519 |
|
|
{ |
520 |
|
4 |
return (TS_STATUS_INFO *)ASN1_item_new(&TS_STATUS_INFO_it); |
521 |
|
|
} |
522 |
|
|
|
523 |
|
|
void |
524 |
|
|
TS_STATUS_INFO_free(TS_STATUS_INFO *a) |
525 |
|
|
{ |
526 |
|
8 |
ASN1_item_free((ASN1_VALUE *)a, &TS_STATUS_INFO_it); |
527 |
|
4 |
} |
528 |
|
|
|
529 |
|
|
TS_STATUS_INFO * |
530 |
|
|
TS_STATUS_INFO_dup(TS_STATUS_INFO *x) |
531 |
|
|
{ |
532 |
|
4 |
return ASN1_item_dup(&TS_STATUS_INFO_it, x); |
533 |
|
|
} |
534 |
|
|
|
535 |
|
|
static int |
536 |
|
|
ts_resp_set_tst_info(TS_RESP *a) |
537 |
|
|
{ |
538 |
|
|
long status; |
539 |
|
|
|
540 |
|
4 |
status = ASN1_INTEGER_get(a->status_info->status); |
541 |
|
|
|
542 |
✓✗ |
2 |
if (a->token) { |
543 |
✗✓ |
2 |
if (status != 0 && status != 1) { |
544 |
|
|
TSerror(TS_R_TOKEN_PRESENT); |
545 |
|
|
return 0; |
546 |
|
|
} |
547 |
✗✓ |
2 |
if (a->tst_info != NULL) |
548 |
|
|
TS_TST_INFO_free(a->tst_info); |
549 |
|
2 |
a->tst_info = PKCS7_to_TS_TST_INFO(a->token); |
550 |
✗✓ |
2 |
if (!a->tst_info) { |
551 |
|
|
TSerror(TS_R_PKCS7_TO_TS_TST_INFO_FAILED); |
552 |
|
|
return 0; |
553 |
|
|
} |
554 |
|
|
} else if (status == 0 || status == 1) { |
555 |
|
|
TSerror(TS_R_TOKEN_NOT_PRESENT); |
556 |
|
|
return 0; |
557 |
|
|
} |
558 |
|
|
|
559 |
|
2 |
return 1; |
560 |
|
2 |
} |
561 |
|
|
|
562 |
|
|
static int |
563 |
|
|
ts_resp_cb(int op, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) |
564 |
|
|
{ |
565 |
|
52 |
TS_RESP *ts_resp = (TS_RESP *)*pval; |
566 |
|
|
|
567 |
✓✓ |
26 |
if (op == ASN1_OP_NEW_POST) { |
568 |
|
4 |
ts_resp->tst_info = NULL; |
569 |
✓✓ |
26 |
} else if (op == ASN1_OP_FREE_POST) { |
570 |
✓✗ |
4 |
if (ts_resp->tst_info != NULL) |
571 |
|
4 |
TS_TST_INFO_free(ts_resp->tst_info); |
572 |
✓✓ |
18 |
} else if (op == ASN1_OP_D2I_POST) { |
573 |
✗✓ |
2 |
if (ts_resp_set_tst_info(ts_resp) == 0) |
574 |
|
|
return 0; |
575 |
|
|
} |
576 |
|
26 |
return 1; |
577 |
|
26 |
} |
578 |
|
|
|
579 |
|
|
static const ASN1_AUX TS_RESP_aux = { |
580 |
|
|
.app_data = NULL, |
581 |
|
|
.flags = 0, |
582 |
|
|
.ref_offset = 0, |
583 |
|
|
.ref_lock = 0, |
584 |
|
|
.asn1_cb = ts_resp_cb, |
585 |
|
|
.enc_offset = 0, |
586 |
|
|
}; |
587 |
|
|
static const ASN1_TEMPLATE TS_RESP_seq_tt[] = { |
588 |
|
|
{ |
589 |
|
|
.flags = 0, |
590 |
|
|
.tag = 0, |
591 |
|
|
.offset = offsetof(TS_RESP, status_info), |
592 |
|
|
.field_name = "status_info", |
593 |
|
|
.item = &TS_STATUS_INFO_it, |
594 |
|
|
}, |
595 |
|
|
{ |
596 |
|
|
.flags = ASN1_TFLG_OPTIONAL, |
597 |
|
|
.tag = 0, |
598 |
|
|
.offset = offsetof(TS_RESP, token), |
599 |
|
|
.field_name = "token", |
600 |
|
|
.item = &PKCS7_it, |
601 |
|
|
}, |
602 |
|
|
}; |
603 |
|
|
|
604 |
|
|
const ASN1_ITEM TS_RESP_it = { |
605 |
|
|
.itype = ASN1_ITYPE_SEQUENCE, |
606 |
|
|
.utype = V_ASN1_SEQUENCE, |
607 |
|
|
.templates = TS_RESP_seq_tt, |
608 |
|
|
.tcount = sizeof(TS_RESP_seq_tt) / sizeof(ASN1_TEMPLATE), |
609 |
|
|
.funcs = &TS_RESP_aux, |
610 |
|
|
.size = sizeof(TS_RESP), |
611 |
|
|
.sname = "TS_RESP", |
612 |
|
|
}; |
613 |
|
|
|
614 |
|
|
|
615 |
|
|
TS_RESP * |
616 |
|
|
d2i_TS_RESP(TS_RESP **a, const unsigned char **in, long len) |
617 |
|
|
{ |
618 |
|
|
return (TS_RESP *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, |
619 |
|
|
&TS_RESP_it); |
620 |
|
|
} |
621 |
|
|
|
622 |
|
|
int |
623 |
|
|
i2d_TS_RESP(const TS_RESP *a, unsigned char **out) |
624 |
|
|
{ |
625 |
|
|
return ASN1_item_i2d((ASN1_VALUE *)a, out, &TS_RESP_it); |
626 |
|
|
} |
627 |
|
|
|
628 |
|
|
TS_RESP * |
629 |
|
|
TS_RESP_new(void) |
630 |
|
|
{ |
631 |
|
4 |
return (TS_RESP *)ASN1_item_new(&TS_RESP_it); |
632 |
|
|
} |
633 |
|
|
|
634 |
|
|
void |
635 |
|
|
TS_RESP_free(TS_RESP *a) |
636 |
|
|
{ |
637 |
|
12 |
ASN1_item_free((ASN1_VALUE *)a, &TS_RESP_it); |
638 |
|
6 |
} |
639 |
|
|
|
640 |
|
|
TS_RESP * |
641 |
|
|
TS_RESP_dup(TS_RESP *x) |
642 |
|
|
{ |
643 |
|
|
return ASN1_item_dup(&TS_RESP_it, x); |
644 |
|
|
} |
645 |
|
|
|
646 |
|
|
#ifndef OPENSSL_NO_BIO |
647 |
|
|
TS_RESP * |
648 |
|
|
d2i_TS_RESP_bio(BIO *bp, TS_RESP **a) |
649 |
|
|
{ |
650 |
|
4 |
return ASN1_item_d2i_bio(&TS_RESP_it, bp, a); |
651 |
|
|
} |
652 |
|
|
|
653 |
|
|
int |
654 |
|
|
i2d_TS_RESP_bio(BIO *bp, TS_RESP *a) |
655 |
|
|
{ |
656 |
|
4 |
return ASN1_item_i2d_bio(&TS_RESP_it, bp, a); |
657 |
|
|
} |
658 |
|
|
#endif |
659 |
|
|
|
660 |
|
|
TS_RESP * |
661 |
|
|
d2i_TS_RESP_fp(FILE *fp, TS_RESP **a) |
662 |
|
|
{ |
663 |
|
|
return ASN1_item_d2i_fp(&TS_RESP_it, fp, a); |
664 |
|
|
} |
665 |
|
|
|
666 |
|
|
int |
667 |
|
|
i2d_TS_RESP_fp(FILE *fp, TS_RESP *a) |
668 |
|
|
{ |
669 |
|
|
return ASN1_item_i2d_fp(&TS_RESP_it, fp, a); |
670 |
|
|
} |
671 |
|
|
|
672 |
|
|
static const ASN1_TEMPLATE ESS_ISSUER_SERIAL_seq_tt[] = { |
673 |
|
|
{ |
674 |
|
|
.flags = ASN1_TFLG_SEQUENCE_OF, |
675 |
|
|
.tag = 0, |
676 |
|
|
.offset = offsetof(ESS_ISSUER_SERIAL, issuer), |
677 |
|
|
.field_name = "issuer", |
678 |
|
|
.item = &GENERAL_NAME_it, |
679 |
|
|
}, |
680 |
|
|
{ |
681 |
|
|
.flags = 0, |
682 |
|
|
.tag = 0, |
683 |
|
|
.offset = offsetof(ESS_ISSUER_SERIAL, serial), |
684 |
|
|
.field_name = "serial", |
685 |
|
|
.item = &ASN1_INTEGER_it, |
686 |
|
|
}, |
687 |
|
|
}; |
688 |
|
|
|
689 |
|
|
const ASN1_ITEM ESS_ISSUER_SERIAL_it = { |
690 |
|
|
.itype = ASN1_ITYPE_SEQUENCE, |
691 |
|
|
.utype = V_ASN1_SEQUENCE, |
692 |
|
|
.templates = ESS_ISSUER_SERIAL_seq_tt, |
693 |
|
|
.tcount = sizeof(ESS_ISSUER_SERIAL_seq_tt) / sizeof(ASN1_TEMPLATE), |
694 |
|
|
.funcs = NULL, |
695 |
|
|
.size = sizeof(ESS_ISSUER_SERIAL), |
696 |
|
|
.sname = "ESS_ISSUER_SERIAL", |
697 |
|
|
}; |
698 |
|
|
|
699 |
|
|
|
700 |
|
|
ESS_ISSUER_SERIAL * |
701 |
|
|
d2i_ESS_ISSUER_SERIAL(ESS_ISSUER_SERIAL **a, const unsigned char **in, long len) |
702 |
|
|
{ |
703 |
|
|
return (ESS_ISSUER_SERIAL *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, |
704 |
|
|
&ESS_ISSUER_SERIAL_it); |
705 |
|
|
} |
706 |
|
|
|
707 |
|
|
int |
708 |
|
|
i2d_ESS_ISSUER_SERIAL(const ESS_ISSUER_SERIAL *a, unsigned char **out) |
709 |
|
|
{ |
710 |
|
|
return ASN1_item_i2d((ASN1_VALUE *)a, out, &ESS_ISSUER_SERIAL_it); |
711 |
|
|
} |
712 |
|
|
|
713 |
|
|
ESS_ISSUER_SERIAL * |
714 |
|
|
ESS_ISSUER_SERIAL_new(void) |
715 |
|
|
{ |
716 |
|
|
return (ESS_ISSUER_SERIAL *)ASN1_item_new(&ESS_ISSUER_SERIAL_it); |
717 |
|
|
} |
718 |
|
|
|
719 |
|
|
void |
720 |
|
|
ESS_ISSUER_SERIAL_free(ESS_ISSUER_SERIAL *a) |
721 |
|
|
{ |
722 |
|
|
ASN1_item_free((ASN1_VALUE *)a, &ESS_ISSUER_SERIAL_it); |
723 |
|
|
} |
724 |
|
|
|
725 |
|
|
ESS_ISSUER_SERIAL * |
726 |
|
|
ESS_ISSUER_SERIAL_dup(ESS_ISSUER_SERIAL *x) |
727 |
|
|
{ |
728 |
|
|
return ASN1_item_dup(&ESS_ISSUER_SERIAL_it, x); |
729 |
|
|
} |
730 |
|
|
|
731 |
|
|
static const ASN1_TEMPLATE ESS_CERT_ID_seq_tt[] = { |
732 |
|
|
{ |
733 |
|
|
.flags = 0, |
734 |
|
|
.tag = 0, |
735 |
|
|
.offset = offsetof(ESS_CERT_ID, hash), |
736 |
|
|
.field_name = "hash", |
737 |
|
|
.item = &ASN1_OCTET_STRING_it, |
738 |
|
|
}, |
739 |
|
|
{ |
740 |
|
|
.flags = ASN1_TFLG_OPTIONAL, |
741 |
|
|
.tag = 0, |
742 |
|
|
.offset = offsetof(ESS_CERT_ID, issuer_serial), |
743 |
|
|
.field_name = "issuer_serial", |
744 |
|
|
.item = &ESS_ISSUER_SERIAL_it, |
745 |
|
|
}, |
746 |
|
|
}; |
747 |
|
|
|
748 |
|
|
const ASN1_ITEM ESS_CERT_ID_it = { |
749 |
|
|
.itype = ASN1_ITYPE_SEQUENCE, |
750 |
|
|
.utype = V_ASN1_SEQUENCE, |
751 |
|
|
.templates = ESS_CERT_ID_seq_tt, |
752 |
|
|
.tcount = sizeof(ESS_CERT_ID_seq_tt) / sizeof(ASN1_TEMPLATE), |
753 |
|
|
.funcs = NULL, |
754 |
|
|
.size = sizeof(ESS_CERT_ID), |
755 |
|
|
.sname = "ESS_CERT_ID", |
756 |
|
|
}; |
757 |
|
|
|
758 |
|
|
|
759 |
|
|
ESS_CERT_ID * |
760 |
|
|
d2i_ESS_CERT_ID(ESS_CERT_ID **a, const unsigned char **in, long len) |
761 |
|
|
{ |
762 |
|
|
return (ESS_CERT_ID *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, |
763 |
|
|
&ESS_CERT_ID_it); |
764 |
|
|
} |
765 |
|
|
|
766 |
|
|
int |
767 |
|
|
i2d_ESS_CERT_ID(const ESS_CERT_ID *a, unsigned char **out) |
768 |
|
|
{ |
769 |
|
|
return ASN1_item_i2d((ASN1_VALUE *)a, out, &ESS_CERT_ID_it); |
770 |
|
|
} |
771 |
|
|
|
772 |
|
|
ESS_CERT_ID * |
773 |
|
|
ESS_CERT_ID_new(void) |
774 |
|
|
{ |
775 |
|
4 |
return (ESS_CERT_ID *)ASN1_item_new(&ESS_CERT_ID_it); |
776 |
|
|
} |
777 |
|
|
|
778 |
|
|
void |
779 |
|
|
ESS_CERT_ID_free(ESS_CERT_ID *a) |
780 |
|
|
{ |
781 |
|
|
ASN1_item_free((ASN1_VALUE *)a, &ESS_CERT_ID_it); |
782 |
|
|
} |
783 |
|
|
|
784 |
|
|
ESS_CERT_ID * |
785 |
|
|
ESS_CERT_ID_dup(ESS_CERT_ID *x) |
786 |
|
|
{ |
787 |
|
|
return ASN1_item_dup(&ESS_CERT_ID_it, x); |
788 |
|
|
} |
789 |
|
|
|
790 |
|
|
static const ASN1_TEMPLATE ESS_SIGNING_CERT_seq_tt[] = { |
791 |
|
|
{ |
792 |
|
|
.flags = ASN1_TFLG_SEQUENCE_OF, |
793 |
|
|
.tag = 0, |
794 |
|
|
.offset = offsetof(ESS_SIGNING_CERT, cert_ids), |
795 |
|
|
.field_name = "cert_ids", |
796 |
|
|
.item = &ESS_CERT_ID_it, |
797 |
|
|
}, |
798 |
|
|
{ |
799 |
|
|
.flags = ASN1_TFLG_SEQUENCE_OF | ASN1_TFLG_OPTIONAL, |
800 |
|
|
.tag = 0, |
801 |
|
|
.offset = offsetof(ESS_SIGNING_CERT, policy_info), |
802 |
|
|
.field_name = "policy_info", |
803 |
|
|
.item = &POLICYINFO_it, |
804 |
|
|
}, |
805 |
|
|
}; |
806 |
|
|
|
807 |
|
|
const ASN1_ITEM ESS_SIGNING_CERT_it = { |
808 |
|
|
.itype = ASN1_ITYPE_SEQUENCE, |
809 |
|
|
.utype = V_ASN1_SEQUENCE, |
810 |
|
|
.templates = ESS_SIGNING_CERT_seq_tt, |
811 |
|
|
.tcount = sizeof(ESS_SIGNING_CERT_seq_tt) / sizeof(ASN1_TEMPLATE), |
812 |
|
|
.funcs = NULL, |
813 |
|
|
.size = sizeof(ESS_SIGNING_CERT), |
814 |
|
|
.sname = "ESS_SIGNING_CERT", |
815 |
|
|
}; |
816 |
|
|
|
817 |
|
|
|
818 |
|
|
ESS_SIGNING_CERT * |
819 |
|
|
d2i_ESS_SIGNING_CERT(ESS_SIGNING_CERT **a, const unsigned char **in, long len) |
820 |
|
|
{ |
821 |
|
4 |
return (ESS_SIGNING_CERT *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, |
822 |
|
|
&ESS_SIGNING_CERT_it); |
823 |
|
|
} |
824 |
|
|
|
825 |
|
|
int |
826 |
|
|
i2d_ESS_SIGNING_CERT(const ESS_SIGNING_CERT *a, unsigned char **out) |
827 |
|
|
{ |
828 |
|
8 |
return ASN1_item_i2d((ASN1_VALUE *)a, out, &ESS_SIGNING_CERT_it); |
829 |
|
|
} |
830 |
|
|
|
831 |
|
|
ESS_SIGNING_CERT * |
832 |
|
|
ESS_SIGNING_CERT_new(void) |
833 |
|
|
{ |
834 |
|
4 |
return (ESS_SIGNING_CERT *)ASN1_item_new(&ESS_SIGNING_CERT_it); |
835 |
|
|
} |
836 |
|
|
|
837 |
|
|
void |
838 |
|
|
ESS_SIGNING_CERT_free(ESS_SIGNING_CERT *a) |
839 |
|
|
{ |
840 |
|
8 |
ASN1_item_free((ASN1_VALUE *)a, &ESS_SIGNING_CERT_it); |
841 |
|
4 |
} |
842 |
|
|
|
843 |
|
|
ESS_SIGNING_CERT * |
844 |
|
|
ESS_SIGNING_CERT_dup(ESS_SIGNING_CERT *x) |
845 |
|
|
{ |
846 |
|
|
return ASN1_item_dup(&ESS_SIGNING_CERT_it, x); |
847 |
|
|
} |
848 |
|
|
|
849 |
|
|
/* Getting encapsulated TS_TST_INFO object from PKCS7. */ |
850 |
|
|
TS_TST_INFO * |
851 |
|
|
PKCS7_to_TS_TST_INFO(PKCS7 *token) |
852 |
|
|
{ |
853 |
|
|
PKCS7_SIGNED *pkcs7_signed; |
854 |
|
|
PKCS7 *enveloped; |
855 |
|
|
ASN1_TYPE *tst_info_wrapper; |
856 |
|
|
ASN1_OCTET_STRING *tst_info_der; |
857 |
|
4 |
const unsigned char *p; |
858 |
|
|
|
859 |
✗✓ |
2 |
if (!PKCS7_type_is_signed(token)) { |
860 |
|
|
TSerror(TS_R_BAD_PKCS7_TYPE); |
861 |
|
|
return NULL; |
862 |
|
|
} |
863 |
|
|
|
864 |
|
|
/* Content must be present. */ |
865 |
✗✓ |
2 |
if (PKCS7_get_detached(token)) { |
866 |
|
|
TSerror(TS_R_DETACHED_CONTENT); |
867 |
|
|
return NULL; |
868 |
|
|
} |
869 |
|
|
|
870 |
|
|
/* We have a signed data with content. */ |
871 |
|
2 |
pkcs7_signed = token->d.sign; |
872 |
|
2 |
enveloped = pkcs7_signed->contents; |
873 |
✗✓ |
2 |
if (OBJ_obj2nid(enveloped->type) != NID_id_smime_ct_TSTInfo) { |
874 |
|
|
TSerror(TS_R_BAD_PKCS7_TYPE); |
875 |
|
|
return NULL; |
876 |
|
|
} |
877 |
|
|
|
878 |
|
|
/* We have a DER encoded TST_INFO as the signed data. */ |
879 |
|
2 |
tst_info_wrapper = enveloped->d.other; |
880 |
✗✓ |
2 |
if (tst_info_wrapper->type != V_ASN1_OCTET_STRING) { |
881 |
|
|
TSerror(TS_R_BAD_TYPE); |
882 |
|
|
return NULL; |
883 |
|
|
} |
884 |
|
|
|
885 |
|
|
/* We have the correct ASN1_OCTET_STRING type. */ |
886 |
|
2 |
tst_info_der = tst_info_wrapper->value.octet_string; |
887 |
|
|
/* At last, decode the TST_INFO. */ |
888 |
|
2 |
p = tst_info_der->data; |
889 |
|
2 |
return d2i_TS_TST_INFO(NULL, &p, tst_info_der->length); |
890 |
|
2 |
} |