GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: lib/libcrypto/crypto/../../libssl/src/crypto/ocsp/ocsp_asn.c Lines: 2 61 3.3 %
Date: 2016-12-06 Branches: 0 0 0.0 %

Line Branch Exec Source
1
/* $OpenBSD: ocsp_asn.c,v 1.8 2015/07/25 14:52:47 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
	return (OCSP_CERTID *)ASN1_item_new(&OCSP_CERTID_it);
181
}
182
183
void
184
OCSP_CERTID_free(OCSP_CERTID *a)
185
{
186
	ASN1_item_free((ASN1_VALUE *)a, &OCSP_CERTID_it);
187
}
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
	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
337
OCSP_REQUEST *
338
d2i_OCSP_REQUEST(OCSP_REQUEST **a, const unsigned char **in, long len)
339
{
340
	return (OCSP_REQUEST *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
341
	    &OCSP_REQUEST_it);
342
}
343
344
int
345
i2d_OCSP_REQUEST(OCSP_REQUEST *a, unsigned char **out)
346
{
347
	return ASN1_item_i2d((ASN1_VALUE *)a, out, &OCSP_REQUEST_it);
348
}
349
350
OCSP_REQUEST *
351
OCSP_REQUEST_new(void)
352
{
353
	return (OCSP_REQUEST *)ASN1_item_new(&OCSP_REQUEST_it);
354
}
355
356
void
357
OCSP_REQUEST_free(OCSP_REQUEST *a)
358
{
359
	ASN1_item_free((ASN1_VALUE *)a, &OCSP_REQUEST_it);
360
}
361
362
/* OCSP_RESPONSE templates */
363
364
static const ASN1_TEMPLATE OCSP_RESPBYTES_seq_tt[] = {
365
	{
366
		.flags = 0,
367
		.tag = 0,
368
		.offset = offsetof(OCSP_RESPBYTES, responseType),
369
		.field_name = "responseType",
370
		.item = &ASN1_OBJECT_it,
371
	},
372
	{
373
		.flags = 0,
374
		.tag = 0,
375
		.offset = offsetof(OCSP_RESPBYTES, response),
376
		.field_name = "response",
377
		.item = &ASN1_OCTET_STRING_it,
378
	},
379
};
380
381
const ASN1_ITEM OCSP_RESPBYTES_it = {
382
	.itype = ASN1_ITYPE_SEQUENCE,
383
	.utype = V_ASN1_SEQUENCE,
384
	.templates = OCSP_RESPBYTES_seq_tt,
385
	.tcount = sizeof(OCSP_RESPBYTES_seq_tt) / sizeof(ASN1_TEMPLATE),
386
	.funcs = NULL,
387
	.size = sizeof(OCSP_RESPBYTES),
388
	.sname = "OCSP_RESPBYTES",
389
};
390
391
392
OCSP_RESPBYTES *
393
d2i_OCSP_RESPBYTES(OCSP_RESPBYTES **a, const unsigned char **in, long len)
394
{
395
	return (OCSP_RESPBYTES *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
396
	    &OCSP_RESPBYTES_it);
397
}
398
399
int
400
i2d_OCSP_RESPBYTES(OCSP_RESPBYTES *a, unsigned char **out)
401
{
402
	return ASN1_item_i2d((ASN1_VALUE *)a, out, &OCSP_RESPBYTES_it);
403
}
404
405
OCSP_RESPBYTES *
406
OCSP_RESPBYTES_new(void)
407
{
408
	return (OCSP_RESPBYTES *)ASN1_item_new(&OCSP_RESPBYTES_it);
409
}
410
411
void
412
OCSP_RESPBYTES_free(OCSP_RESPBYTES *a)
413
{
414
	ASN1_item_free((ASN1_VALUE *)a, &OCSP_RESPBYTES_it);
415
}
416
417
static const ASN1_TEMPLATE OCSP_RESPONSE_seq_tt[] = {
418
	{
419
		.flags = 0,
420
		.tag = 0,
421
		.offset = offsetof(OCSP_RESPONSE, responseStatus),
422
		.field_name = "responseStatus",
423
		.item = &ASN1_ENUMERATED_it,
424
	},
425
	{
426
		.flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_OPTIONAL,
427
		.tag = 0,
428
		.offset = offsetof(OCSP_RESPONSE, responseBytes),
429
		.field_name = "responseBytes",
430
		.item = &OCSP_RESPBYTES_it,
431
	},
432
};
433
434
const ASN1_ITEM OCSP_RESPONSE_it = {
435
	.itype = ASN1_ITYPE_SEQUENCE,
436
	.utype = V_ASN1_SEQUENCE,
437
	.templates = OCSP_RESPONSE_seq_tt,
438
	.tcount = sizeof(OCSP_RESPONSE_seq_tt) / sizeof(ASN1_TEMPLATE),
439
	.funcs = NULL,
440
	.size = sizeof(OCSP_RESPONSE),
441
	.sname = "OCSP_RESPONSE",
442
};
443
444
445
OCSP_RESPONSE *
446
d2i_OCSP_RESPONSE(OCSP_RESPONSE **a, const unsigned char **in, long len)
447
2
{
448
2
	return (OCSP_RESPONSE *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
449
	    &OCSP_RESPONSE_it);
450
}
451
452
int
453
i2d_OCSP_RESPONSE(OCSP_RESPONSE *a, unsigned char **out)
454
{
455
	return ASN1_item_i2d((ASN1_VALUE *)a, out, &OCSP_RESPONSE_it);
456
}
457
458
OCSP_RESPONSE *
459
OCSP_RESPONSE_new(void)
460
{
461
	return (OCSP_RESPONSE *)ASN1_item_new(&OCSP_RESPONSE_it);
462
}
463
464
void
465
OCSP_RESPONSE_free(OCSP_RESPONSE *a)
466
{
467
	ASN1_item_free((ASN1_VALUE *)a, &OCSP_RESPONSE_it);
468
}
469
470
static const ASN1_TEMPLATE OCSP_RESPID_ch_tt[] = {
471
	{
472
		.flags = ASN1_TFLG_EXPLICIT,
473
		.tag = 1,
474
		.offset = offsetof(OCSP_RESPID, value.byName),
475
		.field_name = "value.byName",
476
		.item = &X509_NAME_it,
477
	},
478
	{
479
		.flags = ASN1_TFLG_EXPLICIT,
480
		.tag = 2,
481
		.offset = offsetof(OCSP_RESPID, value.byKey),
482
		.field_name = "value.byKey",
483
		.item = &ASN1_OCTET_STRING_it,
484
	},
485
};
486
487
const ASN1_ITEM OCSP_RESPID_it = {
488
	.itype = ASN1_ITYPE_CHOICE,
489
	.utype = offsetof(OCSP_RESPID, type),
490
	.templates = OCSP_RESPID_ch_tt,
491
	.tcount = sizeof(OCSP_RESPID_ch_tt) / sizeof(ASN1_TEMPLATE),
492
	.funcs = NULL,
493
	.size = sizeof(OCSP_RESPID),
494
	.sname = "OCSP_RESPID",
495
};
496
497
498
OCSP_RESPID *
499
d2i_OCSP_RESPID(OCSP_RESPID **a, const unsigned char **in, long len)
500
{
501
	return (OCSP_RESPID *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
502
	    &OCSP_RESPID_it);
503
}
504
505
int
506
i2d_OCSP_RESPID(OCSP_RESPID *a, unsigned char **out)
507
{
508
	return ASN1_item_i2d((ASN1_VALUE *)a, out, &OCSP_RESPID_it);
509
}
510
511
OCSP_RESPID *
512
OCSP_RESPID_new(void)
513
{
514
	return (OCSP_RESPID *)ASN1_item_new(&OCSP_RESPID_it);
515
}
516
517
void
518
OCSP_RESPID_free(OCSP_RESPID *a)
519
{
520
	ASN1_item_free((ASN1_VALUE *)a, &OCSP_RESPID_it);
521
}
522
523
static const ASN1_TEMPLATE OCSP_REVOKEDINFO_seq_tt[] = {
524
	{
525
		.flags = 0,
526
		.tag = 0,
527
		.offset = offsetof(OCSP_REVOKEDINFO, revocationTime),
528
		.field_name = "revocationTime",
529
		.item = &ASN1_GENERALIZEDTIME_it,
530
	},
531
	{
532
		.flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_OPTIONAL,
533
		.tag = 0,
534
		.offset = offsetof(OCSP_REVOKEDINFO, revocationReason),
535
		.field_name = "revocationReason",
536
		.item = &ASN1_ENUMERATED_it,
537
	},
538
};
539
540
const ASN1_ITEM OCSP_REVOKEDINFO_it = {
541
	.itype = ASN1_ITYPE_SEQUENCE,
542
	.utype = V_ASN1_SEQUENCE,
543
	.templates = OCSP_REVOKEDINFO_seq_tt,
544
	.tcount = sizeof(OCSP_REVOKEDINFO_seq_tt) / sizeof(ASN1_TEMPLATE),
545
	.funcs = NULL,
546
	.size = sizeof(OCSP_REVOKEDINFO),
547
	.sname = "OCSP_REVOKEDINFO",
548
};
549
550
551
OCSP_REVOKEDINFO *
552
d2i_OCSP_REVOKEDINFO(OCSP_REVOKEDINFO **a, const unsigned char **in, long len)
553
{
554
	return (OCSP_REVOKEDINFO *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
555
	    &OCSP_REVOKEDINFO_it);
556
}
557
558
int
559
i2d_OCSP_REVOKEDINFO(OCSP_REVOKEDINFO *a, unsigned char **out)
560
{
561
	return ASN1_item_i2d((ASN1_VALUE *)a, out, &OCSP_REVOKEDINFO_it);
562
}
563
564
OCSP_REVOKEDINFO *
565
OCSP_REVOKEDINFO_new(void)
566
{
567
	return (OCSP_REVOKEDINFO *)ASN1_item_new(&OCSP_REVOKEDINFO_it);
568
}
569
570
void
571
OCSP_REVOKEDINFO_free(OCSP_REVOKEDINFO *a)
572
{
573
	ASN1_item_free((ASN1_VALUE *)a, &OCSP_REVOKEDINFO_it);
574
}
575
576
static const ASN1_TEMPLATE OCSP_CERTSTATUS_ch_tt[] = {
577
	{
578
		.flags = ASN1_TFLG_IMPLICIT,
579
		.tag = 0,
580
		.offset = offsetof(OCSP_CERTSTATUS, value.good),
581
		.field_name = "value.good",
582
		.item = &ASN1_NULL_it,
583
	},
584
	{
585
		.flags = ASN1_TFLG_IMPLICIT,
586
		.tag = 1,
587
		.offset = offsetof(OCSP_CERTSTATUS, value.revoked),
588
		.field_name = "value.revoked",
589
		.item = &OCSP_REVOKEDINFO_it,
590
	},
591
	{
592
		.flags = ASN1_TFLG_IMPLICIT,
593
		.tag = 2,
594
		.offset = offsetof(OCSP_CERTSTATUS, value.unknown),
595
		.field_name = "value.unknown",
596
		.item = &ASN1_NULL_it,
597
	},
598
};
599
600
const ASN1_ITEM OCSP_CERTSTATUS_it = {
601
	.itype = ASN1_ITYPE_CHOICE,
602
	.utype = offsetof(OCSP_CERTSTATUS, type),
603
	.templates = OCSP_CERTSTATUS_ch_tt,
604
	.tcount = sizeof(OCSP_CERTSTATUS_ch_tt) / sizeof(ASN1_TEMPLATE),
605
	.funcs = NULL,
606
	.size = sizeof(OCSP_CERTSTATUS),
607
	.sname = "OCSP_CERTSTATUS",
608
};
609
610
611
OCSP_CERTSTATUS *
612
d2i_OCSP_CERTSTATUS(OCSP_CERTSTATUS **a, const unsigned char **in, long len)
613
{
614
	return (OCSP_CERTSTATUS *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
615
	    &OCSP_CERTSTATUS_it);
616
}
617
618
int
619
i2d_OCSP_CERTSTATUS(OCSP_CERTSTATUS *a, unsigned char **out)
620
{
621
	return ASN1_item_i2d((ASN1_VALUE *)a, out, &OCSP_CERTSTATUS_it);
622
}
623
624
OCSP_CERTSTATUS *
625
OCSP_CERTSTATUS_new(void)
626
{
627
	return (OCSP_CERTSTATUS *)ASN1_item_new(&OCSP_CERTSTATUS_it);
628
}
629
630
void
631
OCSP_CERTSTATUS_free(OCSP_CERTSTATUS *a)
632
{
633
	ASN1_item_free((ASN1_VALUE *)a, &OCSP_CERTSTATUS_it);
634
}
635
636
static const ASN1_TEMPLATE OCSP_SINGLERESP_seq_tt[] = {
637
	{
638
		.flags = 0,
639
		.tag = 0,
640
		.offset = offsetof(OCSP_SINGLERESP, certId),
641
		.field_name = "certId",
642
		.item = &OCSP_CERTID_it,
643
	},
644
	{
645
		.flags = 0,
646
		.tag = 0,
647
		.offset = offsetof(OCSP_SINGLERESP, certStatus),
648
		.field_name = "certStatus",
649
		.item = &OCSP_CERTSTATUS_it,
650
	},
651
	{
652
		.flags = 0,
653
		.tag = 0,
654
		.offset = offsetof(OCSP_SINGLERESP, thisUpdate),
655
		.field_name = "thisUpdate",
656
		.item = &ASN1_GENERALIZEDTIME_it,
657
	},
658
	{
659
		.flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_OPTIONAL,
660
		.tag = 0,
661
		.offset = offsetof(OCSP_SINGLERESP, nextUpdate),
662
		.field_name = "nextUpdate",
663
		.item = &ASN1_GENERALIZEDTIME_it,
664
	},
665
	{
666
		.flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_SEQUENCE_OF | ASN1_TFLG_OPTIONAL,
667
		.tag = 1,
668
		.offset = offsetof(OCSP_SINGLERESP, singleExtensions),
669
		.field_name = "singleExtensions",
670
		.item = &X509_EXTENSION_it,
671
	},
672
};
673
674
const ASN1_ITEM OCSP_SINGLERESP_it = {
675
	.itype = ASN1_ITYPE_SEQUENCE,
676
	.utype = V_ASN1_SEQUENCE,
677
	.templates = OCSP_SINGLERESP_seq_tt,
678
	.tcount = sizeof(OCSP_SINGLERESP_seq_tt) / sizeof(ASN1_TEMPLATE),
679
	.funcs = NULL,
680
	.size = sizeof(OCSP_SINGLERESP),
681
	.sname = "OCSP_SINGLERESP",
682
};
683
684
685
OCSP_SINGLERESP *
686
d2i_OCSP_SINGLERESP(OCSP_SINGLERESP **a, const unsigned char **in, long len)
687
{
688
	return (OCSP_SINGLERESP *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
689
	    &OCSP_SINGLERESP_it);
690
}
691
692
int
693
i2d_OCSP_SINGLERESP(OCSP_SINGLERESP *a, unsigned char **out)
694
{
695
	return ASN1_item_i2d((ASN1_VALUE *)a, out, &OCSP_SINGLERESP_it);
696
}
697
698
OCSP_SINGLERESP *
699
OCSP_SINGLERESP_new(void)
700
{
701
	return (OCSP_SINGLERESP *)ASN1_item_new(&OCSP_SINGLERESP_it);
702
}
703
704
void
705
OCSP_SINGLERESP_free(OCSP_SINGLERESP *a)
706
{
707
	ASN1_item_free((ASN1_VALUE *)a, &OCSP_SINGLERESP_it);
708
}
709
710
static const ASN1_TEMPLATE OCSP_RESPDATA_seq_tt[] = {
711
	{
712
		.flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_OPTIONAL,
713
		.tag = 0,
714
		.offset = offsetof(OCSP_RESPDATA, version),
715
		.field_name = "version",
716
		.item = &ASN1_INTEGER_it,
717
	},
718
	{
719
		.flags = 0,
720
		.tag = 0,
721
		.offset = offsetof(OCSP_RESPDATA, responderId),
722
		.field_name = "responderId",
723
		.item = &OCSP_RESPID_it,
724
	},
725
	{
726
		.flags = 0,
727
		.tag = 0,
728
		.offset = offsetof(OCSP_RESPDATA, producedAt),
729
		.field_name = "producedAt",
730
		.item = &ASN1_GENERALIZEDTIME_it,
731
	},
732
	{
733
		.flags = ASN1_TFLG_SEQUENCE_OF,
734
		.tag = 0,
735
		.offset = offsetof(OCSP_RESPDATA, responses),
736
		.field_name = "responses",
737
		.item = &OCSP_SINGLERESP_it,
738
	},
739
	{
740
		.flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_SEQUENCE_OF | ASN1_TFLG_OPTIONAL,
741
		.tag = 1,
742
		.offset = offsetof(OCSP_RESPDATA, responseExtensions),
743
		.field_name = "responseExtensions",
744
		.item = &X509_EXTENSION_it,
745
	},
746
};
747
748
const ASN1_ITEM OCSP_RESPDATA_it = {
749
	.itype = ASN1_ITYPE_SEQUENCE,
750
	.utype = V_ASN1_SEQUENCE,
751
	.templates = OCSP_RESPDATA_seq_tt,
752
	.tcount = sizeof(OCSP_RESPDATA_seq_tt) / sizeof(ASN1_TEMPLATE),
753
	.funcs = NULL,
754
	.size = sizeof(OCSP_RESPDATA),
755
	.sname = "OCSP_RESPDATA",
756
};
757
758
759
OCSP_RESPDATA *
760
d2i_OCSP_RESPDATA(OCSP_RESPDATA **a, const unsigned char **in, long len)
761
{
762
	return (OCSP_RESPDATA *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
763
	    &OCSP_RESPDATA_it);
764
}
765
766
int
767
i2d_OCSP_RESPDATA(OCSP_RESPDATA *a, unsigned char **out)
768
{
769
	return ASN1_item_i2d((ASN1_VALUE *)a, out, &OCSP_RESPDATA_it);
770
}
771
772
OCSP_RESPDATA *
773
OCSP_RESPDATA_new(void)
774
{
775
	return (OCSP_RESPDATA *)ASN1_item_new(&OCSP_RESPDATA_it);
776
}
777
778
void
779
OCSP_RESPDATA_free(OCSP_RESPDATA *a)
780
{
781
	ASN1_item_free((ASN1_VALUE *)a, &OCSP_RESPDATA_it);
782
}
783
784
static const ASN1_TEMPLATE OCSP_BASICRESP_seq_tt[] = {
785
	{
786
		.flags = 0,
787
		.tag = 0,
788
		.offset = offsetof(OCSP_BASICRESP, tbsResponseData),
789
		.field_name = "tbsResponseData",
790
		.item = &OCSP_RESPDATA_it,
791
	},
792
	{
793
		.flags = 0,
794
		.tag = 0,
795
		.offset = offsetof(OCSP_BASICRESP, signatureAlgorithm),
796
		.field_name = "signatureAlgorithm",
797
		.item = &X509_ALGOR_it,
798
	},
799
	{
800
		.flags = 0,
801
		.tag = 0,
802
		.offset = offsetof(OCSP_BASICRESP, signature),
803
		.field_name = "signature",
804
		.item = &ASN1_BIT_STRING_it,
805
	},
806
	{
807
		.flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_SEQUENCE_OF | ASN1_TFLG_OPTIONAL,
808
		.tag = 0,
809
		.offset = offsetof(OCSP_BASICRESP, certs),
810
		.field_name = "certs",
811
		.item = &X509_it,
812
	},
813
};
814
815
const ASN1_ITEM OCSP_BASICRESP_it = {
816
	.itype = ASN1_ITYPE_SEQUENCE,
817
	.utype = V_ASN1_SEQUENCE,
818
	.templates = OCSP_BASICRESP_seq_tt,
819
	.tcount = sizeof(OCSP_BASICRESP_seq_tt) / sizeof(ASN1_TEMPLATE),
820
	.funcs = NULL,
821
	.size = sizeof(OCSP_BASICRESP),
822
	.sname = "OCSP_BASICRESP",
823
};
824
825
826
OCSP_BASICRESP *
827
d2i_OCSP_BASICRESP(OCSP_BASICRESP **a, const unsigned char **in, long len)
828
{
829
	return (OCSP_BASICRESP *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
830
	    &OCSP_BASICRESP_it);
831
}
832
833
int
834
i2d_OCSP_BASICRESP(OCSP_BASICRESP *a, unsigned char **out)
835
{
836
	return ASN1_item_i2d((ASN1_VALUE *)a, out, &OCSP_BASICRESP_it);
837
}
838
839
OCSP_BASICRESP *
840
OCSP_BASICRESP_new(void)
841
{
842
	return (OCSP_BASICRESP *)ASN1_item_new(&OCSP_BASICRESP_it);
843
}
844
845
void
846
OCSP_BASICRESP_free(OCSP_BASICRESP *a)
847
{
848
	ASN1_item_free((ASN1_VALUE *)a, &OCSP_BASICRESP_it);
849
}
850
851
static const ASN1_TEMPLATE OCSP_CRLID_seq_tt[] = {
852
	{
853
		.flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_OPTIONAL,
854
		.tag = 0,
855
		.offset = offsetof(OCSP_CRLID, crlUrl),
856
		.field_name = "crlUrl",
857
		.item = &ASN1_IA5STRING_it,
858
	},
859
	{
860
		.flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_OPTIONAL,
861
		.tag = 1,
862
		.offset = offsetof(OCSP_CRLID, crlNum),
863
		.field_name = "crlNum",
864
		.item = &ASN1_INTEGER_it,
865
	},
866
	{
867
		.flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_OPTIONAL,
868
		.tag = 2,
869
		.offset = offsetof(OCSP_CRLID, crlTime),
870
		.field_name = "crlTime",
871
		.item = &ASN1_GENERALIZEDTIME_it,
872
	},
873
};
874
875
const ASN1_ITEM OCSP_CRLID_it = {
876
	.itype = ASN1_ITYPE_SEQUENCE,
877
	.utype = V_ASN1_SEQUENCE,
878
	.templates = OCSP_CRLID_seq_tt,
879
	.tcount = sizeof(OCSP_CRLID_seq_tt) / sizeof(ASN1_TEMPLATE),
880
	.funcs = NULL,
881
	.size = sizeof(OCSP_CRLID),
882
	.sname = "OCSP_CRLID",
883
};
884
885
886
OCSP_CRLID *
887
d2i_OCSP_CRLID(OCSP_CRLID **a, const unsigned char **in, long len)
888
{
889
	return (OCSP_CRLID *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
890
	    &OCSP_CRLID_it);
891
}
892
893
int
894
i2d_OCSP_CRLID(OCSP_CRLID *a, unsigned char **out)
895
{
896
	return ASN1_item_i2d((ASN1_VALUE *)a, out, &OCSP_CRLID_it);
897
}
898
899
OCSP_CRLID *
900
OCSP_CRLID_new(void)
901
{
902
	return (OCSP_CRLID *)ASN1_item_new(&OCSP_CRLID_it);
903
}
904
905
void
906
OCSP_CRLID_free(OCSP_CRLID *a)
907
{
908
	ASN1_item_free((ASN1_VALUE *)a, &OCSP_CRLID_it);
909
}
910
911
static const ASN1_TEMPLATE OCSP_SERVICELOC_seq_tt[] = {
912
	{
913
		.flags = 0,
914
		.tag = 0,
915
		.offset = offsetof(OCSP_SERVICELOC, issuer),
916
		.field_name = "issuer",
917
		.item = &X509_NAME_it,
918
	},
919
	{
920
		.flags = ASN1_TFLG_SEQUENCE_OF | ASN1_TFLG_OPTIONAL,
921
		.tag = 0,
922
		.offset = offsetof(OCSP_SERVICELOC, locator),
923
		.field_name = "locator",
924
		.item = &ACCESS_DESCRIPTION_it,
925
	},
926
};
927
928
const ASN1_ITEM OCSP_SERVICELOC_it = {
929
	.itype = ASN1_ITYPE_SEQUENCE,
930
	.utype = V_ASN1_SEQUENCE,
931
	.templates = OCSP_SERVICELOC_seq_tt,
932
	.tcount = sizeof(OCSP_SERVICELOC_seq_tt) / sizeof(ASN1_TEMPLATE),
933
	.funcs = NULL,
934
	.size = sizeof(OCSP_SERVICELOC),
935
	.sname = "OCSP_SERVICELOC",
936
};
937
938
939
OCSP_SERVICELOC *
940
d2i_OCSP_SERVICELOC(OCSP_SERVICELOC **a, const unsigned char **in, long len)
941
{
942
	return (OCSP_SERVICELOC *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
943
	    &OCSP_SERVICELOC_it);
944
}
945
946
int
947
i2d_OCSP_SERVICELOC(OCSP_SERVICELOC *a, unsigned char **out)
948
{
949
	return ASN1_item_i2d((ASN1_VALUE *)a, out, &OCSP_SERVICELOC_it);
950
}
951
952
OCSP_SERVICELOC *
953
OCSP_SERVICELOC_new(void)
954
{
955
	return (OCSP_SERVICELOC *)ASN1_item_new(&OCSP_SERVICELOC_it);
956
}
957
958
void
959
OCSP_SERVICELOC_free(OCSP_SERVICELOC *a)
960
{
961
	ASN1_item_free((ASN1_VALUE *)a, &OCSP_SERVICELOC_it);
962
}