diff options
author | Joel Sing <jsing@cvs.openbsd.org> | 2019-04-01 15:49:23 +0000 |
---|---|---|
committer | Joel Sing <jsing@cvs.openbsd.org> | 2019-04-01 15:49:23 +0000 |
commit | 16da4f8be43cedc6539c84a30ac91ec6ad9ca75c (patch) | |
tree | 65729b4f1a8d90994b556c66d7dcddab36dc7083 | |
parent | c302c066d506c5fe654568582ec8cbc81f2a8b94 (diff) |
Implement a print function for BIGNUM_it.
ok beck@, tb@
-rw-r--r-- | lib/libcrypto/asn1/x_bignum.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/libcrypto/asn1/x_bignum.c b/lib/libcrypto/asn1/x_bignum.c index a5a307eff79..fab8fc212d7 100644 --- a/lib/libcrypto/asn1/x_bignum.c +++ b/lib/libcrypto/asn1/x_bignum.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x_bignum.c,v 1.9 2019/03/31 14:39:15 jsing Exp $ */ +/* $OpenBSD: x_bignum.c,v 1.10 2019/04/01 15:49:22 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -75,6 +75,8 @@ static int bn_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const ASN1_ITEM *it); static int bn_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it); +static int bn_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it, + int indent, const ASN1_PCTX *pctx); static ASN1_PRIMITIVE_FUNCS bignum_pf = { .app_data = NULL, @@ -84,7 +86,7 @@ static ASN1_PRIMITIVE_FUNCS bignum_pf = { .prim_clear = NULL, /* XXX */ .prim_c2i = bn_c2i, .prim_i2c = bn_i2c, - .prim_print = NULL, + .prim_print = bn_print, }; const ASN1_ITEM BIGNUM_it = { @@ -166,3 +168,17 @@ bn_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, } return 1; } + +static int +bn_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it, int indent, + const ASN1_PCTX *pctx) +{ + BIGNUM *bn = (BIGNUM *)*pval; + + if (!BN_print(out, bn)) + return 0; + if (BIO_printf(out, "\n") <= 0) + return 0; + + return 1; +} |