GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: lib/libcrypto/ocsp/ocsp_asn.c Lines: 22 68 32.4 %
Date: 2017-11-07 Branches: 0 0 0.0 %

Line Branch Exec Source
1
/* $OpenBSD: ocsp_asn.c,v 1.9 2016/11/04 18:35:30 jsing Exp $ */
2
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3
 * project 2000.
4
 */
5
/* ====================================================================
6
 * Copyright (c) 2000 The OpenSSL Project.  All rights reserved.
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions
10
 * are met:
11
 *
12
 * 1. Redistributions of source code must retain the above copyright
13
 *    notice, this list of conditions and the following disclaimer.
14
 *
15
 * 2. Redistributions in binary form must reproduce the above copyright
16
 *    notice, this list of conditions and the following disclaimer in
17
 *    the documentation and/or other materials provided with the
18
 *    distribution.
19
 *
20
 * 3. All advertising materials mentioning features or use of this
21
 *    software must display the following acknowledgment:
22
 *    "This product includes software developed by the OpenSSL Project
23
 *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
24
 *
25
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26
 *    endorse or promote products derived from this software without
27
 *    prior written permission. For written permission, please contact
28
 *    licensing@OpenSSL.org.
29
 *
30
 * 5. Products derived from this software may not be called "OpenSSL"
31
 *    nor may "OpenSSL" appear in their names without prior written
32
 *    permission of the OpenSSL Project.
33
 *
34
 * 6. Redistributions of any form whatsoever must retain the following
35
 *    acknowledgment:
36
 *    "This product includes software developed by the OpenSSL Project
37
 *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
38
 *
39
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40
 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
43
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50
 * OF THE POSSIBILITY OF SUCH DAMAGE.
51
 * ====================================================================
52
 *
53
 * This product includes cryptographic software written by Eric Young
54
 * (eay@cryptsoft.com).  This product includes software written by Tim
55
 * Hudson (tjh@cryptsoft.com).
56
 *
57
 */
58
#include <openssl/asn1.h>
59
#include <openssl/asn1t.h>
60
#include <openssl/ocsp.h>
61
62
static const ASN1_TEMPLATE OCSP_SIGNATURE_seq_tt[] = {
63
	{
64
		.flags = 0,
65
		.tag = 0,
66
		.offset = offsetof(OCSP_SIGNATURE, signatureAlgorithm),
67
		.field_name = "signatureAlgorithm",
68
		.item = &X509_ALGOR_it,
69
	},
70
	{
71
		.flags = 0,
72
		.tag = 0,
73
		.offset = offsetof(OCSP_SIGNATURE, signature),
74
		.field_name = "signature",
75
		.item = &ASN1_BIT_STRING_it,
76
	},
77
	{
78
		.flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_SEQUENCE_OF | ASN1_TFLG_OPTIONAL,
79
		.tag = 0,
80
		.offset = offsetof(OCSP_SIGNATURE, certs),
81
		.field_name = "certs",
82
		.item = &X509_it,
83
	},
84
};
85
86
const ASN1_ITEM OCSP_SIGNATURE_it = {
87
	.itype = ASN1_ITYPE_SEQUENCE,
88
	.utype = V_ASN1_SEQUENCE,
89
	.templates = OCSP_SIGNATURE_seq_tt,
90
	.tcount = sizeof(OCSP_SIGNATURE_seq_tt) / sizeof(ASN1_TEMPLATE),
91
	.funcs = NULL,
92
	.size = sizeof(OCSP_SIGNATURE),
93
	.sname = "OCSP_SIGNATURE",
94
};
95
96
97
OCSP_SIGNATURE *
98
d2i_OCSP_SIGNATURE(OCSP_SIGNATURE **a, const unsigned char **in, long len)
99
{
100
	return (OCSP_SIGNATURE *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
101
	    &OCSP_SIGNATURE_it);
102
}
103
104
int
105
i2d_OCSP_SIGNATURE(OCSP_SIGNATURE *a, unsigned char **out)
106
{
107
	return ASN1_item_i2d((ASN1_VALUE *)a, out, &OCSP_SIGNATURE_it);
108
}
109
110
OCSP_SIGNATURE *
111
OCSP_SIGNATURE_new(void)
112
{
113
	return (OCSP_SIGNATURE *)ASN1_item_new(&OCSP_SIGNATURE_it);
114
}
115
116
void
117
OCSP_SIGNATURE_free(OCSP_SIGNATURE *a)
118
{
119
	ASN1_item_free((ASN1_VALUE *)a, &OCSP_SIGNATURE_it);
120
}
121
122
static const ASN1_TEMPLATE OCSP_CERTID_seq_tt[] = {
123
	{
124
		.flags = 0,
125
		.tag = 0,
126
		.offset = offsetof(OCSP_CERTID, hashAlgorithm),
127
		.field_name = "hashAlgorithm",
128
		.item = &X509_ALGOR_it,
129
	},
130
	{
131
		.flags = 0,
132
		.tag = 0,
133
		.offset = offsetof(OCSP_CERTID, issuerNameHash),
134
		.field_name = "issuerNameHash",
135
		.item = &ASN1_OCTET_STRING_it,
136
	},
137
	{
138
		.flags = 0,
139
		.tag = 0,
140
		.offset = offsetof(OCSP_CERTID, issuerKeyHash),
141
		.field_name = "issuerKeyHash",
142
		.item = &ASN1_OCTET_STRING_it,
143
	},
144
	{
145
		.flags = 0,
146
		.tag = 0,
147
		.offset = offsetof(OCSP_CERTID, serialNumber),
148
		.field_name = "serialNumber",
149
		.item = &ASN1_INTEGER_it,
150
	},
151
};
152
153
const ASN1_ITEM OCSP_CERTID_it = {
154
	.itype = ASN1_ITYPE_SEQUENCE,
155
	.utype = V_ASN1_SEQUENCE,
156
	.templates = OCSP_CERTID_seq_tt,
157
	.tcount = sizeof(OCSP_CERTID_seq_tt) / sizeof(ASN1_TEMPLATE),
158
	.funcs = NULL,
159
	.size = sizeof(OCSP_CERTID),
160
	.sname = "OCSP_CERTID",
161
};
162
163
164
OCSP_CERTID *
165
d2i_OCSP_CERTID(OCSP_CERTID **a, const unsigned char **in, long len)
166
{
167
	return (OCSP_CERTID *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
168
	    &OCSP_CERTID_it);
169
}
170
171
int
172
i2d_OCSP_CERTID(OCSP_CERTID *a, unsigned char **out)
173
{
174
	return ASN1_item_i2d((ASN1_VALUE *)a, out, &OCSP_CERTID_it);
175
}
176
177
OCSP_CERTID *
178
OCSP_CERTID_new(void)
179
{
180
32
	return (OCSP_CERTID *)ASN1_item_new(&OCSP_CERTID_it);
181
}
182
183
void
184
OCSP_CERTID_free(OCSP_CERTID *a)
185
{
186
48
	ASN1_item_free((ASN1_VALUE *)a, &OCSP_CERTID_it);
187
24
}
188
189
static const ASN1_TEMPLATE OCSP_ONEREQ_seq_tt[] = {
190
	{
191
		.flags = 0,
192
		.tag = 0,
193
		.offset = offsetof(OCSP_ONEREQ, reqCert),
194
		.field_name = "reqCert",
195
		.item = &OCSP_CERTID_it,
196
	},
197
	{
198
		.flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_SEQUENCE_OF | ASN1_TFLG_OPTIONAL,
199
		.tag = 0,
200
		.offset = offsetof(OCSP_ONEREQ, singleRequestExtensions),
201
		.field_name = "singleRequestExtensions",
202
		.item = &X509_EXTENSION_it,
203
	},
204
};
205
206
const ASN1_ITEM OCSP_ONEREQ_it = {
207
	.itype = ASN1_ITYPE_SEQUENCE,
208
	.utype = V_ASN1_SEQUENCE,
209
	.templates = OCSP_ONEREQ_seq_tt,
210
	.tcount = sizeof(OCSP_ONEREQ_seq_tt) / sizeof(ASN1_TEMPLATE),
211
	.funcs = NULL,
212
	.size = sizeof(OCSP_ONEREQ),
213
	.sname = "OCSP_ONEREQ",
214
};
215
216
217
OCSP_ONEREQ *
218
d2i_OCSP_ONEREQ(OCSP_ONEREQ **a, const unsigned char **in, long len)
219
{
220
	return (OCSP_ONEREQ *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
221
	    &OCSP_ONEREQ_it);
222
}
223
224
int
225
i2d_OCSP_ONEREQ(OCSP_ONEREQ *a, unsigned char **out)
226
{
227
	return ASN1_item_i2d((ASN1_VALUE *)a, out, &OCSP_ONEREQ_it);
228
}
229
230
OCSP_ONEREQ *
231
OCSP_ONEREQ_new(void)
232
{
233
16
	return (OCSP_ONEREQ *)ASN1_item_new(&OCSP_ONEREQ_it);
234
}
235
236
void
237
OCSP_ONEREQ_free(OCSP_ONEREQ *a)
238
{
239
	ASN1_item_free((ASN1_VALUE *)a, &OCSP_ONEREQ_it);
240
}
241
242
static const ASN1_TEMPLATE OCSP_REQINFO_seq_tt[] = {
243
	{
244
		.flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_OPTIONAL,
245
		.tag = 0,
246
		.offset = offsetof(OCSP_REQINFO, version),
247
		.field_name = "version",
248
		.item = &ASN1_INTEGER_it,
249
	},
250
	{
251
		.flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_OPTIONAL,
252
		.tag = 1,
253
		.offset = offsetof(OCSP_REQINFO, requestorName),
254
		.field_name = "requestorName",
255
		.item = &GENERAL_NAME_it,
256
	},
257
	{
258
		.flags = ASN1_TFLG_SEQUENCE_OF,
259
		.tag = 0,
260
		.offset = offsetof(OCSP_REQINFO, requestList),
261
		.field_name = "requestList",
262
		.item = &OCSP_ONEREQ_it,
263
	},
264
	{
265
		.flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_SEQUENCE_OF | ASN1_TFLG_OPTIONAL,
266
		.tag = 2,
267
		.offset = offsetof(OCSP_REQINFO, requestExtensions),
268
		.field_name = "requestExtensions",
269
		.item = &X509_EXTENSION_it,
270
	},
271
};
272
273
const ASN1_ITEM OCSP_REQINFO_it = {
274
	.itype = ASN1_ITYPE_SEQUENCE,
275
	.utype = V_ASN1_SEQUENCE,
276
	.templates = OCSP_REQINFO_seq_tt,
277
	.tcount = sizeof(OCSP_REQINFO_seq_tt) / sizeof(ASN1_TEMPLATE),
278
	.funcs = NULL,
279
	.size = sizeof(OCSP_REQINFO),
280
	.sname = "OCSP_REQINFO",
281
};
282
283
284
OCSP_REQINFO *
285
d2i_OCSP_REQINFO(OCSP_REQINFO **a, const unsigned char **in, long len)
286
{
287
	return (OCSP_REQINFO *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
288
	    &OCSP_REQINFO_it);
289
}
290
291
int
292
i2d_OCSP_REQINFO(OCSP_REQINFO *a, unsigned char **out)
293
{
294
	return ASN1_item_i2d((ASN1_VALUE *)a, out, &OCSP_REQINFO_it);
295
}
296
297
OCSP_REQINFO *
298
OCSP_REQINFO_new(void)
299
{
300
	return (OCSP_REQINFO *)ASN1_item_new(&OCSP_REQINFO_it);
301
}
302
303
void
304
OCSP_REQINFO_free(OCSP_REQINFO *a)
305
{
306
	ASN1_item_free((ASN1_VALUE *)a, &OCSP_REQINFO_it);
307
}
308
309
static const ASN1_TEMPLATE OCSP_REQUEST_seq_tt[] = {
310
	{
311
		.flags = 0,
312
		.tag = 0,
313
		.offset = offsetof(OCSP_REQUEST, tbsRequest),
314
		.field_name = "tbsRequest",
315
		.item = &OCSP_REQINFO_it,
316
	},
317
	{
318
		.flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_OPTIONAL,
319
		.tag = 0,
320
		.offset = offsetof(OCSP_REQUEST, optionalSignature),
321
		.field_name = "optionalSignature",
322
		.item = &OCSP_SIGNATURE_it,
323
	},
324
};
325
326
const ASN1_ITEM OCSP_REQUEST_it = {
327
	.itype = ASN1_ITYPE_SEQUENCE,
328
	.utype = V_ASN1_SEQUENCE,
329
	.templates = OCSP_REQUEST_seq_tt,
330
	.tcount = sizeof(OCSP_REQUEST_seq_tt) / sizeof(ASN1_TEMPLATE),
331
	.funcs = NULL,
332
	.size = sizeof(OCSP_REQUEST),
333
	.sname = "OCSP_REQUEST",
334
};
335
336
OCSP_REQUEST *
337
d2i_OCSP_REQUEST(OCSP_REQUEST **a, const unsigned char **in, long len)
338
{
339
	return (OCSP_REQUEST *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
340
	    &OCSP_REQUEST_it);
341
}
342
343
int
344
i2d_OCSP_REQUEST(OCSP_REQUEST *a, unsigned char **out)
345
{
346
4
	return ASN1_item_i2d((ASN1_VALUE *)a, out, &OCSP_REQUEST_it);
347
}
348
349
OCSP_REQUEST *
350
d2i_OCSP_REQUEST_bio(BIO *bp, OCSP_REQUEST **a)
351
{
352
8
	return ASN1_item_d2i_bio(&OCSP_REQUEST_it, bp, a);
353
}
354
355
int
356
i2d_OCSP_REQUEST_bio(BIO *bp, OCSP_REQUEST *a)
357
{
358
8
	return ASN1_item_i2d_bio(&OCSP_REQUEST_it, bp, a);
359
}
360
361
OCSP_REQUEST *
362
OCSP_REQUEST_new(void)
363
{
364
8
	return (OCSP_REQUEST *)ASN1_item_new(&OCSP_REQUEST_it);
365
}
366
367
void
368
OCSP_REQUEST_free(OCSP_REQUEST *a)
369
{
370
20
	ASN1_item_free((ASN1_VALUE *)a, &OCSP_REQUEST_it);
371
10
}
372
373
/* OCSP_RESPONSE templates */
374
375
static const ASN1_TEMPLATE OCSP_RESPBYTES_seq_tt[] = {
376
	{
377
		.flags = 0,
378
		.tag = 0,
379
		.offset = offsetof(OCSP_RESPBYTES, responseType),
380
		.field_name = "responseType",
381
		.item = &ASN1_OBJECT_it,
382
	},
383
	{
384
		.flags = 0,
385
		.tag = 0,
386
		.offset = offsetof(OCSP_RESPBYTES, response),
387
		.field_name = "response",
388
		.item = &ASN1_OCTET_STRING_it,
389
	},
390
};
391
392
const ASN1_ITEM OCSP_RESPBYTES_it = {
393
	.itype = ASN1_ITYPE_SEQUENCE,
394
	.utype = V_ASN1_SEQUENCE,
395
	.templates = OCSP_RESPBYTES_seq_tt,
396
	.tcount = sizeof(OCSP_RESPBYTES_seq_tt) / sizeof(ASN1_TEMPLATE),
397
	.funcs = NULL,
398
	.size = sizeof(OCSP_RESPBYTES),
399
	.sname = "OCSP_RESPBYTES",
400
};
401
402
403
OCSP_RESPBYTES *
404
d2i_OCSP_RESPBYTES(OCSP_RESPBYTES **a, const unsigned char **in, long len)
405
{
406
	return (OCSP_RESPBYTES *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
407
	    &OCSP_RESPBYTES_it);
408
}
409
410
int
411
i2d_OCSP_RESPBYTES(OCSP_RESPBYTES *a, unsigned char **out)
412
{
413
	return ASN1_item_i2d((ASN1_VALUE *)a, out, &OCSP_RESPBYTES_it);
414
}
415
416
OCSP_RESPBYTES *
417
OCSP_RESPBYTES_new(void)
418
{
419
8
	return (OCSP_RESPBYTES *)ASN1_item_new(&OCSP_RESPBYTES_it);
420
}
421
422
void
423
OCSP_RESPBYTES_free(OCSP_RESPBYTES *a)
424
{
425
	ASN1_item_free((ASN1_VALUE *)a, &OCSP_RESPBYTES_it);
426
}
427
428
static const ASN1_TEMPLATE OCSP_RESPONSE_seq_tt[] = {
429
	{
430
		.flags = 0,
431
		.tag = 0,
432
		.offset = offsetof(OCSP_RESPONSE, responseStatus),
433
		.field_name = "responseStatus",
434
		.item = &ASN1_ENUMERATED_it,
435
	},
436
	{
437
		.flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_OPTIONAL,
438
		.tag = 0,
439
		.offset = offsetof(OCSP_RESPONSE, responseBytes),
440
		.field_name = "responseBytes",
441
		.item = &OCSP_RESPBYTES_it,
442
	},
443
};
444
445
const ASN1_ITEM OCSP_RESPONSE_it = {
446
	.itype = ASN1_ITYPE_SEQUENCE,
447
	.utype = V_ASN1_SEQUENCE,
448
	.templates = OCSP_RESPONSE_seq_tt,
449
	.tcount = sizeof(OCSP_RESPONSE_seq_tt) / sizeof(ASN1_TEMPLATE),
450
	.funcs = NULL,
451
	.size = sizeof(OCSP_RESPONSE),
452
	.sname = "OCSP_RESPONSE",
453
};
454
455
456
OCSP_RESPONSE *
457
d2i_OCSP_RESPONSE(OCSP_RESPONSE **a, const unsigned char **in, long len)
458
{
459
4
	return (OCSP_RESPONSE *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
460
	    &OCSP_RESPONSE_it);
461
}
462
463
int
464
i2d_OCSP_RESPONSE(OCSP_RESPONSE *a, unsigned char **out)
465
{
466
4
	return ASN1_item_i2d((ASN1_VALUE *)a, out, &OCSP_RESPONSE_it);
467
}
468
469
OCSP_RESPONSE *
470
d2i_OCSP_RESPONSE_bio(BIO *bp, OCSP_RESPONSE **a)
471
{
472
	return ASN1_item_d2i_bio(&OCSP_RESPONSE_it, bp, a);
473
}
474
475
int
476
i2d_OCSP_RESPONSE_bio(BIO *bp, OCSP_RESPONSE *a)
477
{
478
12
	return ASN1_item_i2d_bio(&OCSP_RESPONSE_it, bp, a);
479
}
480
481
OCSP_RESPONSE *
482
OCSP_RESPONSE_new(void)
483
{
484
8
	return (OCSP_RESPONSE *)ASN1_item_new(&OCSP_RESPONSE_it);
485
}
486
487
void
488
OCSP_RESPONSE_free(OCSP_RESPONSE *a)
489
{
490
20
	ASN1_item_free((ASN1_VALUE *)a, &OCSP_RESPONSE_it);
491
10
}
492
493
static const ASN1_TEMPLATE OCSP_RESPID_ch_tt[] = {
494
	{
495
		.flags = ASN1_TFLG_EXPLICIT,
496
		.tag = 1,
497
		.offset = offsetof(OCSP_RESPID, value.byName),
498
		.field_name = "value.byName",
499
		.item = &X509_NAME_it,
500
	},
501
	{
502
		.flags = ASN1_TFLG_EXPLICIT,
503
		.tag = 2,
504
		.offset = offsetof(OCSP_RESPID, value.byKey),
505
		.field_name = "value.byKey",
506
		.item = &ASN1_OCTET_STRING_it,
507
	},
508
};
509
510
const ASN1_ITEM OCSP_RESPID_it = {
511
	.itype = ASN1_ITYPE_CHOICE,
512
	.utype = offsetof(OCSP_RESPID, type),
513
	.templates = OCSP_RESPID_ch_tt,
514
	.tcount = sizeof(OCSP_RESPID_ch_tt) / sizeof(ASN1_TEMPLATE),
515
	.funcs = NULL,
516
	.size = sizeof(OCSP_RESPID),
517
	.sname = "OCSP_RESPID",
518
};
519
520
521
OCSP_RESPID *
522
d2i_OCSP_RESPID(OCSP_RESPID **a, const unsigned char **in, long len)
523
{
524
	return (OCSP_RESPID *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
525
	    &OCSP_RESPID_it);
526
}
527
528
int
529
i2d_OCSP_RESPID(OCSP_RESPID *a, unsigned char **out)
530
{
531
	return ASN1_item_i2d((ASN1_VALUE *)a, out, &OCSP_RESPID_it);
532
}
533
534
OCSP_RESPID *
535
OCSP_RESPID_new(void)
536
{
537
	return (OCSP_RESPID *)ASN1_item_new(&OCSP_RESPID_it);
538
}
539
540
void
541
OCSP_RESPID_free(OCSP_RESPID *a)
542
{
543
	ASN1_item_free((ASN1_VALUE *)a, &OCSP_RESPID_it);
544
}
545
546
static const ASN1_TEMPLATE OCSP_REVOKEDINFO_seq_tt[] = {
547
	{
548
		.flags = 0,
549
		.tag = 0,
550
		.offset = offsetof(OCSP_REVOKEDINFO, revocationTime),
551
		.field_name = "revocationTime",
552
		.item = &ASN1_GENERALIZEDTIME_it,
553
	},
554
	{
555
		.flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_OPTIONAL,
556
		.tag = 0,
557
		.offset = offsetof(OCSP_REVOKEDINFO, revocationReason),
558
		.field_name = "revocationReason",
559
		.item = &ASN1_ENUMERATED_it,
560
	},
561
};
562
563
const ASN1_ITEM OCSP_REVOKEDINFO_it = {
564
	.itype = ASN1_ITYPE_SEQUENCE,
565
	.utype = V_ASN1_SEQUENCE,
566
	.templates = OCSP_REVOKEDINFO_seq_tt,
567
	.tcount = sizeof(OCSP_REVOKEDINFO_seq_tt) / sizeof(ASN1_TEMPLATE),
568
	.funcs = NULL,
569
	.size = sizeof(OCSP_REVOKEDINFO),
570
	.sname = "OCSP_REVOKEDINFO",
571
};
572
573
574
OCSP_REVOKEDINFO *
575
d2i_OCSP_REVOKEDINFO(OCSP_REVOKEDINFO **a, const unsigned char **in, long len)
576
{
577
	return (OCSP_REVOKEDINFO *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
578
	    &OCSP_REVOKEDINFO_it);
579
}
580
581
int
582
i2d_OCSP_REVOKEDINFO(OCSP_REVOKEDINFO *a, unsigned char **out)
583
{
584
	return ASN1_item_i2d((ASN1_VALUE *)a, out, &OCSP_REVOKEDINFO_it);
585
}
586
587
OCSP_REVOKEDINFO *
588
OCSP_REVOKEDINFO_new(void)
589
{
590
8
	return (OCSP_REVOKEDINFO *)ASN1_item_new(&OCSP_REVOKEDINFO_it);
591
}
592
593
void
594
OCSP_REVOKEDINFO_free(OCSP_REVOKEDINFO *a)
595
{
596
	ASN1_item_free((ASN1_VALUE *)a, &OCSP_REVOKEDINFO_it);
597
}
598
599
static const ASN1_TEMPLATE OCSP_CERTSTATUS_ch_tt[] = {
600
	{
601
		.flags = ASN1_TFLG_IMPLICIT,
602
		.tag = 0,
603
		.offset = offsetof(OCSP_CERTSTATUS, value.good),
604
		.field_name = "value.good",
605
		.item = &ASN1_NULL_it,
606
	},
607
	{
608
		.flags = ASN1_TFLG_IMPLICIT,
609
		.tag = 1,
610
		.offset = offsetof(OCSP_CERTSTATUS, value.revoked),
611
		.field_name = "value.revoked",
612
		.item = &OCSP_REVOKEDINFO_it,
613
	},
614
	{
615
		.flags = ASN1_TFLG_IMPLICIT,
616
		.tag = 2,
617
		.offset = offsetof(OCSP_CERTSTATUS, value.unknown),
618
		.field_name = "value.unknown",
619
		.item = &ASN1_NULL_it,
620
	},
621
};
622
623
const ASN1_ITEM OCSP_CERTSTATUS_it = {
624
	.itype = ASN1_ITYPE_CHOICE,
625
	.utype = offsetof(OCSP_CERTSTATUS, type),
626
	.templates = OCSP_CERTSTATUS_ch_tt,
627
	.tcount = sizeof(OCSP_CERTSTATUS_ch_tt) / sizeof(ASN1_TEMPLATE),
628
	.funcs = NULL,
629
	.size = sizeof(OCSP_CERTSTATUS),
630
	.sname = "OCSP_CERTSTATUS",
631
};
632
633
634
OCSP_CERTSTATUS *
635
d2i_OCSP_CERTSTATUS(OCSP_CERTSTATUS **a, const unsigned char **in, long len)
636
{
637
	return (OCSP_CERTSTATUS *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
638
	    &OCSP_CERTSTATUS_it);
639
}
640
641
int
642
i2d_OCSP_CERTSTATUS(OCSP_CERTSTATUS *a, unsigned char **out)
643
{
644
	return ASN1_item_i2d((ASN1_VALUE *)a, out, &OCSP_CERTSTATUS_it);
645
}
646
647
OCSP_CERTSTATUS *
648
OCSP_CERTSTATUS_new(void)
649
{
650
	return (OCSP_CERTSTATUS *)ASN1_item_new(&OCSP_CERTSTATUS_it);
651
}
652
653
void
654
OCSP_CERTSTATUS_free(OCSP_CERTSTATUS *a)
655
{
656
	ASN1_item_free((ASN1_VALUE *)a, &OCSP_CERTSTATUS_it);
657
}
658
659
static const ASN1_TEMPLATE OCSP_SINGLERESP_seq_tt[] = {
660
	{
661
		.flags = 0,
662
		.tag = 0,
663
		.offset = offsetof(OCSP_SINGLERESP, certId),
664
		.field_name = "certId",
665
		.item = &OCSP_CERTID_it,
666
	},
667
	{
668
		.flags = 0,
669
		.tag = 0,
670
		.offset = offsetof(OCSP_SINGLERESP, certStatus),
671
		.field_name = "certStatus",
672
		.item = &OCSP_CERTSTATUS_it,
673
	},
674
	{
675
		.flags = 0,
676
		.tag = 0,
677
		.offset = offsetof(OCSP_SINGLERESP, thisUpdate),
678
		.field_name = "thisUpdate",
679
		.item = &ASN1_GENERALIZEDTIME_it,
680
	},
681
	{
682
		.flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_OPTIONAL,
683
		.tag = 0,
684
		.offset = offsetof(OCSP_SINGLERESP, nextUpdate),
685
		.field_name = "nextUpdate",
686
		.item = &ASN1_GENERALIZEDTIME_it,
687
	},
688
	{
689
		.flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_SEQUENCE_OF | ASN1_TFLG_OPTIONAL,
690
		.tag = 1,
691
		.offset = offsetof(OCSP_SINGLERESP, singleExtensions),
692
		.field_name = "singleExtensions",
693
		.item = &X509_EXTENSION_it,
694
	},
695
};
696
697
const ASN1_ITEM OCSP_SINGLERESP_it = {
698
	.itype = ASN1_ITYPE_SEQUENCE,
699
	.utype = V_ASN1_SEQUENCE,
700
	.templates = OCSP_SINGLERESP_seq_tt,
701
	.tcount = sizeof(OCSP_SINGLERESP_seq_tt) / sizeof(ASN1_TEMPLATE),
702
	.funcs = NULL,
703
	.size = sizeof(OCSP_SINGLERESP),
704
	.sname = "OCSP_SINGLERESP",
705
};
706
707
708
OCSP_SINGLERESP *
709
d2i_OCSP_SINGLERESP(OCSP_SINGLERESP **a, const unsigned char **in, long len)
710
{
711
	return (OCSP_SINGLERESP *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
712
	    &OCSP_SINGLERESP_it);
713
}
714
715
int
716
i2d_OCSP_SINGLERESP(OCSP_SINGLERESP *a, unsigned char **out)
717
{
718
	return ASN1_item_i2d((ASN1_VALUE *)a, out, &OCSP_SINGLERESP_it);
719
}
720
721
OCSP_SINGLERESP *
722
OCSP_SINGLERESP_new(void)
723
{
724
16
	return (OCSP_SINGLERESP *)ASN1_item_new(&OCSP_SINGLERESP_it);
725
}
726
727
void
728
OCSP_SINGLERESP_free(OCSP_SINGLERESP *a)
729
{
730
	ASN1_item_free((ASN1_VALUE *)a, &OCSP_SINGLERESP_it);
731
}
732
733
static const ASN1_TEMPLATE OCSP_RESPDATA_seq_tt[] = {
734
	{
735
		.flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_OPTIONAL,
736
		.tag = 0,
737
		.offset = offsetof(OCSP_RESPDATA, version),
738
		.field_name = "version",
739
		.item = &ASN1_INTEGER_it,
740
	},
741
	{
742
		.flags = 0,
743
		.tag = 0,
744
		.offset = offsetof(OCSP_RESPDATA, responderId),
745
		.field_name = "responderId",
746
		.item = &OCSP_RESPID_it,
747
	},
748
	{
749
		.flags = 0,
750
		.tag = 0,
751
		.offset = offsetof(OCSP_RESPDATA, producedAt),
752
		.field_name = "producedAt",
753
		.item = &ASN1_GENERALIZEDTIME_it,
754
	},
755
	{
756
		.flags = ASN1_TFLG_SEQUENCE_OF,
757
		.tag = 0,
758
		.offset = offsetof(OCSP_RESPDATA, responses),
759
		.field_name = "responses",
760
		.item = &OCSP_SINGLERESP_it,
761
	},
762
	{
763
		.flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_SEQUENCE_OF | ASN1_TFLG_OPTIONAL,
764
		.tag = 1,
765
		.offset = offsetof(OCSP_RESPDATA, responseExtensions),
766
		.field_name = "responseExtensions",
767
		.item = &X509_EXTENSION_it,
768
	},
769
};
770
771
const ASN1_ITEM OCSP_RESPDATA_it = {
772
	.itype = ASN1_ITYPE_SEQUENCE,
773
	.utype = V_ASN1_SEQUENCE,
774
	.templates = OCSP_RESPDATA_seq_tt,
775
	.tcount = sizeof(OCSP_RESPDATA_seq_tt) / sizeof(ASN1_TEMPLATE),
776
	.funcs = NULL,
777
	.size = sizeof(OCSP_RESPDATA),
778
	.sname = "OCSP_RESPDATA",
779
};
780
781
782
OCSP_RESPDATA *
783
d2i_OCSP_RESPDATA(OCSP_RESPDATA **a, const unsigned char **in, long len)
784
{
785
	return (OCSP_RESPDATA *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
786
	    &OCSP_RESPDATA_it);
787
}
788
789
int
790
i2d_OCSP_RESPDATA(OCSP_RESPDATA *a, unsigned char **out)
791
{
792
	return ASN1_item_i2d((ASN1_VALUE *)a, out, &OCSP_RESPDATA_it);
793
}
794
795
OCSP_RESPDATA *
796
OCSP_RESPDATA_new(void)
797
{
798
	return (OCSP_RESPDATA *)ASN1_item_new(&OCSP_RESPDATA_it);
799
}
800
801
void
802
OCSP_RESPDATA_free(OCSP_RESPDATA *a)
803
{
804
	ASN1_item_free((ASN1_VALUE *)a, &OCSP_RESPDATA_it);
805
}
806
807
static const ASN1_TEMPLATE OCSP_BASICRESP_seq_tt[] = {
808
	{
809
		.flags = 0,
810
		.tag = 0,
811
		.offset = offsetof(OCSP_BASICRESP, tbsResponseData),
812
		.field_name = "tbsResponseData",
813
		.item = &OCSP_RESPDATA_it,
814
	},
815
	{
816
		.flags = 0,
817
		.tag = 0,
818
		.offset = offsetof(OCSP_BASICRESP, signatureAlgorithm),
819
		.field_name = "signatureAlgorithm",
820
		.item = &X509_ALGOR_it,
821
	},
822
	{
823
		.flags = 0,
824
		.tag = 0,
825
		.offset = offsetof(OCSP_BASICRESP, signature),
826
		.field_name = "signature",
827
		.item = &ASN1_BIT_STRING_it,
828
	},
829
	{
830
		.flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_SEQUENCE_OF | ASN1_TFLG_OPTIONAL,
831
		.tag = 0,
832
		.offset = offsetof(OCSP_BASICRESP, certs),
833
		.field_name = "certs",
834
		.item = &X509_it,
835
	},
836
};
837
838
const ASN1_ITEM OCSP_BASICRESP_it = {
839
	.itype = ASN1_ITYPE_SEQUENCE,
840
	.utype = V_ASN1_SEQUENCE,
841
	.templates = OCSP_BASICRESP_seq_tt,
842
	.tcount = sizeof(OCSP_BASICRESP_seq_tt) / sizeof(ASN1_TEMPLATE),
843
	.funcs = NULL,
844
	.size = sizeof(OCSP_BASICRESP),
845
	.sname = "OCSP_BASICRESP",
846
};
847
848
849
OCSP_BASICRESP *
850
d2i_OCSP_BASICRESP(OCSP_BASICRESP **a, const unsigned char **in, long len)
851
{
852
	return (OCSP_BASICRESP *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
853
	    &OCSP_BASICRESP_it);
854
}
855
856
int
857
i2d_OCSP_BASICRESP(OCSP_BASICRESP *a, unsigned char **out)
858
{
859
	return ASN1_item_i2d((ASN1_VALUE *)a, out, &OCSP_BASICRESP_it);
860
}
861
862
OCSP_BASICRESP *
863
OCSP_BASICRESP_new(void)
864
{
865
8
	return (OCSP_BASICRESP *)ASN1_item_new(&OCSP_BASICRESP_it);
866
}
867
868
void
869
OCSP_BASICRESP_free(OCSP_BASICRESP *a)
870
{
871
36
	ASN1_item_free((ASN1_VALUE *)a, &OCSP_BASICRESP_it);
872
18
}
873
874
static const ASN1_TEMPLATE OCSP_CRLID_seq_tt[] = {
875
	{
876
		.flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_OPTIONAL,
877
		.tag = 0,
878
		.offset = offsetof(OCSP_CRLID, crlUrl),
879
		.field_name = "crlUrl",
880
		.item = &ASN1_IA5STRING_it,
881
	},
882
	{
883
		.flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_OPTIONAL,
884
		.tag = 1,
885
		.offset = offsetof(OCSP_CRLID, crlNum),
886
		.field_name = "crlNum",
887
		.item = &ASN1_INTEGER_it,
888
	},
889
	{
890
		.flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_OPTIONAL,
891
		.tag = 2,
892
		.offset = offsetof(OCSP_CRLID, crlTime),
893
		.field_name = "crlTime",
894
		.item = &ASN1_GENERALIZEDTIME_it,
895
	},
896
};
897
898
const ASN1_ITEM OCSP_CRLID_it = {
899
	.itype = ASN1_ITYPE_SEQUENCE,
900
	.utype = V_ASN1_SEQUENCE,
901
	.templates = OCSP_CRLID_seq_tt,
902
	.tcount = sizeof(OCSP_CRLID_seq_tt) / sizeof(ASN1_TEMPLATE),
903
	.funcs = NULL,
904
	.size = sizeof(OCSP_CRLID),
905
	.sname = "OCSP_CRLID",
906
};
907
908
909
OCSP_CRLID *
910
d2i_OCSP_CRLID(OCSP_CRLID **a, const unsigned char **in, long len)
911
{
912
	return (OCSP_CRLID *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
913
	    &OCSP_CRLID_it);
914
}
915
916
int
917
i2d_OCSP_CRLID(OCSP_CRLID *a, unsigned char **out)
918
{
919
	return ASN1_item_i2d((ASN1_VALUE *)a, out, &OCSP_CRLID_it);
920
}
921
922
OCSP_CRLID *
923
OCSP_CRLID_new(void)
924
{
925
	return (OCSP_CRLID *)ASN1_item_new(&OCSP_CRLID_it);
926
}
927
928
void
929
OCSP_CRLID_free(OCSP_CRLID *a)
930
{
931
	ASN1_item_free((ASN1_VALUE *)a, &OCSP_CRLID_it);
932
}
933
934
static const ASN1_TEMPLATE OCSP_SERVICELOC_seq_tt[] = {
935
	{
936
		.flags = 0,
937
		.tag = 0,
938
		.offset = offsetof(OCSP_SERVICELOC, issuer),
939
		.field_name = "issuer",
940
		.item = &X509_NAME_it,
941
	},
942
	{
943
		.flags = ASN1_TFLG_SEQUENCE_OF | ASN1_TFLG_OPTIONAL,
944
		.tag = 0,
945
		.offset = offsetof(OCSP_SERVICELOC, locator),
946
		.field_name = "locator",
947
		.item = &ACCESS_DESCRIPTION_it,
948
	},
949
};
950
951
const ASN1_ITEM OCSP_SERVICELOC_it = {
952
	.itype = ASN1_ITYPE_SEQUENCE,
953
	.utype = V_ASN1_SEQUENCE,
954
	.templates = OCSP_SERVICELOC_seq_tt,
955
	.tcount = sizeof(OCSP_SERVICELOC_seq_tt) / sizeof(ASN1_TEMPLATE),
956
	.funcs = NULL,
957
	.size = sizeof(OCSP_SERVICELOC),
958
	.sname = "OCSP_SERVICELOC",
959
};
960
961
962
OCSP_SERVICELOC *
963
d2i_OCSP_SERVICELOC(OCSP_SERVICELOC **a, const unsigned char **in, long len)
964
{
965
	return (OCSP_SERVICELOC *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
966
	    &OCSP_SERVICELOC_it);
967
}
968
969
int
970
i2d_OCSP_SERVICELOC(OCSP_SERVICELOC *a, unsigned char **out)
971
{
972
	return ASN1_item_i2d((ASN1_VALUE *)a, out, &OCSP_SERVICELOC_it);
973
}
974
975
OCSP_SERVICELOC *
976
OCSP_SERVICELOC_new(void)
977
{
978
	return (OCSP_SERVICELOC *)ASN1_item_new(&OCSP_SERVICELOC_it);
979
}
980
981
void
982
OCSP_SERVICELOC_free(OCSP_SERVICELOC *a)
983
{
984
	ASN1_item_free((ASN1_VALUE *)a, &OCSP_SERVICELOC_it);
985
}