summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1/tasn_prn.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/asn1/tasn_prn.c')
-rw-r--r--src/lib/libcrypto/asn1/tasn_prn.c625
1 files changed, 527 insertions, 98 deletions
diff --git a/src/lib/libcrypto/asn1/tasn_prn.c b/src/lib/libcrypto/asn1/tasn_prn.c
index b9c96a6dbe..453698012d 100644
--- a/src/lib/libcrypto/asn1/tasn_prn.c
+++ b/src/lib/libcrypto/asn1/tasn_prn.c
@@ -3,7 +3,7 @@
3 * project 2000. 3 * project 2000.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
6 * Copyright (c) 2000 The OpenSSL Project. All rights reserved. 6 * Copyright (c) 2000,2005 The OpenSSL Project. All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
@@ -58,141 +58,570 @@
58 58
59 59
60#include <stddef.h> 60#include <stddef.h>
61#include "cryptlib.h"
61#include <openssl/asn1.h> 62#include <openssl/asn1.h>
63#include <openssl/asn1t.h>
62#include <openssl/objects.h> 64#include <openssl/objects.h>
63#include <openssl/buffer.h> 65#include <openssl/buffer.h>
64#include <openssl/err.h> 66#include <openssl/err.h>
65#include <openssl/nasn.h> 67#include <openssl/x509v3.h>
68#include "asn1_locl.h"
66 69
67/* Print routines. Print out a whole structure from a template. 70/* Print routines.
68 */ 71 */
69 72
70static int asn1_item_print_nm(BIO *out, void *fld, int indent, const ASN1_ITEM *it, const char *name); 73/* ASN1_PCTX routines */
71 74
72int ASN1_item_print(BIO *out, void *fld, int indent, const ASN1_ITEM *it) 75ASN1_PCTX default_pctx =
73{ 76 {
74 return asn1_item_print_nm(out, fld, indent, it, it->sname); 77 ASN1_PCTX_FLAGS_SHOW_ABSENT, /* flags */
75} 78 0, /* nm_flags */
79 0, /* cert_flags */
80 0, /* oid_flags */
81 0 /* str_flags */
82 };
83
76 84
77static int asn1_item_print_nm(BIO *out, void *fld, int indent, const ASN1_ITEM *it, const char *name) 85ASN1_PCTX *ASN1_PCTX_new(void)
78{ 86 {
79 ASN1_STRING *str; 87 ASN1_PCTX *ret;
88 ret = OPENSSL_malloc(sizeof(ASN1_PCTX));
89 if (ret == NULL)
90 {
91 ASN1err(ASN1_F_ASN1_PCTX_NEW, ERR_R_MALLOC_FAILURE);
92 return NULL;
93 }
94 ret->flags = 0;
95 ret->nm_flags = 0;
96 ret->cert_flags = 0;
97 ret->oid_flags = 0;
98 ret->str_flags = 0;
99 return ret;
100 }
101
102void ASN1_PCTX_free(ASN1_PCTX *p)
103 {
104 OPENSSL_free(p);
105 }
106
107unsigned long ASN1_PCTX_get_flags(ASN1_PCTX *p)
108 {
109 return p->flags;
110 }
111
112void ASN1_PCTX_set_flags(ASN1_PCTX *p, unsigned long flags)
113 {
114 p->flags = flags;
115 }
116
117unsigned long ASN1_PCTX_get_nm_flags(ASN1_PCTX *p)
118 {
119 return p->nm_flags;
120 }
121
122void ASN1_PCTX_set_nm_flags(ASN1_PCTX *p, unsigned long flags)
123 {
124 p->nm_flags = flags;
125 }
126
127unsigned long ASN1_PCTX_get_cert_flags(ASN1_PCTX *p)
128 {
129 return p->cert_flags;
130 }
131
132void ASN1_PCTX_set_cert_flags(ASN1_PCTX *p, unsigned long flags)
133 {
134 p->cert_flags = flags;
135 }
136
137unsigned long ASN1_PCTX_get_oid_flags(ASN1_PCTX *p)
138 {
139 return p->oid_flags;
140 }
141
142void ASN1_PCTX_set_oid_flags(ASN1_PCTX *p, unsigned long flags)
143 {
144 p->oid_flags = flags;
145 }
146
147unsigned long ASN1_PCTX_get_str_flags(ASN1_PCTX *p)
148 {
149 return p->str_flags;
150 }
151
152void ASN1_PCTX_set_str_flags(ASN1_PCTX *p, unsigned long flags)
153 {
154 p->str_flags = flags;
155 }
156
157/* Main print routines */
158
159static int asn1_item_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
160 const ASN1_ITEM *it,
161 const char *fname, const char *sname,
162 int nohdr, const ASN1_PCTX *pctx);
163
164int asn1_template_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
165 const ASN1_TEMPLATE *tt, const ASN1_PCTX *pctx);
166
167static int asn1_primitive_print(BIO *out, ASN1_VALUE **fld,
168 const ASN1_ITEM *it, int indent,
169 const char *fname, const char *sname,
170 const ASN1_PCTX *pctx);
171
172static int asn1_print_fsname(BIO *out, int indent,
173 const char *fname, const char *sname,
174 const ASN1_PCTX *pctx);
175
176int ASN1_item_print(BIO *out, ASN1_VALUE *ifld, int indent,
177 const ASN1_ITEM *it, const ASN1_PCTX *pctx)
178 {
179 const char *sname;
180 if (pctx == NULL)
181 pctx = &default_pctx;
182 if (pctx->flags & ASN1_PCTX_FLAGS_NO_STRUCT_NAME)
183 sname = NULL;
184 else
185 sname = it->sname;
186 return asn1_item_print_ctx(out, &ifld, indent, it,
187 NULL, sname, 0, pctx);
188 }
189
190static int asn1_item_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
191 const ASN1_ITEM *it,
192 const char *fname, const char *sname,
193 int nohdr, const ASN1_PCTX *pctx)
194 {
80 const ASN1_TEMPLATE *tt; 195 const ASN1_TEMPLATE *tt;
81 void *tmpfld; 196 const ASN1_EXTERN_FUNCS *ef;
197 ASN1_VALUE **tmpfld;
198 const ASN1_AUX *aux = it->funcs;
199 ASN1_aux_cb *asn1_cb;
200 ASN1_PRINT_ARG parg;
82 int i; 201 int i;
83 if(!fld) { 202 if (aux && aux->asn1_cb)
84 BIO_printf(out, "%*s%s ABSENT\n", indent, "", name); 203 {
204 parg.out = out;
205 parg.indent = indent;
206 parg.pctx = pctx;
207 asn1_cb = aux->asn1_cb;
208 }
209 else asn1_cb = 0;
210
211 if(*fld == NULL)
212 {
213 if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_ABSENT)
214 {
215 if (!nohdr && !asn1_print_fsname(out, indent,
216 fname, sname, pctx))
217 return 0;
218 if (BIO_puts(out, "<ABSENT>\n") <= 0)
219 return 0;
220 }
85 return 1; 221 return 1;
86 } 222 }
87 switch(it->itype) {
88 223
224 switch(it->itype)
225 {
89 case ASN1_ITYPE_PRIMITIVE: 226 case ASN1_ITYPE_PRIMITIVE:
90 if(it->templates) 227 if(it->templates)
91 return ASN1_template_print(out, fld, indent, it->templates); 228 {
92 return asn1_primitive_print(out, fld, it->utype, indent, name); 229 if (!asn1_template_print_ctx(out, fld, indent,
93 break; 230 it->templates, pctx))
94 231 return 0;
232 }
233 /* fall thru */
95 case ASN1_ITYPE_MSTRING: 234 case ASN1_ITYPE_MSTRING:
96 str = fld; 235 if (!asn1_primitive_print(out, fld, it,
97 return asn1_primitive_print(out, fld, str->type, indent, name); 236 indent, fname, sname,pctx))
237 return 0;
238 break;
98 239
99 case ASN1_ITYPE_EXTERN: 240 case ASN1_ITYPE_EXTERN:
100 BIO_printf(out, "%*s%s:EXTERNAL TYPE %s %s\n", indent, "", name, it->sname, fld ? "" : "ABSENT"); 241 if (!nohdr && !asn1_print_fsname(out, indent, fname, sname, pctx))
101 return 1; 242 return 0;
102 case ASN1_ITYPE_COMPAT: 243 /* Use new style print routine if possible */
103 BIO_printf(out, "%*s%s:COMPATIBLE TYPE %s %s\n", indent, "", name, it->sname, fld ? "" : "ABSENT"); 244 ef = it->funcs;
104 return 1; 245 if (ef && ef->asn1_ex_print)
105 246 {
247 i = ef->asn1_ex_print(out, fld, indent, "", pctx);
248 if (!i)
249 return 0;
250 if ((i == 2) && (BIO_puts(out, "\n") <= 0))
251 return 0;
252 return 1;
253 }
254 else if (sname &&
255 BIO_printf(out, ":EXTERNAL TYPE %s\n", sname) <= 0)
256 return 0;
257 break;
106 258
107 case ASN1_ITYPE_CHOICE: 259 case ASN1_ITYPE_CHOICE:
260#if 0
261 if (!nohdr && !asn1_print_fsname(out, indent, fname, sname, pctx))
262 return 0;
263#endif
108 /* CHOICE type, get selector */ 264 /* CHOICE type, get selector */
109 i = asn1_get_choice_selector(fld, it); 265 i = asn1_get_choice_selector(fld, it);
110 /* This should never happen... */ 266 /* This should never happen... */
111 if((i < 0) || (i >= it->tcount)) { 267 if((i < 0) || (i >= it->tcount))
112 BIO_printf(out, "%s selector [%d] out of range\n", it->sname, i); 268 {
269 if (BIO_printf(out,
270 "ERROR: selector [%d] invalid\n", i) <= 0)
271 return 0;
113 return 1; 272 return 1;
114 } 273 }
115 tt = it->templates + i; 274 tt = it->templates + i;
116 tmpfld = asn1_get_field(fld, tt); 275 tmpfld = asn1_get_field_ptr(fld, tt);
117 return ASN1_template_print(out, tmpfld, indent, tt); 276 if (!asn1_template_print_ctx(out, tmpfld, indent, tt, pctx))
277 return 0;
278 break;
118 279
119 case ASN1_ITYPE_SEQUENCE: 280 case ASN1_ITYPE_SEQUENCE:
120 BIO_printf(out, "%*s%s {\n", indent, "", name); 281 case ASN1_ITYPE_NDEF_SEQUENCE:
121 /* Get each field entry */ 282 if (!nohdr && !asn1_print_fsname(out, indent, fname, sname, pctx))
122 for(i = 0, tt = it->templates; i < it->tcount; i++, tt++) { 283 return 0;
123 tmpfld = asn1_get_field(fld, tt); 284 if (fname || sname)
124 ASN1_template_print(out, tmpfld, indent + 2, tt); 285 {
125 } 286 if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_SEQUENCE)
126 BIO_printf(out, "%*s}\n", indent, ""); 287 {
127 return 1; 288 if (BIO_puts(out, " {\n") <= 0)
289 return 0;
290 }
291 else
292 {
293 if (BIO_puts(out, "\n") <= 0)
294 return 0;
295 }
296 }
297
298 if (asn1_cb)
299 {
300 i = asn1_cb(ASN1_OP_PRINT_PRE, fld, it, &parg);
301 if (i == 0)
302 return 0;
303 if (i == 2)
304 return 1;
305 }
306
307 /* Print each field entry */
308 for(i = 0, tt = it->templates; i < it->tcount; i++, tt++)
309 {
310 const ASN1_TEMPLATE *seqtt;
311 seqtt = asn1_do_adb(fld, tt, 1);
312 tmpfld = asn1_get_field_ptr(fld, seqtt);
313 if (!asn1_template_print_ctx(out, tmpfld,
314 indent + 2, seqtt, pctx))
315 return 0;
316 }
317 if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_SEQUENCE)
318 {
319 if (BIO_printf(out, "%*s}\n", indent, "") < 0)
320 return 0;
321 }
322
323 if (asn1_cb)
324 {
325 i = asn1_cb(ASN1_OP_PRINT_POST, fld, it, &parg);
326 if (i == 0)
327 return 0;
328 }
329 break;
128 330
129 default: 331 default:
332 BIO_printf(out, "Unprocessed type %d\n", it->itype);
130 return 0; 333 return 0;
334 }
335
336 return 1;
131 } 337 }
132}
133 338
134int ASN1_template_print(BIO *out, void *fld, int indent, const ASN1_TEMPLATE *tt) 339int asn1_template_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
135{ 340 const ASN1_TEMPLATE *tt, const ASN1_PCTX *pctx)
341 {
136 int i, flags; 342 int i, flags;
137#if 0 343 const char *sname, *fname;
138 if(!fld) return 0;
139#endif
140 flags = tt->flags; 344 flags = tt->flags;
141 if(flags & ASN1_TFLG_SK_MASK) { 345 if(pctx->flags & ASN1_PCTX_FLAGS_SHOW_FIELD_STRUCT_NAME)
346 sname = ASN1_ITEM_ptr(tt->item)->sname;
347 else
348 sname = NULL;
349 if(pctx->flags & ASN1_PCTX_FLAGS_NO_FIELD_NAME)
350 fname = NULL;
351 else
352 fname = tt->field_name;
353 if(flags & ASN1_TFLG_SK_MASK)
354 {
142 char *tname; 355 char *tname;
143 void *skitem; 356 ASN1_VALUE *skitem;
357 STACK_OF(ASN1_VALUE) *stack;
358
144 /* SET OF, SEQUENCE OF */ 359 /* SET OF, SEQUENCE OF */
145 if(flags & ASN1_TFLG_SET_OF) tname = "SET"; 360 if (fname)
146 else tname = "SEQUENCE"; 361 {
147 if(fld) { 362 if(pctx->flags & ASN1_PCTX_FLAGS_SHOW_SSOF)
148 BIO_printf(out, "%*s%s OF %s {\n", indent, "", tname, tt->field_name); 363 {
149 for(i = 0; i < sk_num(fld); i++) { 364 if(flags & ASN1_TFLG_SET_OF)
150 skitem = sk_value(fld, i); 365 tname = "SET";
151 asn1_item_print_nm(out, skitem, indent + 2, tt->item, ""); 366 else
367 tname = "SEQUENCE";
368 if (BIO_printf(out, "%*s%s OF %s {\n",
369 indent, "", tname, tt->field_name) <= 0)
370 return 0;
371 }
372 else if (BIO_printf(out, "%*s%s:\n", indent, "",
373 fname) <= 0)
374 return 0;
375 }
376 stack = (STACK_OF(ASN1_VALUE) *)*fld;
377 for(i = 0; i < sk_ASN1_VALUE_num(stack); i++)
378 {
379 if ((i > 0) && (BIO_puts(out, "\n") <= 0))
380 return 0;
381
382 skitem = sk_ASN1_VALUE_value(stack, i);
383 if (!asn1_item_print_ctx(out, &skitem, indent + 2,
384 ASN1_ITEM_ptr(tt->item), NULL, NULL, 1, pctx))
385 return 0;
386 }
387 if (!i && BIO_printf(out, "%*s<EMPTY>\n", indent + 2, "") <= 0)
388 return 0;
389 if(pctx->flags & ASN1_PCTX_FLAGS_SHOW_SEQUENCE)
390 {
391 if (BIO_printf(out, "%*s}\n", indent, "") <= 0)
392 return 0;
152 } 393 }
153 BIO_printf(out, "%*s}\n", indent, "");
154 } else
155 BIO_printf(out, "%*s%s OF %s ABSENT\n", indent, "", tname, tt->field_name);
156 return 1; 394 return 1;
395 }
396 return asn1_item_print_ctx(out, fld, indent, ASN1_ITEM_ptr(tt->item),
397 fname, sname, 0, pctx);
157 } 398 }
158 return asn1_item_print_nm(out, fld, indent, tt->item, tt->field_name); 399
159} 400static int asn1_print_fsname(BIO *out, int indent,
160 401 const char *fname, const char *sname,
161static int asn1_primitive_print(BIO *out, void *fld, long utype, int indent, const char *name) 402 const ASN1_PCTX *pctx)
162{ 403 {
163 ASN1_STRING *str = fld; 404 static char spaces[] = " ";
164 if(fld) { 405 const int nspaces = sizeof(spaces) - 1;
165 if(utype == V_ASN1_BOOLEAN) { 406
166 int *bool = fld; 407#if 0
167if(*bool == -1) printf("BOOL MISSING\n"); 408 if (!sname && !fname)
168 BIO_printf(out, "%*s%s:%s", indent, "", "BOOLEAN", *bool ? "TRUE" : "FALSE"); 409 return 1;
169 } else if((utype == V_ASN1_INTEGER) 410#endif
170 || (utype == V_ASN1_ENUMERATED)) { 411
171 char *s, *nm; 412 while (indent > nspaces)
172 s = i2s_ASN1_INTEGER(NULL, fld); 413 {
173 if(utype == V_ASN1_INTEGER) nm = "INTEGER"; 414 if (BIO_write(out, spaces, nspaces) != nspaces)
174 else nm = "ENUMERATED"; 415 return 0;
175 BIO_printf(out, "%*s%s:%s", indent, "", nm, s); 416 indent -= nspaces;
176 OPENSSL_free(s); 417 }
177 } else if(utype == V_ASN1_NULL) { 418 if (BIO_write(out, spaces, indent) != indent)
178 BIO_printf(out, "%*s%s", indent, "", "NULL"); 419 return 0;
179 } else if(utype == V_ASN1_UTCTIME) { 420 if (pctx->flags & ASN1_PCTX_FLAGS_NO_STRUCT_NAME)
180 BIO_printf(out, "%*s%s:%s:", indent, "", name, "UTCTIME"); 421 sname = NULL;
181 ASN1_UTCTIME_print(out, str); 422 if (pctx->flags & ASN1_PCTX_FLAGS_NO_FIELD_NAME)
182 } else if(utype == V_ASN1_GENERALIZEDTIME) { 423 fname = NULL;
183 BIO_printf(out, "%*s%s:%s:", indent, "", name, "GENERALIZEDTIME"); 424 if (!sname && !fname)
184 ASN1_GENERALIZEDTIME_print(out, str); 425 return 1;
185 } else if(utype == V_ASN1_OBJECT) { 426 if (fname)
186 char objbuf[80], *ln; 427 {
187 ln = OBJ_nid2ln(OBJ_obj2nid(fld)); 428 if (BIO_puts(out, fname) <= 0)
188 if(!ln) ln = ""; 429 return 0;
189 OBJ_obj2txt(objbuf, sizeof objbuf, fld, 1);
190 BIO_printf(out, "%*s%s:%s (%s)", indent, "", "OBJECT", ln, objbuf);
191 } else {
192 BIO_printf(out, "%*s%s:", indent, "", name);
193 ASN1_STRING_print_ex(out, str, ASN1_STRFLGS_DUMP_UNKNOWN|ASN1_STRFLGS_SHOW_TYPE);
194 } 430 }
195 BIO_printf(out, "\n"); 431 if (sname)
196 } else BIO_printf(out, "%*s%s [ABSENT]\n", indent, "", name); 432 {
433 if (fname)
434 {
435 if (BIO_printf(out, " (%s)", sname) <= 0)
436 return 0;
437 }
438 else
439 {
440 if (BIO_puts(out, sname) <= 0)
441 return 0;
442 }
443 }
444 if (BIO_write(out, ": ", 2) != 2)
445 return 0;
197 return 1; 446 return 1;
198} 447 }
448
449static int asn1_print_boolean_ctx(BIO *out, const int bool,
450 const ASN1_PCTX *pctx)
451 {
452 const char *str;
453 switch (bool)
454 {
455 case -1:
456 str = "BOOL ABSENT";
457 break;
458
459 case 0:
460 str = "FALSE";
461 break;
462
463 default:
464 str = "TRUE";
465 break;
466
467 }
468
469 if (BIO_puts(out, str) <= 0)
470 return 0;
471 return 1;
472
473 }
474
475static int asn1_print_integer_ctx(BIO *out, ASN1_INTEGER *str,
476 const ASN1_PCTX *pctx)
477 {
478 char *s;
479 int ret = 1;
480 s = i2s_ASN1_INTEGER(NULL, str);
481 if (BIO_puts(out, s) <= 0)
482 ret = 0;
483 OPENSSL_free(s);
484 return ret;
485 }
486
487static int asn1_print_oid_ctx(BIO *out, const ASN1_OBJECT *oid,
488 const ASN1_PCTX *pctx)
489 {
490 char objbuf[80];
491 const char *ln;
492 ln = OBJ_nid2ln(OBJ_obj2nid(oid));
493 if(!ln)
494 ln = "";
495 OBJ_obj2txt(objbuf, sizeof objbuf, oid, 1);
496 if (BIO_printf(out, "%s (%s)", ln, objbuf) <= 0)
497 return 0;
498 return 1;
499 }
500
501static int asn1_print_obstring_ctx(BIO *out, ASN1_STRING *str, int indent,
502 const ASN1_PCTX *pctx)
503 {
504 if (str->type == V_ASN1_BIT_STRING)
505 {
506 if (BIO_printf(out, " (%ld unused bits)\n",
507 str->flags & 0x7) <= 0)
508 return 0;
509 }
510 else if (BIO_puts(out, "\n") <= 0)
511 return 0;
512 if ((str->length > 0)
513 && BIO_dump_indent(out, (char *)str->data, str->length,
514 indent + 2) <= 0)
515 return 0;
516 return 1;
517 }
518
519static int asn1_primitive_print(BIO *out, ASN1_VALUE **fld,
520 const ASN1_ITEM *it, int indent,
521 const char *fname, const char *sname,
522 const ASN1_PCTX *pctx)
523 {
524 long utype;
525 ASN1_STRING *str;
526 int ret = 1, needlf = 1;
527 const char *pname;
528 const ASN1_PRIMITIVE_FUNCS *pf;
529 pf = it->funcs;
530 if (!asn1_print_fsname(out, indent, fname, sname, pctx))
531 return 0;
532 if (pf && pf->prim_print)
533 return pf->prim_print(out, fld, it, indent, pctx);
534 str = (ASN1_STRING *)*fld;
535 if (it->itype == ASN1_ITYPE_MSTRING)
536 utype = str->type & ~V_ASN1_NEG;
537 else
538 utype = it->utype;
539 if (utype == V_ASN1_ANY)
540 {
541 ASN1_TYPE *atype = (ASN1_TYPE *)*fld;
542 utype = atype->type;
543 fld = &atype->value.asn1_value;
544 str = (ASN1_STRING *)*fld;
545 if (pctx->flags & ASN1_PCTX_FLAGS_NO_ANY_TYPE)
546 pname = NULL;
547 else
548 pname = ASN1_tag2str(utype);
549 }
550 else
551 {
552 if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_TYPE)
553 pname = ASN1_tag2str(utype);
554 else
555 pname = NULL;
556 }
557
558 if (utype == V_ASN1_NULL)
559 {
560 if (BIO_puts(out, "NULL\n") <= 0)
561 return 0;
562 return 1;
563 }
564
565 if (pname)
566 {
567 if (BIO_puts(out, pname) <= 0)
568 return 0;
569 if (BIO_puts(out, ":") <= 0)
570 return 0;
571 }
572
573 switch (utype)
574 {
575 case V_ASN1_BOOLEAN:
576 {
577 int bool = *(int *)fld;
578 if (bool == -1)
579 bool = it->size;
580 ret = asn1_print_boolean_ctx(out, bool, pctx);
581 }
582 break;
583
584 case V_ASN1_INTEGER:
585 case V_ASN1_ENUMERATED:
586 ret = asn1_print_integer_ctx(out, str, pctx);
587 break;
588
589 case V_ASN1_UTCTIME:
590 ret = ASN1_UTCTIME_print(out, str);
591 break;
592
593 case V_ASN1_GENERALIZEDTIME:
594 ret = ASN1_GENERALIZEDTIME_print(out, str);
595 break;
596
597 case V_ASN1_OBJECT:
598 ret = asn1_print_oid_ctx(out, (const ASN1_OBJECT *)*fld, pctx);
599 break;
600
601 case V_ASN1_OCTET_STRING:
602 case V_ASN1_BIT_STRING:
603 ret = asn1_print_obstring_ctx(out, str, indent, pctx);
604 needlf = 0;
605 break;
606
607 case V_ASN1_SEQUENCE:
608 case V_ASN1_SET:
609 case V_ASN1_OTHER:
610 if (BIO_puts(out, "\n") <= 0)
611 return 0;
612 if (ASN1_parse_dump(out, str->data, str->length,
613 indent, 0) <= 0)
614 ret = 0;
615 needlf = 0;
616 break;
617
618 default:
619 ret = ASN1_STRING_print_ex(out, str, pctx->str_flags);
620
621 }
622 if (!ret)
623 return 0;
624 if (needlf && BIO_puts(out, "\n") <= 0)
625 return 0;
626 return 1;
627 }