summaryrefslogtreecommitdiff
path: root/lib/libcrypto
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2022-07-30 13:37:18 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2022-07-30 13:37:18 +0000
commit7dbdeee8de88e5f46d218ef2d73df2e945de3c48 (patch)
treea53e09589b9850112e8810da1bc9e3591220a9ff /lib/libcrypto
parentf83afd5c57b1ec361ca58a33151209dce3bec429 (diff)
Provide and use a primitive clear function for BIGNUM_it.
Also tidy up bn_new() while here. ok tb@
Diffstat (limited to 'lib/libcrypto')
-rw-r--r--lib/libcrypto/asn1/x_bignum.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/lib/libcrypto/asn1/x_bignum.c b/lib/libcrypto/asn1/x_bignum.c
index fab8fc212d7..9ad78103062 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.10 2019/04/01 15:49:22 jsing Exp $ */
+/* $OpenBSD: x_bignum.c,v 1.11 2022/07/30 13:37:17 jsing Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2000.
*/
@@ -70,6 +70,7 @@
static int bn_new(ASN1_VALUE **pval, const ASN1_ITEM *it);
static void bn_free(ASN1_VALUE **pval, const ASN1_ITEM *it);
+static void bn_clear(ASN1_VALUE **pval, const ASN1_ITEM *it);
static int bn_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype,
const ASN1_ITEM *it);
@@ -83,7 +84,7 @@ static ASN1_PRIMITIVE_FUNCS bignum_pf = {
.flags = 0,
.prim_new = bn_new,
.prim_free = bn_free,
- .prim_clear = NULL, /* XXX */
+ .prim_clear = bn_clear,
.prim_c2i = bn_c2i,
.prim_i2c = bn_i2c,
.prim_print = bn_print,
@@ -112,11 +113,17 @@ const ASN1_ITEM CBIGNUM_it = {
static int
bn_new(ASN1_VALUE **pval, const ASN1_ITEM *it)
{
- *pval = (ASN1_VALUE *)BN_new();
- if (*pval)
- return 1;
- else
+ if ((*pval = (ASN1_VALUE *)BN_new()) == NULL)
return 0;
+
+ return 1;
+}
+
+static void
+bn_clear(ASN1_VALUE **pval, const ASN1_ITEM *it)
+{
+ BN_free((BIGNUM *)*pval);
+ *pval = NULL;
}
static void
@@ -124,8 +131,8 @@ bn_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
{
if (*pval == NULL)
return;
- BN_clear_free((BIGNUM *)*pval);
- *pval = NULL;
+
+ bn_clear(pval, it);
}
static int