diff options
author | tb <> | 2023-07-02 13:18:54 +0000 |
---|---|---|
committer | tb <> | 2023-07-02 13:18:54 +0000 |
commit | 990e84f7fa2c70c269e911655533a972154800b1 (patch) | |
tree | fddccabf6dc15635e95536a5ab3c014fc2d0d9e7 /src | |
parent | 1f763186de570f92a5cbf045453f0f71f5e1f9ff (diff) | |
download | openbsd-990e84f7fa2c70c269e911655533a972154800b1.tar.gz openbsd-990e84f7fa2c70c269e911655533a972154800b1.tar.bz2 openbsd-990e84f7fa2c70c269e911655533a972154800b1.zip |
Rework handling of the out_kinv and out_r pointers
suggested by jsing
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/ecdsa/ecs_ossl.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/lib/libcrypto/ecdsa/ecs_ossl.c b/src/lib/libcrypto/ecdsa/ecs_ossl.c index 17d39cf36d..b8a0344753 100644 --- a/src/lib/libcrypto/ecdsa/ecs_ossl.c +++ b/src/lib/libcrypto/ecdsa/ecs_ossl.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ecs_ossl.c,v 1.42 2023/07/02 13:05:29 tb Exp $ */ | 1 | /* $OpenBSD: ecs_ossl.c,v 1.43 2023/07/02 13:18:54 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Written by Nils Larsch for the OpenSSL project | 3 | * Written by Nils Larsch for the OpenSSL project |
4 | */ | 4 | */ |
@@ -130,6 +130,12 @@ ossl_ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *in_ctx, BIGNUM **out_kinv, | |||
130 | const EC_GROUP *group; | 130 | const EC_GROUP *group; |
131 | int order_bits, ret = 0; | 131 | int order_bits, ret = 0; |
132 | 132 | ||
133 | BN_free(*out_kinv); | ||
134 | *out_kinv = NULL; | ||
135 | |||
136 | BN_free(*out_r); | ||
137 | *out_r = NULL; | ||
138 | |||
133 | if (eckey == NULL || (group = EC_KEY_get0_group(eckey)) == NULL) { | 139 | if (eckey == NULL || (group = EC_KEY_get0_group(eckey)) == NULL) { |
134 | ECDSAerror(ERR_R_PASSED_NULL_PARAMETER); | 140 | ECDSAerror(ERR_R_PASSED_NULL_PARAMETER); |
135 | return 0; | 141 | return 0; |
@@ -220,20 +226,21 @@ ossl_ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *in_ctx, BIGNUM **out_kinv, | |||
220 | ECDSAerror(ERR_R_BN_LIB); | 226 | ECDSAerror(ERR_R_BN_LIB); |
221 | goto err; | 227 | goto err; |
222 | } | 228 | } |
223 | BN_free(*out_r); | 229 | |
224 | BN_free(*out_kinv); | ||
225 | *out_r = r; | ||
226 | *out_kinv = k; | 230 | *out_kinv = k; |
231 | k = NULL; | ||
232 | |||
233 | *out_r = r; | ||
234 | r = NULL; | ||
235 | |||
227 | ret = 1; | 236 | ret = 1; |
228 | 237 | ||
229 | err: | 238 | err: |
230 | if (ret == 0) { | ||
231 | BN_free(k); | ||
232 | BN_free(r); | ||
233 | } | ||
234 | if (in_ctx == NULL) | 239 | if (in_ctx == NULL) |
235 | BN_CTX_free(ctx); | 240 | BN_CTX_free(ctx); |
236 | BN_free(order); | 241 | BN_free(order); |
242 | BN_free(k); | ||
243 | BN_free(r); | ||
237 | EC_POINT_free(point); | 244 | EC_POINT_free(point); |
238 | BN_free(x); | 245 | BN_free(x); |
239 | return (ret); | 246 | return (ret); |