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.c216
1 files changed, 108 insertions, 108 deletions
diff --git a/src/lib/libcrypto/asn1/tasn_prn.c b/src/lib/libcrypto/asn1/tasn_prn.c
index ec524edac8..f62c085f3b 100644
--- a/src/lib/libcrypto/asn1/tasn_prn.c
+++ b/src/lib/libcrypto/asn1/tasn_prn.c
@@ -73,86 +73,86 @@
73/* ASN1_PCTX routines */ 73/* ASN1_PCTX routines */
74 74
75ASN1_PCTX default_pctx = 75ASN1_PCTX default_pctx =
76 { 76{
77 ASN1_PCTX_FLAGS_SHOW_ABSENT, /* flags */ 77 ASN1_PCTX_FLAGS_SHOW_ABSENT, /* flags */
78 0, /* nm_flags */ 78 0, /* nm_flags */
79 0, /* cert_flags */ 79 0, /* cert_flags */
80 0, /* oid_flags */ 80 0, /* oid_flags */
81 0 /* str_flags */ 81 0 /* str_flags */
82 }; 82};
83 83
84 84
85ASN1_PCTX *ASN1_PCTX_new(void) 85ASN1_PCTX *ASN1_PCTX_new(void)
86 { 86{
87 ASN1_PCTX *ret; 87 ASN1_PCTX *ret;
88 ret = malloc(sizeof(ASN1_PCTX)); 88 ret = malloc(sizeof(ASN1_PCTX));
89 if (ret == NULL) 89 if (ret == NULL)
90 { 90 {
91 ASN1err(ASN1_F_ASN1_PCTX_NEW, ERR_R_MALLOC_FAILURE); 91 ASN1err(ASN1_F_ASN1_PCTX_NEW, ERR_R_MALLOC_FAILURE);
92 return NULL; 92 return NULL;
93 } 93 }
94 ret->flags = 0; 94 ret->flags = 0;
95 ret->nm_flags = 0; 95 ret->nm_flags = 0;
96 ret->cert_flags = 0; 96 ret->cert_flags = 0;
97 ret->oid_flags = 0; 97 ret->oid_flags = 0;
98 ret->str_flags = 0; 98 ret->str_flags = 0;
99 return ret; 99 return ret;
100 } 100}
101 101
102void ASN1_PCTX_free(ASN1_PCTX *p) 102void ASN1_PCTX_free(ASN1_PCTX *p)
103 { 103{
104 free(p); 104 free(p);
105 } 105}
106 106
107unsigned long ASN1_PCTX_get_flags(ASN1_PCTX *p) 107unsigned long ASN1_PCTX_get_flags(ASN1_PCTX *p)
108 { 108{
109 return p->flags; 109 return p->flags;
110 } 110}
111 111
112void ASN1_PCTX_set_flags(ASN1_PCTX *p, unsigned long flags) 112void ASN1_PCTX_set_flags(ASN1_PCTX *p, unsigned long flags)
113 { 113{
114 p->flags = flags; 114 p->flags = flags;
115 } 115}
116 116
117unsigned long ASN1_PCTX_get_nm_flags(ASN1_PCTX *p) 117unsigned long ASN1_PCTX_get_nm_flags(ASN1_PCTX *p)
118 { 118{
119 return p->nm_flags; 119 return p->nm_flags;
120 } 120}
121 121
122void ASN1_PCTX_set_nm_flags(ASN1_PCTX *p, unsigned long flags) 122void ASN1_PCTX_set_nm_flags(ASN1_PCTX *p, unsigned long flags)
123 { 123{
124 p->nm_flags = flags; 124 p->nm_flags = flags;
125 } 125}
126 126
127unsigned long ASN1_PCTX_get_cert_flags(ASN1_PCTX *p) 127unsigned long ASN1_PCTX_get_cert_flags(ASN1_PCTX *p)
128 { 128{
129 return p->cert_flags; 129 return p->cert_flags;
130 } 130}
131 131
132void ASN1_PCTX_set_cert_flags(ASN1_PCTX *p, unsigned long flags) 132void ASN1_PCTX_set_cert_flags(ASN1_PCTX *p, unsigned long flags)
133 { 133{
134 p->cert_flags = flags; 134 p->cert_flags = flags;
135 } 135}
136 136
137unsigned long ASN1_PCTX_get_oid_flags(ASN1_PCTX *p) 137unsigned long ASN1_PCTX_get_oid_flags(ASN1_PCTX *p)
138 { 138{
139 return p->oid_flags; 139 return p->oid_flags;
140 } 140}
141 141
142void ASN1_PCTX_set_oid_flags(ASN1_PCTX *p, unsigned long flags) 142void ASN1_PCTX_set_oid_flags(ASN1_PCTX *p, unsigned long flags)
143 { 143{
144 p->oid_flags = flags; 144 p->oid_flags = flags;
145 } 145}
146 146
147unsigned long ASN1_PCTX_get_str_flags(ASN1_PCTX *p) 147unsigned long ASN1_PCTX_get_str_flags(ASN1_PCTX *p)
148 { 148{
149 return p->str_flags; 149 return p->str_flags;
150 } 150}
151 151
152void ASN1_PCTX_set_str_flags(ASN1_PCTX *p, unsigned long flags) 152void ASN1_PCTX_set_str_flags(ASN1_PCTX *p, unsigned long flags)
153 { 153{
154 p->str_flags = flags; 154 p->str_flags = flags;
155 } 155}
156 156
157/* Main print routines */ 157/* Main print routines */
158 158
@@ -175,7 +175,7 @@ static int asn1_print_fsname(BIO *out, int indent,
175 175
176int ASN1_item_print(BIO *out, ASN1_VALUE *ifld, int indent, 176int ASN1_item_print(BIO *out, ASN1_VALUE *ifld, int indent,
177 const ASN1_ITEM *it, const ASN1_PCTX *pctx) 177 const ASN1_ITEM *it, const ASN1_PCTX *pctx)
178 { 178{
179 const char *sname; 179 const char *sname;
180 if (pctx == NULL) 180 if (pctx == NULL)
181 pctx = &default_pctx; 181 pctx = &default_pctx;
@@ -185,13 +185,13 @@ int ASN1_item_print(BIO *out, ASN1_VALUE *ifld, int indent,
185 sname = it->sname; 185 sname = it->sname;
186 return asn1_item_print_ctx(out, &ifld, indent, it, 186 return asn1_item_print_ctx(out, &ifld, indent, it,
187 NULL, sname, 0, pctx); 187 NULL, sname, 0, pctx);
188 } 188}
189 189
190static int asn1_item_print_ctx(BIO *out, ASN1_VALUE **fld, int indent, 190static int asn1_item_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
191 const ASN1_ITEM *it, 191 const ASN1_ITEM *it,
192 const char *fname, const char *sname, 192 const char *fname, const char *sname,
193 int nohdr, const ASN1_PCTX *pctx) 193 int nohdr, const ASN1_PCTX *pctx)
194 { 194{
195 const ASN1_TEMPLATE *tt; 195 const ASN1_TEMPLATE *tt;
196 const ASN1_EXTERN_FUNCS *ef; 196 const ASN1_EXTERN_FUNCS *ef;
197 ASN1_VALUE **tmpfld; 197 ASN1_VALUE **tmpfld;
@@ -200,36 +200,36 @@ static int asn1_item_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
200 ASN1_PRINT_ARG parg; 200 ASN1_PRINT_ARG parg;
201 int i; 201 int i;
202 if (aux && aux->asn1_cb) 202 if (aux && aux->asn1_cb)
203 { 203 {
204 parg.out = out; 204 parg.out = out;
205 parg.indent = indent; 205 parg.indent = indent;
206 parg.pctx = pctx; 206 parg.pctx = pctx;
207 asn1_cb = aux->asn1_cb; 207 asn1_cb = aux->asn1_cb;
208 } 208 }
209 else asn1_cb = 0; 209 else asn1_cb = 0;
210 210
211 if(*fld == NULL) 211 if(*fld == NULL)
212 { 212 {
213 if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_ABSENT) 213 if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_ABSENT)
214 { 214 {
215 if (!nohdr && !asn1_print_fsname(out, indent, 215 if (!nohdr && !asn1_print_fsname(out, indent,
216 fname, sname, pctx)) 216 fname, sname, pctx))
217 return 0; 217 return 0;
218 if (BIO_puts(out, "<ABSENT>\n") <= 0) 218 if (BIO_puts(out, "<ABSENT>\n") <= 0)
219 return 0; 219 return 0;
220 }
221 return 1;
222 } 220 }
221 return 1;
222 }
223 223
224 switch(it->itype) 224 switch(it->itype)
225 { 225 {
226 case ASN1_ITYPE_PRIMITIVE: 226 case ASN1_ITYPE_PRIMITIVE:
227 if(it->templates) 227 if(it->templates)
228 { 228 {
229 if (!asn1_template_print_ctx(out, fld, indent, 229 if (!asn1_template_print_ctx(out, fld, indent,
230 it->templates, pctx)) 230 it->templates, pctx))
231 return 0; 231 return 0;
232 } 232 }
233 /* fall thru */ 233 /* fall thru */
234 case ASN1_ITYPE_MSTRING: 234 case ASN1_ITYPE_MSTRING:
235 if (!asn1_primitive_print(out, fld, it, 235 if (!asn1_primitive_print(out, fld, it,
@@ -243,14 +243,14 @@ static int asn1_item_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
243 /* Use new style print routine if possible */ 243 /* Use new style print routine if possible */
244 ef = it->funcs; 244 ef = it->funcs;
245 if (ef && ef->asn1_ex_print) 245 if (ef && ef->asn1_ex_print)
246 { 246 {
247 i = ef->asn1_ex_print(out, fld, indent, "", pctx); 247 i = ef->asn1_ex_print(out, fld, indent, "", pctx);
248 if (!i) 248 if (!i)
249 return 0; 249 return 0;
250 if ((i == 2) && (BIO_puts(out, "\n") <= 0)) 250 if ((i == 2) && (BIO_puts(out, "\n") <= 0))
251 return 0; 251 return 0;
252 return 1; 252 return 1;
253 } 253 }
254 else if (sname && 254 else if (sname &&
255 BIO_printf(out, ":EXTERNAL TYPE %s\n", sname) <= 0) 255 BIO_printf(out, ":EXTERNAL TYPE %s\n", sname) <= 0)
256 return 0; 256 return 0;
@@ -265,12 +265,12 @@ static int asn1_item_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
265 i = asn1_get_choice_selector(fld, it); 265 i = asn1_get_choice_selector(fld, it);
266 /* This should never happen... */ 266 /* This should never happen... */
267 if((i < 0) || (i >= it->tcount)) 267 if((i < 0) || (i >= it->tcount))
268 { 268 {
269 if (BIO_printf(out, 269 if (BIO_printf(out,
270 "ERROR: selector [%d] invalid\n", i) <= 0) 270 "ERROR: selector [%d] invalid\n", i) <= 0)
271 return 0; 271 return 0;
272 return 1; 272 return 1;
273 } 273 }
274 tt = it->templates + i; 274 tt = it->templates + i;
275 tmpfld = asn1_get_field_ptr(fld, tt); 275 tmpfld = asn1_get_field_ptr(fld, tt);
276 if (!asn1_template_print_ctx(out, tmpfld, indent, tt, pctx)) 276 if (!asn1_template_print_ctx(out, tmpfld, indent, tt, pctx))
@@ -282,63 +282,63 @@ static int asn1_item_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
282 if (!nohdr && !asn1_print_fsname(out, indent, fname, sname, pctx)) 282 if (!nohdr && !asn1_print_fsname(out, indent, fname, sname, pctx))
283 return 0; 283 return 0;
284 if (fname || sname) 284 if (fname || sname)
285 { 285 {
286 if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_SEQUENCE) 286 if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_SEQUENCE)
287 { 287 {
288 if (BIO_puts(out, " {\n") <= 0) 288 if (BIO_puts(out, " {\n") <= 0)
289 return 0; 289 return 0;
290 } 290 }
291 else 291 else
292 { 292 {
293 if (BIO_puts(out, "\n") <= 0) 293 if (BIO_puts(out, "\n") <= 0)
294 return 0; 294 return 0;
295 }
296 } 295 }
296 }
297 297
298 if (asn1_cb) 298 if (asn1_cb)
299 { 299 {
300 i = asn1_cb(ASN1_OP_PRINT_PRE, fld, it, &parg); 300 i = asn1_cb(ASN1_OP_PRINT_PRE, fld, it, &parg);
301 if (i == 0) 301 if (i == 0)
302 return 0; 302 return 0;
303 if (i == 2) 303 if (i == 2)
304 return 1; 304 return 1;
305 } 305 }
306 306
307 /* Print each field entry */ 307 /* Print each field entry */
308 for(i = 0, tt = it->templates; i < it->tcount; i++, tt++) 308 for(i = 0, tt = it->templates; i < it->tcount; i++, tt++)
309 { 309 {
310 const ASN1_TEMPLATE *seqtt; 310 const ASN1_TEMPLATE *seqtt;
311 seqtt = asn1_do_adb(fld, tt, 1); 311 seqtt = asn1_do_adb(fld, tt, 1);
312 tmpfld = asn1_get_field_ptr(fld, seqtt); 312 tmpfld = asn1_get_field_ptr(fld, seqtt);
313 if (!asn1_template_print_ctx(out, tmpfld, 313 if (!asn1_template_print_ctx(out, tmpfld,
314 indent + 2, seqtt, pctx)) 314 indent + 2, seqtt, pctx))
315 return 0; 315 return 0;
316 } 316 }
317 if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_SEQUENCE) 317 if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_SEQUENCE)
318 { 318 {
319 if (BIO_printf(out, "%*s}\n", indent, "") < 0) 319 if (BIO_printf(out, "%*s}\n", indent, "") < 0)
320 return 0; 320 return 0;
321 } 321 }
322 322
323 if (asn1_cb) 323 if (asn1_cb)
324 { 324 {
325 i = asn1_cb(ASN1_OP_PRINT_POST, fld, it, &parg); 325 i = asn1_cb(ASN1_OP_PRINT_POST, fld, it, &parg);
326 if (i == 0) 326 if (i == 0)
327 return 0; 327 return 0;
328 } 328 }
329 break; 329 break;
330 330
331 default: 331 default:
332 BIO_printf(out, "Unprocessed type %d\n", it->itype); 332 BIO_printf(out, "Unprocessed type %d\n", it->itype);
333 return 0; 333 return 0;
334 } 334 }
335 335
336 return 1; 336 return 1;
337 } 337}
338 338
339int asn1_template_print_ctx(BIO *out, ASN1_VALUE **fld, int indent, 339int asn1_template_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
340 const ASN1_TEMPLATE *tt, const ASN1_PCTX *pctx) 340 const ASN1_TEMPLATE *tt, const ASN1_PCTX *pctx)
341 { 341{
342 int i, flags; 342 int i, flags;
343 const char *sname, *fname; 343 const char *sname, *fname;
344 flags = tt->flags; 344 flags = tt->flags;
@@ -351,16 +351,16 @@ int asn1_template_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
351 else 351 else
352 fname = tt->field_name; 352 fname = tt->field_name;
353 if(flags & ASN1_TFLG_SK_MASK) 353 if(flags & ASN1_TFLG_SK_MASK)
354 { 354 {
355 char *tname; 355 char *tname;
356 ASN1_VALUE *skitem; 356 ASN1_VALUE *skitem;
357 STACK_OF(ASN1_VALUE) *stack; 357 STACK_OF(ASN1_VALUE) *stack;
358 358
359 /* SET OF, SEQUENCE OF */ 359 /* SET OF, SEQUENCE OF */
360 if (fname) 360 if (fname)
361 { 361 {
362 if(pctx->flags & ASN1_PCTX_FLAGS_SHOW_SSOF) 362 if(pctx->flags & ASN1_PCTX_FLAGS_SHOW_SSOF)
363 { 363 {
364 if(flags & ASN1_TFLG_SET_OF) 364 if(flags & ASN1_TFLG_SET_OF)
365 tname = "SET"; 365 tname = "SET";
366 else 366 else
@@ -368,14 +368,14 @@ int asn1_template_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
368 if (BIO_printf(out, "%*s%s OF %s {\n", 368 if (BIO_printf(out, "%*s%s OF %s {\n",
369 indent, "", tname, tt->field_name) <= 0) 369 indent, "", tname, tt->field_name) <= 0)
370 return 0; 370 return 0;
371 } 371 }
372 else if (BIO_printf(out, "%*s%s:\n", indent, "", 372 else if (BIO_printf(out, "%*s%s:\n", indent, "",
373 fname) <= 0) 373 fname) <= 0)
374 return 0; 374 return 0;
375 } 375 }
376 stack = (STACK_OF(ASN1_VALUE) *)*fld; 376 stack = (STACK_OF(ASN1_VALUE) *)*fld;
377 for(i = 0; i < sk_ASN1_VALUE_num(stack); i++) 377 for(i = 0; i < sk_ASN1_VALUE_num(stack); i++)
378 { 378 {
379 if ((i > 0) && (BIO_puts(out, "\n") <= 0)) 379 if ((i > 0) && (BIO_puts(out, "\n") <= 0))
380 return 0; 380 return 0;
381 381
@@ -383,24 +383,24 @@ int asn1_template_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
383 if (!asn1_item_print_ctx(out, &skitem, indent + 2, 383 if (!asn1_item_print_ctx(out, &skitem, indent + 2,
384 ASN1_ITEM_ptr(tt->item), NULL, NULL, 1, pctx)) 384 ASN1_ITEM_ptr(tt->item), NULL, NULL, 1, pctx))
385 return 0; 385 return 0;
386 } 386 }
387 if (!i && BIO_printf(out, "%*s<EMPTY>\n", indent + 2, "") <= 0) 387 if (!i && BIO_printf(out, "%*s<EMPTY>\n", indent + 2, "") <= 0)
388 return 0; 388 return 0;
389 if(pctx->flags & ASN1_PCTX_FLAGS_SHOW_SEQUENCE) 389 if(pctx->flags & ASN1_PCTX_FLAGS_SHOW_SEQUENCE)
390 { 390 {
391 if (BIO_printf(out, "%*s}\n", indent, "") <= 0) 391 if (BIO_printf(out, "%*s}\n", indent, "") <= 0)
392 return 0; 392 return 0;
393 }
394 return 1;
395 } 393 }
394 return 1;
395 }
396 return asn1_item_print_ctx(out, fld, indent, ASN1_ITEM_ptr(tt->item), 396 return asn1_item_print_ctx(out, fld, indent, ASN1_ITEM_ptr(tt->item),
397 fname, sname, 0, pctx); 397 fname, sname, 0, pctx);
398 } 398}
399 399
400static int asn1_print_fsname(BIO *out, int indent, 400static int asn1_print_fsname(BIO *out, int indent,
401 const char *fname, const char *sname, 401 const char *fname, const char *sname,
402 const ASN1_PCTX *pctx) 402 const ASN1_PCTX *pctx)
403 { 403{
404 static char spaces[] = " "; 404 static char spaces[] = " ";
405 const int nspaces = sizeof(spaces) - 1; 405 const int nspaces = sizeof(spaces) - 1;
406 406
@@ -410,11 +410,11 @@ static int asn1_print_fsname(BIO *out, int indent,
410#endif 410#endif
411 411
412 while (indent > nspaces) 412 while (indent > nspaces)
413 { 413 {
414 if (BIO_write(out, spaces, nspaces) != nspaces) 414 if (BIO_write(out, spaces, nspaces) != nspaces)
415 return 0; 415 return 0;
416 indent -= nspaces; 416 indent -= nspaces;
417 } 417 }
418 if (BIO_write(out, spaces, indent) != indent) 418 if (BIO_write(out, spaces, indent) != indent)
419 return 0; 419 return 0;
420 if (pctx->flags & ASN1_PCTX_FLAGS_NO_STRUCT_NAME) 420 if (pctx->flags & ASN1_PCTX_FLAGS_NO_STRUCT_NAME)
@@ -424,34 +424,34 @@ static int asn1_print_fsname(BIO *out, int indent,
424 if (!sname && !fname) 424 if (!sname && !fname)
425 return 1; 425 return 1;
426 if (fname) 426 if (fname)
427 { 427 {
428 if (BIO_puts(out, fname) <= 0) 428 if (BIO_puts(out, fname) <= 0)
429 return 0; 429 return 0;
430 } 430 }
431 if (sname) 431 if (sname)
432 { 432 {
433 if (fname) 433 if (fname)
434 { 434 {
435 if (BIO_printf(out, " (%s)", sname) <= 0) 435 if (BIO_printf(out, " (%s)", sname) <= 0)
436 return 0; 436 return 0;
437 } 437 }
438 else 438 else
439 { 439 {
440 if (BIO_puts(out, sname) <= 0) 440 if (BIO_puts(out, sname) <= 0)
441 return 0; 441 return 0;
442 }
443 } 442 }
443 }
444 if (BIO_write(out, ": ", 2) != 2) 444 if (BIO_write(out, ": ", 2) != 2)
445 return 0; 445 return 0;
446 return 1; 446 return 1;
447 } 447}
448 448
449static int asn1_print_boolean_ctx(BIO *out, int boolval, 449static int asn1_print_boolean_ctx(BIO *out, int boolval,
450 const ASN1_PCTX *pctx) 450 const ASN1_PCTX *pctx)
451 { 451{
452 const char *str; 452 const char *str;
453 switch (boolval) 453 switch (boolval)
454 { 454 {
455 case -1: 455 case -1:
456 str = "BOOL ABSENT"; 456 str = "BOOL ABSENT";
457 break; 457 break;
@@ -464,17 +464,17 @@ static int asn1_print_boolean_ctx(BIO *out, int boolval,
464 str = "TRUE"; 464 str = "TRUE";
465 break; 465 break;
466 466
467 } 467 }
468 468
469 if (BIO_puts(out, str) <= 0) 469 if (BIO_puts(out, str) <= 0)
470 return 0; 470 return 0;
471 return 1; 471 return 1;
472 472
473 } 473}
474 474
475static int asn1_print_integer_ctx(BIO *out, ASN1_INTEGER *str, 475static int asn1_print_integer_ctx(BIO *out, ASN1_INTEGER *str,
476 const ASN1_PCTX *pctx) 476 const ASN1_PCTX *pctx)
477 { 477{
478 char *s; 478 char *s;
479 int ret = 1; 479 int ret = 1;
480 s = i2s_ASN1_INTEGER(NULL, str); 480 s = i2s_ASN1_INTEGER(NULL, str);
@@ -482,11 +482,11 @@ static int asn1_print_integer_ctx(BIO *out, ASN1_INTEGER *str,
482 ret = 0; 482 ret = 0;
483 free(s); 483 free(s);
484 return ret; 484 return ret;
485 } 485}
486 486
487static int asn1_print_oid_ctx(BIO *out, const ASN1_OBJECT *oid, 487static int asn1_print_oid_ctx(BIO *out, const ASN1_OBJECT *oid,
488 const ASN1_PCTX *pctx) 488 const ASN1_PCTX *pctx)
489 { 489{
490 char objbuf[80]; 490 char objbuf[80];
491 const char *ln; 491 const char *ln;
492 ln = OBJ_nid2ln(OBJ_obj2nid(oid)); 492 ln = OBJ_nid2ln(OBJ_obj2nid(oid));
@@ -496,17 +496,17 @@ static int asn1_print_oid_ctx(BIO *out, const ASN1_OBJECT *oid,
496 if (BIO_printf(out, "%s (%s)", ln, objbuf) <= 0) 496 if (BIO_printf(out, "%s (%s)", ln, objbuf) <= 0)
497 return 0; 497 return 0;
498 return 1; 498 return 1;
499 } 499}
500 500
501static int asn1_print_obstring_ctx(BIO *out, ASN1_STRING *str, int indent, 501static int asn1_print_obstring_ctx(BIO *out, ASN1_STRING *str, int indent,
502 const ASN1_PCTX *pctx) 502 const ASN1_PCTX *pctx)
503 { 503{
504 if (str->type == V_ASN1_BIT_STRING) 504 if (str->type == V_ASN1_BIT_STRING)
505 { 505 {
506 if (BIO_printf(out, " (%ld unused bits)\n", 506 if (BIO_printf(out, " (%ld unused bits)\n",
507 str->flags & 0x7) <= 0) 507 str->flags & 0x7) <= 0)
508 return 0; 508 return 0;
509 } 509 }
510 else if (BIO_puts(out, "\n") <= 0) 510 else if (BIO_puts(out, "\n") <= 0)
511 return 0; 511 return 0;
512 if ((str->length > 0) 512 if ((str->length > 0)
@@ -514,13 +514,13 @@ static int asn1_print_obstring_ctx(BIO *out, ASN1_STRING *str, int indent,
514 indent + 2) <= 0) 514 indent + 2) <= 0)
515 return 0; 515 return 0;
516 return 1; 516 return 1;
517 } 517}
518 518
519static int asn1_primitive_print(BIO *out, ASN1_VALUE **fld, 519static int asn1_primitive_print(BIO *out, ASN1_VALUE **fld,
520 const ASN1_ITEM *it, int indent, 520 const ASN1_ITEM *it, int indent,
521 const char *fname, const char *sname, 521 const char *fname, const char *sname,
522 const ASN1_PCTX *pctx) 522 const ASN1_PCTX *pctx)
523 { 523{
524 long utype; 524 long utype;
525 ASN1_STRING *str; 525 ASN1_STRING *str;
526 int ret = 1, needlf = 1; 526 int ret = 1, needlf = 1;
@@ -537,7 +537,7 @@ static int asn1_primitive_print(BIO *out, ASN1_VALUE **fld,
537 else 537 else
538 utype = it->utype; 538 utype = it->utype;
539 if (utype == V_ASN1_ANY) 539 if (utype == V_ASN1_ANY)
540 { 540 {
541 ASN1_TYPE *atype = (ASN1_TYPE *)*fld; 541 ASN1_TYPE *atype = (ASN1_TYPE *)*fld;
542 utype = atype->type; 542 utype = atype->type;
543 fld = &atype->value.asn1_value; 543 fld = &atype->value.asn1_value;
@@ -546,39 +546,39 @@ static int asn1_primitive_print(BIO *out, ASN1_VALUE **fld,
546 pname = NULL; 546 pname = NULL;
547 else 547 else
548 pname = ASN1_tag2str(utype); 548 pname = ASN1_tag2str(utype);
549 } 549 }
550 else 550 else
551 { 551 {
552 if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_TYPE) 552 if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_TYPE)
553 pname = ASN1_tag2str(utype); 553 pname = ASN1_tag2str(utype);
554 else 554 else
555 pname = NULL; 555 pname = NULL;
556 } 556 }
557 557
558 if (utype == V_ASN1_NULL) 558 if (utype == V_ASN1_NULL)
559 { 559 {
560 if (BIO_puts(out, "NULL\n") <= 0) 560 if (BIO_puts(out, "NULL\n") <= 0)
561 return 0; 561 return 0;
562 return 1; 562 return 1;
563 } 563 }
564 564
565 if (pname) 565 if (pname)
566 { 566 {
567 if (BIO_puts(out, pname) <= 0) 567 if (BIO_puts(out, pname) <= 0)
568 return 0; 568 return 0;
569 if (BIO_puts(out, ":") <= 0) 569 if (BIO_puts(out, ":") <= 0)
570 return 0; 570 return 0;
571 } 571 }
572 572
573 switch (utype) 573 switch (utype)
574 { 574 {
575 case V_ASN1_BOOLEAN: 575 case V_ASN1_BOOLEAN:
576 { 576 {
577 int boolval = *(int *)fld; 577 int boolval = *(int *)fld;
578 if (boolval == -1) 578 if (boolval == -1)
579 boolval = it->size; 579 boolval = it->size;
580 ret = asn1_print_boolean_ctx(out, boolval, pctx); 580 ret = asn1_print_boolean_ctx(out, boolval, pctx);
581 } 581 }
582 break; 582 break;
583 583
584 case V_ASN1_INTEGER: 584 case V_ASN1_INTEGER:
@@ -618,10 +618,10 @@ static int asn1_primitive_print(BIO *out, ASN1_VALUE **fld,
618 default: 618 default:
619 ret = ASN1_STRING_print_ex(out, str, pctx->str_flags); 619 ret = ASN1_STRING_print_ex(out, str, pctx->str_flags);
620 620
621 } 621 }
622 if (!ret) 622 if (!ret)
623 return 0; 623 return 0;
624 if (needlf && BIO_puts(out, "\n") <= 0) 624 if (needlf && BIO_puts(out, "\n") <= 0)
625 return 0; 625 return 0;
626 return 1; 626 return 1;
627 } 627}