diff options
| author | jsing <> | 2022-07-30 13:37:17 +0000 |
|---|---|---|
| committer | jsing <> | 2022-07-30 13:37:17 +0000 |
| commit | 1dc2e65d098d6b432c6aec3f1e0446795467eb24 (patch) | |
| tree | de002899993c5f367bc60b41fc6f2c9871f89d6a /src/lib/libc | |
| parent | f3f1f8dcf4fc5dee8271d164b5c0529caad7c12f (diff) | |
| download | openbsd-1dc2e65d098d6b432c6aec3f1e0446795467eb24.tar.gz openbsd-1dc2e65d098d6b432c6aec3f1e0446795467eb24.tar.bz2 openbsd-1dc2e65d098d6b432c6aec3f1e0446795467eb24.zip | |
Provide and use a primitive clear function for BIGNUM_it.
Also tidy up bn_new() while here.
ok tb@
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/asn1/x_bignum.c | 23 |
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 | ||
| 71 | static int bn_new(ASN1_VALUE **pval, const ASN1_ITEM *it); | 71 | static int bn_new(ASN1_VALUE **pval, const ASN1_ITEM *it); |
| 72 | static void bn_free(ASN1_VALUE **pval, const ASN1_ITEM *it); | 72 | static void bn_free(ASN1_VALUE **pval, const ASN1_ITEM *it); |
| 73 | static void bn_clear(ASN1_VALUE **pval, const ASN1_ITEM *it); | ||
| 73 | 74 | ||
| 74 | static int bn_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, | 75 | static 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 = { | |||
| 112 | static int | 113 | static int |
| 113 | bn_new(ASN1_VALUE **pval, const ASN1_ITEM *it) | 114 | bn_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 | |||
| 122 | static void | ||
| 123 | bn_clear(ASN1_VALUE **pval, const ASN1_ITEM *it) | ||
| 124 | { | ||
| 125 | BN_free((BIGNUM *)*pval); | ||
| 126 | *pval = NULL; | ||
| 120 | } | 127 | } |
| 121 | 128 | ||
| 122 | static void | 129 | static 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 | ||
| 131 | static int | 138 | static int |
