/src/openssl111/crypto/asn1/tasn_prn.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved. |
3 | | * |
4 | | * Licensed under the OpenSSL license (the "License"). You may not use |
5 | | * this file except in compliance with the License. You can obtain a copy |
6 | | * in the file LICENSE in the source distribution or at |
7 | | * https://www.openssl.org/source/license.html |
8 | | */ |
9 | | |
10 | | #include <stddef.h> |
11 | | #include "internal/cryptlib.h" |
12 | | #include <openssl/asn1.h> |
13 | | #include <openssl/asn1t.h> |
14 | | #include <openssl/objects.h> |
15 | | #include <openssl/buffer.h> |
16 | | #include <openssl/err.h> |
17 | | #include <openssl/x509v3.h> |
18 | | #include "crypto/asn1.h" |
19 | | #include "asn1_local.h" |
20 | | |
21 | | /* |
22 | | * Print routines. |
23 | | */ |
24 | | |
25 | | /* ASN1_PCTX routines */ |
26 | | |
27 | | static ASN1_PCTX default_pctx = { |
28 | | ASN1_PCTX_FLAGS_SHOW_ABSENT, /* flags */ |
29 | | 0, /* nm_flags */ |
30 | | 0, /* cert_flags */ |
31 | | 0, /* oid_flags */ |
32 | | 0 /* str_flags */ |
33 | | }; |
34 | | |
35 | | ASN1_PCTX *ASN1_PCTX_new(void) |
36 | 8 | { |
37 | 8 | ASN1_PCTX *ret; |
38 | | |
39 | 8 | ret = OPENSSL_zalloc(sizeof(*ret)); |
40 | 8 | if (ret == NULL) { |
41 | 0 | ASN1err(ASN1_F_ASN1_PCTX_NEW, ERR_R_MALLOC_FAILURE); |
42 | 0 | return NULL; |
43 | 0 | } |
44 | 8 | return ret; |
45 | 8 | } |
46 | | |
47 | | void ASN1_PCTX_free(ASN1_PCTX *p) |
48 | 0 | { |
49 | 0 | OPENSSL_free(p); |
50 | 0 | } |
51 | | |
52 | | unsigned long ASN1_PCTX_get_flags(const ASN1_PCTX *p) |
53 | 0 | { |
54 | 0 | return p->flags; |
55 | 0 | } |
56 | | |
57 | | void ASN1_PCTX_set_flags(ASN1_PCTX *p, unsigned long flags) |
58 | 8 | { |
59 | 8 | p->flags = flags; |
60 | 8 | } |
61 | | |
62 | | unsigned long ASN1_PCTX_get_nm_flags(const ASN1_PCTX *p) |
63 | 0 | { |
64 | 0 | return p->nm_flags; |
65 | 0 | } |
66 | | |
67 | | void ASN1_PCTX_set_nm_flags(ASN1_PCTX *p, unsigned long flags) |
68 | 0 | { |
69 | 0 | p->nm_flags = flags; |
70 | 0 | } |
71 | | |
72 | | unsigned long ASN1_PCTX_get_cert_flags(const ASN1_PCTX *p) |
73 | 0 | { |
74 | 0 | return p->cert_flags; |
75 | 0 | } |
76 | | |
77 | | void ASN1_PCTX_set_cert_flags(ASN1_PCTX *p, unsigned long flags) |
78 | 0 | { |
79 | 0 | p->cert_flags = flags; |
80 | 0 | } |
81 | | |
82 | | unsigned long ASN1_PCTX_get_oid_flags(const ASN1_PCTX *p) |
83 | 0 | { |
84 | 0 | return p->oid_flags; |
85 | 0 | } |
86 | | |
87 | | void ASN1_PCTX_set_oid_flags(ASN1_PCTX *p, unsigned long flags) |
88 | 0 | { |
89 | 0 | p->oid_flags = flags; |
90 | 0 | } |
91 | | |
92 | | unsigned long ASN1_PCTX_get_str_flags(const ASN1_PCTX *p) |
93 | 0 | { |
94 | 0 | return p->str_flags; |
95 | 0 | } |
96 | | |
97 | | void ASN1_PCTX_set_str_flags(ASN1_PCTX *p, unsigned long flags) |
98 | 8 | { |
99 | 8 | p->str_flags = flags; |
100 | 8 | } |
101 | | |
102 | | /* Main print routines */ |
103 | | |
104 | | static int asn1_item_print_ctx(BIO *out, ASN1_VALUE **fld, int indent, |
105 | | const ASN1_ITEM *it, |
106 | | const char *fname, const char *sname, |
107 | | int nohdr, const ASN1_PCTX *pctx); |
108 | | |
109 | | static int asn1_template_print_ctx(BIO *out, ASN1_VALUE **fld, int indent, |
110 | | const ASN1_TEMPLATE *tt, const ASN1_PCTX *pctx); |
111 | | |
112 | | static int asn1_primitive_print(BIO *out, ASN1_VALUE **fld, |
113 | | const ASN1_ITEM *it, int indent, |
114 | | const char *fname, const char *sname, |
115 | | const ASN1_PCTX *pctx); |
116 | | |
117 | | static int asn1_print_fsname(BIO *out, int indent, |
118 | | const char *fname, const char *sname, |
119 | | const ASN1_PCTX *pctx); |
120 | | |
121 | | int ASN1_item_print(BIO *out, ASN1_VALUE *ifld, int indent, |
122 | | const ASN1_ITEM *it, const ASN1_PCTX *pctx) |
123 | 179k | { |
124 | 179k | const char *sname; |
125 | 179k | if (pctx == NULL) |
126 | 11.6k | pctx = &default_pctx; |
127 | 179k | if (pctx->flags & ASN1_PCTX_FLAGS_NO_STRUCT_NAME) |
128 | 0 | sname = NULL; |
129 | 179k | else |
130 | 179k | sname = it->sname; |
131 | 179k | return asn1_item_print_ctx(out, &ifld, indent, it, NULL, sname, 0, pctx); |
132 | 179k | } |
133 | | |
134 | | static int asn1_item_print_ctx(BIO *out, ASN1_VALUE **fld, int indent, |
135 | | const ASN1_ITEM *it, |
136 | | const char *fname, const char *sname, |
137 | | int nohdr, const ASN1_PCTX *pctx) |
138 | 1.31M | { |
139 | 1.31M | const ASN1_TEMPLATE *tt; |
140 | 1.31M | const ASN1_EXTERN_FUNCS *ef; |
141 | 1.31M | ASN1_VALUE **tmpfld; |
142 | 1.31M | const ASN1_AUX *aux = it->funcs; |
143 | 1.31M | ASN1_aux_cb *asn1_cb; |
144 | 1.31M | ASN1_PRINT_ARG parg; |
145 | 1.31M | int i; |
146 | 1.31M | if (aux && aux->asn1_cb) { |
147 | 46.8k | parg.out = out; |
148 | 46.8k | parg.indent = indent; |
149 | 46.8k | parg.pctx = pctx; |
150 | 46.8k | asn1_cb = aux->asn1_cb; |
151 | 46.8k | } else |
152 | 1.26M | asn1_cb = 0; |
153 | | |
154 | 1.31M | if (((it->itype != ASN1_ITYPE_PRIMITIVE) |
155 | 1.31M | || (it->utype != V_ASN1_BOOLEAN)) && *fld == NULL) { |
156 | 9.18k | if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_ABSENT) { |
157 | 9.18k | if (!nohdr && !asn1_print_fsname(out, indent, fname, sname, pctx)) |
158 | 0 | return 0; |
159 | 9.18k | if (BIO_puts(out, "<ABSENT>\n") <= 0) |
160 | 0 | return 0; |
161 | 9.18k | } |
162 | 9.18k | return 1; |
163 | 9.18k | } |
164 | | |
165 | 1.30M | switch (it->itype) { |
166 | 1.16M | case ASN1_ITYPE_PRIMITIVE: |
167 | 1.16M | if (it->templates) { |
168 | 8.47k | if (!asn1_template_print_ctx(out, fld, indent, |
169 | 8.47k | it->templates, pctx)) |
170 | 548 | return 0; |
171 | 7.92k | break; |
172 | 8.47k | } |
173 | | /* fall through */ |
174 | 1.16M | case ASN1_ITYPE_MSTRING: |
175 | 1.16M | if (!asn1_primitive_print(out, fld, it, indent, fname, sname, pctx)) |
176 | 3.52k | return 0; |
177 | 1.16M | break; |
178 | | |
179 | 1.16M | case ASN1_ITYPE_EXTERN: |
180 | 2.06k | if (!nohdr && !asn1_print_fsname(out, indent, fname, sname, pctx)) |
181 | 0 | return 0; |
182 | | /* Use new style print routine if possible */ |
183 | 2.06k | ef = it->funcs; |
184 | 2.06k | if (ef && ef->asn1_ex_print) { |
185 | 2.06k | i = ef->asn1_ex_print(out, fld, indent, "", pctx); |
186 | 2.06k | if (!i) |
187 | 52 | return 0; |
188 | 2.01k | if ((i == 2) && (BIO_puts(out, "\n") <= 0)) |
189 | 0 | return 0; |
190 | 2.01k | return 1; |
191 | 2.01k | } else if (sname && |
192 | 0 | BIO_printf(out, ":EXTERNAL TYPE %s\n", sname) <= 0) |
193 | 0 | return 0; |
194 | 0 | break; |
195 | | |
196 | 87.0k | case ASN1_ITYPE_CHOICE: |
197 | | /* CHOICE type, get selector */ |
198 | 87.0k | i = asn1_get_choice_selector(fld, it); |
199 | | /* This should never happen... */ |
200 | 87.0k | if ((i < 0) || (i >= it->tcount)) { |
201 | 0 | if (BIO_printf(out, "ERROR: selector [%d] invalid\n", i) <= 0) |
202 | 0 | return 0; |
203 | 0 | return 1; |
204 | 0 | } |
205 | 87.0k | tt = it->templates + i; |
206 | 87.0k | tmpfld = asn1_get_field_ptr(fld, tt); |
207 | 87.0k | if (!asn1_template_print_ctx(out, tmpfld, indent, tt, pctx)) |
208 | 123 | return 0; |
209 | 86.8k | break; |
210 | | |
211 | 86.8k | case ASN1_ITYPE_SEQUENCE: |
212 | 34.3k | case ASN1_ITYPE_NDEF_SEQUENCE: |
213 | 34.3k | if (!nohdr && !asn1_print_fsname(out, indent, fname, sname, pctx)) |
214 | 0 | return 0; |
215 | 34.3k | if (fname || sname) { |
216 | 14.9k | if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_SEQUENCE) { |
217 | 14.9k | if (BIO_puts(out, " {\n") <= 0) |
218 | 0 | return 0; |
219 | 14.9k | } else { |
220 | 0 | if (BIO_puts(out, "\n") <= 0) |
221 | 0 | return 0; |
222 | 0 | } |
223 | 14.9k | } |
224 | | |
225 | 34.3k | if (asn1_cb) { |
226 | 4.68k | i = asn1_cb(ASN1_OP_PRINT_PRE, fld, it, &parg); |
227 | 4.68k | if (i == 0) |
228 | 0 | return 0; |
229 | 4.68k | if (i == 2) |
230 | 0 | return 1; |
231 | 4.68k | } |
232 | | |
233 | | /* Print each field entry */ |
234 | 132k | for (i = 0, tt = it->templates; i < it->tcount; i++, tt++) { |
235 | 99.6k | const ASN1_TEMPLATE *seqtt; |
236 | 99.6k | seqtt = asn1_do_adb(fld, tt, 1); |
237 | 99.6k | if (!seqtt) |
238 | 0 | return 0; |
239 | 99.6k | tmpfld = asn1_get_field_ptr(fld, seqtt); |
240 | 99.6k | if (!asn1_template_print_ctx(out, tmpfld, |
241 | 99.6k | indent + 2, seqtt, pctx)) |
242 | 1.56k | return 0; |
243 | 99.6k | } |
244 | 32.8k | if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_SEQUENCE) { |
245 | 32.8k | if (BIO_printf(out, "%*s}\n", indent, "") < 0) |
246 | 0 | return 0; |
247 | 32.8k | } |
248 | | |
249 | 32.8k | if (asn1_cb) { |
250 | 4.09k | i = asn1_cb(ASN1_OP_PRINT_POST, fld, it, &parg); |
251 | 4.09k | if (i == 0) |
252 | 0 | return 0; |
253 | 4.09k | } |
254 | 32.8k | break; |
255 | | |
256 | 32.8k | default: |
257 | 0 | BIO_printf(out, "Unprocessed type %d\n", it->itype); |
258 | 0 | return 0; |
259 | 1.30M | } |
260 | | |
261 | 1.29M | return 1; |
262 | 1.30M | } |
263 | | |
264 | | static int asn1_template_print_ctx(BIO *out, ASN1_VALUE **fld, int indent, |
265 | | const ASN1_TEMPLATE *tt, const ASN1_PCTX *pctx) |
266 | 1.50M | { |
267 | 1.50M | int i, flags; |
268 | 1.50M | const char *sname, *fname; |
269 | 1.50M | ASN1_VALUE *tfld; |
270 | 1.50M | flags = tt->flags; |
271 | 1.50M | if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_FIELD_STRUCT_NAME) |
272 | 470k | sname = ASN1_ITEM_ptr(tt->item)->sname; |
273 | 1.03M | else |
274 | 1.03M | sname = NULL; |
275 | 1.50M | if (pctx->flags & ASN1_PCTX_FLAGS_NO_FIELD_NAME) |
276 | 0 | fname = NULL; |
277 | 1.50M | else |
278 | 1.50M | fname = tt->field_name; |
279 | | |
280 | | /* |
281 | | * If field is embedded then fld needs fixing so it is a pointer to |
282 | | * a pointer to a field. |
283 | | */ |
284 | 1.50M | if (flags & ASN1_TFLG_EMBED) { |
285 | 28.4k | tfld = (ASN1_VALUE *)fld; |
286 | 28.4k | fld = &tfld; |
287 | 28.4k | } |
288 | | |
289 | 1.50M | if (flags & ASN1_TFLG_SK_MASK) { |
290 | 168k | char *tname; |
291 | 168k | ASN1_VALUE *skitem; |
292 | 168k | STACK_OF(ASN1_VALUE) *stack; |
293 | | |
294 | | /* SET OF, SEQUENCE OF */ |
295 | 168k | if (fname) { |
296 | 168k | if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_SSOF) { |
297 | 61.2k | if (flags & ASN1_TFLG_SET_OF) |
298 | 10.4k | tname = "SET"; |
299 | 50.8k | else |
300 | 50.8k | tname = "SEQUENCE"; |
301 | 61.2k | if (BIO_printf(out, "%*s%s OF %s {\n", |
302 | 61.2k | indent, "", tname, tt->field_name) <= 0) |
303 | 0 | return 0; |
304 | 106k | } else if (BIO_printf(out, "%*s%s:\n", indent, "", fname) <= 0) |
305 | 0 | return 0; |
306 | 168k | } |
307 | 168k | stack = (STACK_OF(ASN1_VALUE) *)*fld; |
308 | 3.87M | for (i = 0; i < sk_ASN1_VALUE_num(stack); i++) { |
309 | 3.70M | if ((i > 0) && (BIO_puts(out, "\n") <= 0)) |
310 | 0 | return 0; |
311 | | |
312 | 3.70M | skitem = sk_ASN1_VALUE_value(stack, i); |
313 | 3.70M | if (!asn1_item_print_ctx(out, &skitem, indent + 2, |
314 | 3.70M | ASN1_ITEM_ptr(tt->item), NULL, NULL, 1, |
315 | 3.70M | pctx)) |
316 | 3.61k | return 0; |
317 | 3.70M | } |
318 | 164k | if (i == 0 && BIO_printf(out, "%*s<%s>\n", indent + 2, "", |
319 | 131k | stack == NULL ? "ABSENT" : "EMPTY") <= 0) |
320 | 0 | return 0; |
321 | 164k | if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_SEQUENCE) { |
322 | 58.8k | if (BIO_printf(out, "%*s}\n", indent, "") <= 0) |
323 | 0 | return 0; |
324 | 58.8k | } |
325 | 164k | return 1; |
326 | 164k | } |
327 | 1.33M | return asn1_item_print_ctx(out, fld, indent, ASN1_ITEM_ptr(tt->item), |
328 | 1.33M | fname, sname, 0, pctx); |
329 | 1.50M | } |
330 | | |
331 | | static int asn1_print_fsname(BIO *out, int indent, |
332 | | const char *fname, const char *sname, |
333 | | const ASN1_PCTX *pctx) |
334 | 4.88M | { |
335 | 4.88M | static const char spaces[] = " "; |
336 | 4.88M | static const int nspaces = sizeof(spaces) - 1; |
337 | | |
338 | 4.92M | while (indent > nspaces) { |
339 | 41.7k | if (BIO_write(out, spaces, nspaces) != nspaces) |
340 | 0 | return 0; |
341 | 41.7k | indent -= nspaces; |
342 | 41.7k | } |
343 | 4.88M | if (BIO_write(out, spaces, indent) != indent) |
344 | 0 | return 0; |
345 | 4.88M | if (pctx->flags & ASN1_PCTX_FLAGS_NO_STRUCT_NAME) |
346 | 0 | sname = NULL; |
347 | 4.88M | if (pctx->flags & ASN1_PCTX_FLAGS_NO_FIELD_NAME) |
348 | 0 | fname = NULL; |
349 | 4.88M | if (!sname && !fname) |
350 | 3.47M | return 1; |
351 | 1.41M | if (fname) { |
352 | 1.26M | if (BIO_puts(out, fname) <= 0) |
353 | 0 | return 0; |
354 | 1.26M | } |
355 | 1.41M | if (sname) { |
356 | 555k | if (fname) { |
357 | 403k | if (BIO_printf(out, " (%s)", sname) <= 0) |
358 | 0 | return 0; |
359 | 403k | } else { |
360 | 152k | if (BIO_puts(out, sname) <= 0) |
361 | 0 | return 0; |
362 | 152k | } |
363 | 555k | } |
364 | 1.41M | if (BIO_write(out, ": ", 2) != 2) |
365 | 0 | return 0; |
366 | 1.41M | return 1; |
367 | 1.41M | } |
368 | | |
369 | | static int asn1_print_boolean(BIO *out, int boolval) |
370 | 13.8k | { |
371 | 13.8k | const char *str; |
372 | 13.8k | switch (boolval) { |
373 | 5.47k | case -1: |
374 | 5.47k | str = "BOOL ABSENT"; |
375 | 5.47k | break; |
376 | | |
377 | 3.56k | case 0: |
378 | 3.56k | str = "FALSE"; |
379 | 3.56k | break; |
380 | | |
381 | 4.76k | default: |
382 | 4.76k | str = "TRUE"; |
383 | 4.76k | break; |
384 | | |
385 | 13.8k | } |
386 | | |
387 | 13.8k | if (BIO_puts(out, str) <= 0) |
388 | 0 | return 0; |
389 | 13.8k | return 1; |
390 | | |
391 | 13.8k | } |
392 | | |
393 | | static int asn1_print_integer(BIO *out, const ASN1_INTEGER *str) |
394 | 1.80M | { |
395 | 1.80M | char *s; |
396 | 1.80M | int ret = 1; |
397 | 1.80M | s = i2s_ASN1_INTEGER(NULL, str); |
398 | 1.80M | if (s == NULL) |
399 | 256 | return 0; |
400 | 1.80M | if (BIO_puts(out, s) <= 0) |
401 | 0 | ret = 0; |
402 | 1.80M | OPENSSL_free(s); |
403 | 1.80M | return ret; |
404 | 1.80M | } |
405 | | |
406 | | static int asn1_print_oid(BIO *out, const ASN1_OBJECT *oid) |
407 | 124k | { |
408 | 124k | char objbuf[80]; |
409 | 124k | const char *ln; |
410 | 124k | ln = OBJ_nid2ln(OBJ_obj2nid(oid)); |
411 | 124k | if (!ln) |
412 | 0 | ln = ""; |
413 | 124k | OBJ_obj2txt(objbuf, sizeof(objbuf), oid, 1); |
414 | 124k | if (BIO_printf(out, "%s (%s)", ln, objbuf) <= 0) |
415 | 0 | return 0; |
416 | 124k | return 1; |
417 | 124k | } |
418 | | |
419 | | static int asn1_print_obstring(BIO *out, const ASN1_STRING *str, int indent) |
420 | 95.9k | { |
421 | 95.9k | if (str->type == V_ASN1_BIT_STRING) { |
422 | 47.7k | if (BIO_printf(out, " (%ld unused bits)\n", str->flags & 0x7) <= 0) |
423 | 0 | return 0; |
424 | 48.1k | } else if (BIO_puts(out, "\n") <= 0) |
425 | 0 | return 0; |
426 | 95.9k | if ((str->length > 0) |
427 | 95.9k | && BIO_dump_indent(out, (const char *)str->data, str->length, |
428 | 48.6k | indent + 2) <= 0) |
429 | 0 | return 0; |
430 | 95.9k | return 1; |
431 | 95.9k | } |
432 | | |
433 | | static int asn1_primitive_print(BIO *out, ASN1_VALUE **fld, |
434 | | const ASN1_ITEM *it, int indent, |
435 | | const char *fname, const char *sname, |
436 | | const ASN1_PCTX *pctx) |
437 | 4.07M | { |
438 | 4.07M | long utype; |
439 | 4.07M | ASN1_STRING *str; |
440 | 4.07M | int ret = 1, needlf = 1; |
441 | 4.07M | const char *pname; |
442 | 4.07M | const ASN1_PRIMITIVE_FUNCS *pf; |
443 | 4.07M | pf = it->funcs; |
444 | 4.07M | if (!asn1_print_fsname(out, indent, fname, sname, pctx)) |
445 | 0 | return 0; |
446 | 4.07M | if (pf && pf->prim_print) |
447 | 135k | return pf->prim_print(out, fld, it, indent, pctx); |
448 | 3.93M | if (it->itype == ASN1_ITYPE_MSTRING) { |
449 | 28.1k | str = (ASN1_STRING *)*fld; |
450 | 28.1k | utype = str->type & ~V_ASN1_NEG; |
451 | 3.90M | } else { |
452 | 3.90M | utype = it->utype; |
453 | 3.90M | if (utype == V_ASN1_BOOLEAN) |
454 | 11.8k | str = NULL; |
455 | 3.89M | else |
456 | 3.89M | str = (ASN1_STRING *)*fld; |
457 | 3.90M | } |
458 | 3.93M | if (utype == V_ASN1_ANY) { |
459 | 1.82M | ASN1_TYPE *atype = (ASN1_TYPE *)*fld; |
460 | 1.82M | utype = atype->type; |
461 | 1.82M | fld = &atype->value.asn1_value; |
462 | 1.82M | str = (ASN1_STRING *)*fld; |
463 | 1.82M | if (pctx->flags & ASN1_PCTX_FLAGS_NO_ANY_TYPE) |
464 | 0 | pname = NULL; |
465 | 1.82M | else |
466 | 1.82M | pname = ASN1_tag2str(utype); |
467 | 2.11M | } else { |
468 | 2.11M | if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_TYPE) |
469 | 240k | pname = ASN1_tag2str(utype); |
470 | 1.87M | else |
471 | 1.87M | pname = NULL; |
472 | 2.11M | } |
473 | | |
474 | 3.93M | if (utype == V_ASN1_NULL) { |
475 | 1.04M | if (BIO_puts(out, "NULL\n") <= 0) |
476 | 0 | return 0; |
477 | 1.04M | return 1; |
478 | 1.04M | } |
479 | | |
480 | 2.89M | if (pname) { |
481 | 1.01M | if (BIO_puts(out, pname) <= 0) |
482 | 0 | return 0; |
483 | 1.01M | if (BIO_puts(out, ":") <= 0) |
484 | 0 | return 0; |
485 | 1.01M | } |
486 | | |
487 | 2.89M | switch (utype) { |
488 | 13.8k | case V_ASN1_BOOLEAN: |
489 | 13.8k | { |
490 | 13.8k | int boolval = *(int *)fld; |
491 | 13.8k | if (boolval == -1) |
492 | 5.47k | boolval = it->size; |
493 | 13.8k | ret = asn1_print_boolean(out, boolval); |
494 | 13.8k | } |
495 | 13.8k | break; |
496 | | |
497 | 1.80M | case V_ASN1_INTEGER: |
498 | 1.80M | case V_ASN1_ENUMERATED: |
499 | 1.80M | ret = asn1_print_integer(out, str); |
500 | 1.80M | break; |
501 | | |
502 | 7.32k | case V_ASN1_UTCTIME: |
503 | 7.32k | ret = ASN1_UTCTIME_print(out, str); |
504 | 7.32k | break; |
505 | | |
506 | 6.68k | case V_ASN1_GENERALIZEDTIME: |
507 | 6.68k | ret = ASN1_GENERALIZEDTIME_print(out, str); |
508 | 6.68k | break; |
509 | | |
510 | 124k | case V_ASN1_OBJECT: |
511 | 124k | ret = asn1_print_oid(out, (const ASN1_OBJECT *)*fld); |
512 | 124k | break; |
513 | | |
514 | 48.1k | case V_ASN1_OCTET_STRING: |
515 | 95.9k | case V_ASN1_BIT_STRING: |
516 | 95.9k | ret = asn1_print_obstring(out, str, indent); |
517 | 95.9k | needlf = 0; |
518 | 95.9k | break; |
519 | | |
520 | 216k | case V_ASN1_SEQUENCE: |
521 | 500k | case V_ASN1_SET: |
522 | 728k | case V_ASN1_OTHER: |
523 | 728k | if (BIO_puts(out, "\n") <= 0) |
524 | 0 | return 0; |
525 | 728k | if (ASN1_parse_dump(out, str->data, str->length, indent, 0) <= 0) |
526 | 8.77k | ret = 0; |
527 | 728k | needlf = 0; |
528 | 728k | break; |
529 | | |
530 | 119k | default: |
531 | 119k | ret = ASN1_STRING_print_ex(out, str, pctx->str_flags); |
532 | | |
533 | 2.89M | } |
534 | 2.89M | if (!ret) |
535 | 16.2k | return 0; |
536 | 2.87M | if (needlf && BIO_puts(out, "\n") <= 0) |
537 | 0 | return 0; |
538 | 2.87M | return 1; |
539 | 2.87M | } |