From 5cecd6a22c296f340853d47afffabcd24c0c8b33 Mon Sep 17 00:00:00 2001 From: jsing <> Date: Mon, 1 Apr 2019 15:49:22 +0000 Subject: Implement a print function for BIGNUM_it. ok beck@, tb@ --- src/lib/libcrypto/asn1/x_bignum.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/lib/libcrypto/asn1/x_bignum.c b/src/lib/libcrypto/asn1/x_bignum.c index a5a307eff7..fab8fc212d 100644 --- a/src/lib/libcrypto/asn1/x_bignum.c +++ b/src/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; +} -- cgit v1.2.3-55-g6feb