summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorjsing <>2022-07-30 13:37:17 +0000
committerjsing <>2022-07-30 13:37:17 +0000
commit0f71ba015d8e03e4d84b7bc359636df7bec8ff0d (patch)
treede002899993c5f367bc60b41fc6f2c9871f89d6a /src/lib
parent37cc01d2346626dfdf99d0f89d6ab5e0679448be (diff)
downloadopenbsd-0f71ba015d8e03e4d84b7bc359636df7bec8ff0d.tar.gz
openbsd-0f71ba015d8e03e4d84b7bc359636df7bec8ff0d.tar.bz2
openbsd-0f71ba015d8e03e4d84b7bc359636df7bec8ff0d.zip
Provide and use a primitive clear function for BIGNUM_it.
Also tidy up bn_new() while here. ok tb@
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/asn1/x_bignum.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/lib/libcrypto/asn1/x_bignum.c b/src/lib/libcrypto/asn1/x_bignum.c
index fab8fc212d..9ad7810306 100644
--- a/src/lib/libcrypto/asn1/x_bignum.c
+++ b/src/lib/libcrypto/asn1/x_bignum.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x_bignum.c,v 1.10 2019/04/01 15:49:22 jsing Exp $ */ 1/* $OpenBSD: x_bignum.c,v 1.11 2022/07/30 13:37:17 jsing Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
@@ -70,6 +70,7 @@
70 70
71static int bn_new(ASN1_VALUE **pval, const ASN1_ITEM *it); 71static int bn_new(ASN1_VALUE **pval, const ASN1_ITEM *it);
72static void bn_free(ASN1_VALUE **pval, const ASN1_ITEM *it); 72static void bn_free(ASN1_VALUE **pval, const ASN1_ITEM *it);
73static void bn_clear(ASN1_VALUE **pval, const ASN1_ITEM *it);
73 74
74static int bn_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, 75static int bn_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype,
75 const ASN1_ITEM *it); 76 const ASN1_ITEM *it);
@@ -83,7 +84,7 @@ static ASN1_PRIMITIVE_FUNCS bignum_pf = {
83 .flags = 0, 84 .flags = 0,
84 .prim_new = bn_new, 85 .prim_new = bn_new,
85 .prim_free = bn_free, 86 .prim_free = bn_free,
86 .prim_clear = NULL, /* XXX */ 87 .prim_clear = bn_clear,
87 .prim_c2i = bn_c2i, 88 .prim_c2i = bn_c2i,
88 .prim_i2c = bn_i2c, 89 .prim_i2c = bn_i2c,
89 .prim_print = bn_print, 90 .prim_print = bn_print,
@@ -112,11 +113,17 @@ const ASN1_ITEM CBIGNUM_it = {
112static int 113static int
113bn_new(ASN1_VALUE **pval, const ASN1_ITEM *it) 114bn_new(ASN1_VALUE **pval, const ASN1_ITEM *it)
114{ 115{
115 *pval = (ASN1_VALUE *)BN_new(); 116 if ((*pval = (ASN1_VALUE *)BN_new()) == NULL)
116 if (*pval)
117 return 1;
118 else
119 return 0; 117 return 0;
118
119 return 1;
120}
121
122static void
123bn_clear(ASN1_VALUE **pval, const ASN1_ITEM *it)
124{
125 BN_free((BIGNUM *)*pval);
126 *pval = NULL;
120} 127}
121 128
122static void 129static void
@@ -124,8 +131,8 @@ bn_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
124{ 131{
125 if (*pval == NULL) 132 if (*pval == NULL)
126 return; 133 return;
127 BN_clear_free((BIGNUM *)*pval); 134
128 *pval = NULL; 135 bn_clear(pval, it);
129} 136}
130 137
131static int 138static int