summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1/a_strex.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/asn1/a_strex.c')
-rw-r--r--src/lib/libcrypto/asn1/a_strex.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/src/lib/libcrypto/asn1/a_strex.c b/src/lib/libcrypto/asn1/a_strex.c
index 569b811998..128aa7e772 100644
--- a/src/lib/libcrypto/asn1/a_strex.c
+++ b/src/lib/libcrypto/asn1/a_strex.c
@@ -371,6 +371,8 @@ static int do_indent(char_io *io_ch, void *arg, int indent)
371 return 1; 371 return 1;
372} 372}
373 373
374#define FN_WIDTH_LN 25
375#define FN_WIDTH_SN 10
374 376
375static int do_name_ex(char_io *io_ch, void *arg, X509_NAME *n, 377static int do_name_ex(char_io *io_ch, void *arg, X509_NAME *n,
376 int indent, unsigned long flags) 378 int indent, unsigned long flags)
@@ -456,19 +458,29 @@ static int do_name_ex(char_io *io_ch, void *arg, X509_NAME *n,
456 val = X509_NAME_ENTRY_get_data(ent); 458 val = X509_NAME_ENTRY_get_data(ent);
457 fn_nid = OBJ_obj2nid(fn); 459 fn_nid = OBJ_obj2nid(fn);
458 if(fn_opt != XN_FLAG_FN_NONE) { 460 if(fn_opt != XN_FLAG_FN_NONE) {
459 int objlen; 461 int objlen, fld_len;
460 if((fn_opt == XN_FLAG_FN_OID) || (fn_nid==NID_undef) ) { 462 if((fn_opt == XN_FLAG_FN_OID) || (fn_nid==NID_undef) ) {
461 OBJ_obj2txt(objtmp, 80, fn, 1); 463 OBJ_obj2txt(objtmp, 80, fn, 1);
464 fld_len = 0; /* XXX: what should this be? */
462 objbuf = objtmp; 465 objbuf = objtmp;
463 } else { 466 } else {
464 if(fn_opt == XN_FLAG_FN_SN) 467 if(fn_opt == XN_FLAG_FN_SN) {
468 fld_len = FN_WIDTH_SN;
465 objbuf = OBJ_nid2sn(fn_nid); 469 objbuf = OBJ_nid2sn(fn_nid);
466 else if(fn_opt == XN_FLAG_FN_LN) 470 } else if(fn_opt == XN_FLAG_FN_LN) {
471 fld_len = FN_WIDTH_LN;
467 objbuf = OBJ_nid2ln(fn_nid); 472 objbuf = OBJ_nid2ln(fn_nid);
468 else objbuf = ""; 473 } else {
474 fld_len = 0; /* XXX: what should this be? */
475 objbuf = "";
476 }
469 } 477 }
470 objlen = strlen(objbuf); 478 objlen = strlen(objbuf);
471 if(!io_ch(arg, objbuf, objlen)) return -1; 479 if(!io_ch(arg, objbuf, objlen)) return -1;
480 if ((objlen < fld_len) && (flags & XN_FLAG_FN_ALIGN)) {
481 if (!do_indent(io_ch, arg, fld_len - objlen)) return -1;
482 outlen += fld_len - objlen;
483 }
472 if(!io_ch(arg, sep_eq, sep_eq_len)) return -1; 484 if(!io_ch(arg, sep_eq, sep_eq_len)) return -1;
473 outlen += objlen + sep_eq_len; 485 outlen += objlen + sep_eq_len;
474 } 486 }
@@ -491,12 +503,24 @@ static int do_name_ex(char_io *io_ch, void *arg, X509_NAME *n,
491 503
492int X509_NAME_print_ex(BIO *out, X509_NAME *nm, int indent, unsigned long flags) 504int X509_NAME_print_ex(BIO *out, X509_NAME *nm, int indent, unsigned long flags)
493{ 505{
506 if(flags == XN_FLAG_COMPAT)
507 return X509_NAME_print(out, nm, indent);
494 return do_name_ex(send_bio_chars, out, nm, indent, flags); 508 return do_name_ex(send_bio_chars, out, nm, indent, flags);
495} 509}
496 510
497 511
498int X509_NAME_print_ex_fp(FILE *fp, X509_NAME *nm, int indent, unsigned long flags) 512int X509_NAME_print_ex_fp(FILE *fp, X509_NAME *nm, int indent, unsigned long flags)
499{ 513{
514 if(flags == XN_FLAG_COMPAT)
515 {
516 BIO *btmp;
517 int ret;
518 btmp = BIO_new_fp(fp, BIO_NOCLOSE);
519 if(!btmp) return -1;
520 ret = X509_NAME_print(btmp, nm, indent);
521 BIO_free(btmp);
522 return ret;
523 }
500 return do_name_ex(send_fp_chars, fp, nm, indent, flags); 524 return do_name_ex(send_fp_chars, fp, nm, indent, flags);
501} 525}
502 526