summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjsing <jsing@openbsd.org>2019-04-01 15:49:22 +0000
committerjsing <jsing@openbsd.org>2019-04-01 15:49:22 +0000
commit2dc07f70c65fea40cbc934a2fedd3d0d8638d907 (patch)
tree1a8fef086adadad7135cd9c2afbf13ebcbacbd48
parentCorrect the return values from long_print. (diff)
downloadwireguard-openbsd-2dc07f70c65fea40cbc934a2fedd3d0d8638d907.tar.xz
wireguard-openbsd-2dc07f70c65fea40cbc934a2fedd3d0d8638d907.zip
Implement a print function for BIGNUM_it.
ok beck@, tb@
-rw-r--r--lib/libcrypto/asn1/x_bignum.c20
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;
+}