diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2023-07-02 13:18:55 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2023-07-02 13:18:55 +0000 |
commit | 8ee1519364ae8ca01a0ae54d39c409f22aa91807 (patch) | |
tree | 406713bfa52751ea91cf7345f0e90f4fecf6f700 /lib/libcrypto | |
parent | 9089620136c952d88b124005c1182044101a80ba (diff) |
Rework handling of the out_kinv and out_r pointers
suggested by jsing
Diffstat (limited to 'lib/libcrypto')
-rw-r--r-- | lib/libcrypto/ecdsa/ecs_ossl.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/lib/libcrypto/ecdsa/ecs_ossl.c b/lib/libcrypto/ecdsa/ecs_ossl.c index 17d39cf36d9..b8a03447531 100644 --- a/lib/libcrypto/ecdsa/ecs_ossl.c +++ b/lib/libcrypto/ecdsa/ecs_ossl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecs_ossl.c,v 1.42 2023/07/02 13:05:29 tb Exp $ */ +/* $OpenBSD: ecs_ossl.c,v 1.43 2023/07/02 13:18:54 tb Exp $ */ /* * Written by Nils Larsch for the OpenSSL project */ @@ -130,6 +130,12 @@ ossl_ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *in_ctx, BIGNUM **out_kinv, const EC_GROUP *group; int order_bits, ret = 0; + BN_free(*out_kinv); + *out_kinv = NULL; + + BN_free(*out_r); + *out_r = NULL; + if (eckey == NULL || (group = EC_KEY_get0_group(eckey)) == NULL) { ECDSAerror(ERR_R_PASSED_NULL_PARAMETER); return 0; @@ -220,20 +226,21 @@ ossl_ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *in_ctx, BIGNUM **out_kinv, ECDSAerror(ERR_R_BN_LIB); goto err; } - BN_free(*out_r); - BN_free(*out_kinv); - *out_r = r; + *out_kinv = k; + k = NULL; + + *out_r = r; + r = NULL; + ret = 1; err: - if (ret == 0) { - BN_free(k); - BN_free(r); - } if (in_ctx == NULL) BN_CTX_free(ctx); BN_free(order); + BN_free(k); + BN_free(r); EC_POINT_free(point); BN_free(x); return (ret); |