summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2016-07-18 17:52:56 +0100
committerDr. Stephen Henson <steve@openssl.org>2016-07-18 17:53:05 +0100
commit3cea73a7fcaaada1ea0ee4b4353ed0176fee1112 (patch)
tree5f38be17af4757ff61cb77ad1c400b9bcf9c82db /crypto
parent23dd09b5e96039300ba0196c122046d1d0b31af1 (diff)
Fix print of ASN.1 BIGNUM type.
The ASN.1 BIGNUM type needs to be handled in a custom way as it is not a generic ASN1_STRING type. Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/asn1/x_bignum.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/crypto/asn1/x_bignum.c b/crypto/asn1/x_bignum.c
index db6ce82e8f..da57e77a7a 100644
--- a/crypto/asn1/x_bignum.c
+++ b/crypto/asn1/x_bignum.c
@@ -31,6 +31,8 @@ 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_secure_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 = {
NULL, 0,
@@ -38,7 +40,8 @@ static ASN1_PRIMITIVE_FUNCS bignum_pf = {
bn_free,
0,
bn_c2i,
- bn_i2c
+ bn_i2c,
+ bn_print
};
static ASN1_PRIMITIVE_FUNCS cbignum_pf = {
@@ -47,7 +50,8 @@ static ASN1_PRIMITIVE_FUNCS cbignum_pf = {
bn_free,
0,
bn_secure_c2i,
- bn_i2c
+ bn_i2c,
+ bn_print
};
ASN1_ITEM_start(BIGNUM)
@@ -130,3 +134,13 @@ static int bn_secure_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
bn_secure_new(pval, it);
return bn_c2i(pval, cont, len, utype, free_cont, it);
}
+
+static int bn_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it,
+ int indent, const ASN1_PCTX *pctx)
+{
+ if (!BN_print(out, *(BIGNUM **)pval))
+ return 0;
+ if (BIO_puts(out, "\n") <= 0)
+ return 0;
+ return 1;
+}