From c11f785522f27114af2285067053266fdb327ba0 Mon Sep 17 00:00:00 2001 From: jsing Date: Tue, 7 Mar 2023 09:27:10 +0000 Subject: [PATCH] Call BN_free() instead of BN_clear_free(). BN_clear_free() is a wrapper that calls BN_free() - call BN_free() directly instead. ok tb@ --- lib/libcrypto/bn/bn_blind.c | 10 +++++----- lib/libcrypto/bn/bn_sqrt.c | 4 ++-- lib/libcrypto/dh/dh_lib.c | 16 ++++++++-------- lib/libcrypto/dsa/dsa_asn1.c | 6 +++--- lib/libcrypto/dsa/dsa_lib.c | 16 ++++++++-------- lib/libcrypto/ec/ec2_smpl.c | 14 +++++++------- lib/libcrypto/ec/ec_key.c | 4 ++-- lib/libcrypto/ec/ec_lib.c | 6 +++--- lib/libcrypto/ec/ec_print.c | 4 ++-- lib/libcrypto/ec/ecp_smpl.c | 16 ++++++++-------- lib/libcrypto/ecdsa/ecs_asn1.c | 6 +++--- lib/libcrypto/ecdsa/ecs_lib.c | 4 ++-- lib/libcrypto/ecdsa/ecs_ossl.c | 24 ++++++++++++------------ lib/libcrypto/gost/gostr341001_key.c | 10 +++++----- lib/libcrypto/rsa/rsa_lib.c | 18 +++++++++--------- 15 files changed, 79 insertions(+), 79 deletions(-) diff --git a/lib/libcrypto/bn/bn_blind.c b/lib/libcrypto/bn/bn_blind.c index fbcdf1c6e7f..61d0cf7a951 100644 --- a/lib/libcrypto/bn/bn_blind.c +++ b/lib/libcrypto/bn/bn_blind.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_blind.c,v 1.19 2022/11/26 16:08:51 tb Exp $ */ +/* $OpenBSD: bn_blind.c,v 1.20 2023/03/07 09:27:10 jsing Exp $ */ /* ==================================================================== * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. * @@ -180,10 +180,10 @@ BN_BLINDING_free(BN_BLINDING *r) if (r == NULL) return; - BN_clear_free(r->A); - BN_clear_free(r->Ai); - BN_clear_free(r->e); - BN_clear_free(r->mod); + BN_free(r->A); + BN_free(r->Ai); + BN_free(r->e); + BN_free(r->mod); free(r); } diff --git a/lib/libcrypto/bn/bn_sqrt.c b/lib/libcrypto/bn/bn_sqrt.c index 652dc2b5fcc..9bbca4267a4 100644 --- a/lib/libcrypto/bn/bn_sqrt.c +++ b/lib/libcrypto/bn/bn_sqrt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_sqrt.c,v 1.14 2022/11/26 16:08:51 tb Exp $ */ +/* $OpenBSD: bn_sqrt.c,v 1.15 2023/03/07 09:27:10 jsing Exp $ */ /* Written by Lenka Fibikova * and Bodo Moeller for the OpenSSL project. */ /* ==================================================================== @@ -400,7 +400,7 @@ vrfy: end: if (err) { if (ret != NULL && ret != in) { - BN_clear_free(ret); + BN_free(ret); } ret = NULL; } diff --git a/lib/libcrypto/dh/dh_lib.c b/lib/libcrypto/dh/dh_lib.c index 35a22d1ec82..e5cb46485de 100644 --- a/lib/libcrypto/dh/dh_lib.c +++ b/lib/libcrypto/dh/dh_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dh_lib.c,v 1.37 2022/06/27 12:31:38 tb Exp $ */ +/* $OpenBSD: dh_lib.c,v 1.38 2023/03/07 09:27:10 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -194,14 +194,14 @@ DH_free(DH *r) CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DH, r, &r->ex_data); - BN_clear_free(r->p); - BN_clear_free(r->g); - BN_clear_free(r->q); - BN_clear_free(r->j); + BN_free(r->p); + BN_free(r->g); + BN_free(r->q); + BN_free(r->j); free(r->seed); - BN_clear_free(r->counter); - BN_clear_free(r->pub_key); - BN_clear_free(r->priv_key); + BN_free(r->counter); + BN_free(r->pub_key); + BN_free(r->priv_key); free(r); } diff --git a/lib/libcrypto/dsa/dsa_asn1.c b/lib/libcrypto/dsa/dsa_asn1.c index 976b34a73a6..f6c66cecde3 100644 --- a/lib/libcrypto/dsa/dsa_asn1.c +++ b/lib/libcrypto/dsa/dsa_asn1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsa_asn1.c,v 1.28 2022/11/26 16:08:52 tb Exp $ */ +/* $OpenBSD: dsa_asn1.c,v 1.29 2023/03/07 09:27:10 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -147,9 +147,9 @@ DSA_SIG_set0(DSA_SIG *sig, BIGNUM *r, BIGNUM *s) if (r == NULL || s == NULL) return 0; - BN_clear_free(sig->r); + BN_free(sig->r); sig->r = r; - BN_clear_free(sig->s); + BN_free(sig->s); sig->s = s; return 1; diff --git a/lib/libcrypto/dsa/dsa_lib.c b/lib/libcrypto/dsa/dsa_lib.c index 38f0b071ec5..1a6ca54da12 100644 --- a/lib/libcrypto/dsa/dsa_lib.c +++ b/lib/libcrypto/dsa/dsa_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsa_lib.c,v 1.40 2023/03/04 20:54:52 tb Exp $ */ +/* $OpenBSD: dsa_lib.c,v 1.41 2023/03/07 09:27:10 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -200,13 +200,13 @@ DSA_free(DSA *r) CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DSA, r, &r->ex_data); - BN_clear_free(r->p); - BN_clear_free(r->q); - BN_clear_free(r->g); - BN_clear_free(r->pub_key); - BN_clear_free(r->priv_key); - BN_clear_free(r->kinv); - BN_clear_free(r->r); + BN_free(r->p); + BN_free(r->q); + BN_free(r->g); + BN_free(r->pub_key); + BN_free(r->priv_key); + BN_free(r->kinv); + BN_free(r->r); free(r); } diff --git a/lib/libcrypto/ec/ec2_smpl.c b/lib/libcrypto/ec/ec2_smpl.c index 910484fc65c..c7ea0d97650 100644 --- a/lib/libcrypto/ec/ec2_smpl.c +++ b/lib/libcrypto/ec/ec2_smpl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec2_smpl.c,v 1.30 2023/03/07 05:50:59 jsing Exp $ */ +/* $OpenBSD: ec2_smpl.c,v 1.31 2023/03/07 09:27:10 jsing Exp $ */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * @@ -107,9 +107,9 @@ ec_GF2m_simple_group_finish(EC_GROUP *group) static void ec_GF2m_simple_group_clear_finish(EC_GROUP *group) { - BN_clear_free(&group->field); - BN_clear_free(&group->a); - BN_clear_free(&group->b); + BN_free(&group->field); + BN_free(&group->a); + BN_free(&group->b); group->poly[0] = 0; group->poly[1] = 0; group->poly[2] = 0; @@ -285,9 +285,9 @@ ec_GF2m_simple_point_finish(EC_POINT *point) static void ec_GF2m_simple_point_clear_finish(EC_POINT *point) { - BN_clear_free(&point->X); - BN_clear_free(&point->Y); - BN_clear_free(&point->Z); + BN_free(&point->X); + BN_free(&point->Y); + BN_free(&point->Z); point->Z_is_one = 0; } diff --git a/lib/libcrypto/ec/ec_key.c b/lib/libcrypto/ec/ec_key.c index 2ef5d75d474..3799498ab1c 100644 --- a/lib/libcrypto/ec/ec_key.c +++ b/lib/libcrypto/ec/ec_key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_key.c,v 1.30 2023/01/14 15:10:45 jsing Exp $ */ +/* $OpenBSD: ec_key.c,v 1.31 2023/03/07 09:27:10 jsing Exp $ */ /* * Written by Nils Larsch for the OpenSSL project. */ @@ -120,7 +120,7 @@ EC_KEY_free(EC_KEY *r) EC_GROUP_free(r->group); EC_POINT_free(r->pub_key); - BN_clear_free(r->priv_key); + BN_free(r->priv_key); EC_EX_DATA_free_all_data(&r->method_data); diff --git a/lib/libcrypto/ec/ec_lib.c b/lib/libcrypto/ec/ec_lib.c index 2a99f8d4907..0e863ddfef5 100644 --- a/lib/libcrypto/ec/ec_lib.c +++ b/lib/libcrypto/ec/ec_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_lib.c,v 1.48 2023/02/07 09:00:48 tb Exp $ */ +/* $OpenBSD: ec_lib.c,v 1.49 2023/03/07 09:27:10 jsing Exp $ */ /* * Originally written by Bodo Moeller for the OpenSSL project. */ @@ -149,8 +149,8 @@ EC_GROUP_clear_free(EC_GROUP *group) EC_EX_DATA_clear_free_all_data(&group->extra_data); EC_POINT_clear_free(group->generator); - BN_clear_free(&group->order); - BN_clear_free(&group->cofactor); + BN_free(&group->order); + BN_free(&group->cofactor); freezero(group->seed, group->seed_len); freezero(group, sizeof *group); diff --git a/lib/libcrypto/ec/ec_print.c b/lib/libcrypto/ec/ec_print.c index 1b85e824366..faa212f5021 100644 --- a/lib/libcrypto/ec/ec_print.c +++ b/lib/libcrypto/ec/ec_print.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_print.c,v 1.9 2022/11/26 16:08:52 tb Exp $ */ +/* $OpenBSD: ec_print.c,v 1.10 2023/03/07 09:27:10 jsing Exp $ */ /* ==================================================================== * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. * @@ -172,7 +172,7 @@ EC_POINT_hex2point(const EC_GROUP *group, const char *buf, ret = EC_POINT_bn2point(group, tmp_bn, point, ctx); - BN_clear_free(tmp_bn); + BN_free(tmp_bn); return ret; } diff --git a/lib/libcrypto/ec/ecp_smpl.c b/lib/libcrypto/ec/ecp_smpl.c index 8f53b150b8c..df9806445c5 100644 --- a/lib/libcrypto/ec/ecp_smpl.c +++ b/lib/libcrypto/ec/ecp_smpl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecp_smpl.c,v 1.39 2023/03/07 05:54:40 jsing Exp $ */ +/* $OpenBSD: ecp_smpl.c,v 1.40 2023/03/07 09:27:10 jsing Exp $ */ /* Includes code written by Lenka Fibikova * for the OpenSSL project. * Includes code written by Bodo Moeller for the OpenSSL project. @@ -102,9 +102,9 @@ ec_GFp_simple_group_finish(EC_GROUP *group) void ec_GFp_simple_group_clear_finish(EC_GROUP *group) { - BN_clear_free(&group->field); - BN_clear_free(&group->a); - BN_clear_free(&group->b); + BN_free(&group->field); + BN_free(&group->a); + BN_free(&group->b); } int @@ -324,9 +324,9 @@ ec_GFp_simple_point_finish(EC_POINT *point) void ec_GFp_simple_point_clear_finish(EC_POINT *point) { - BN_clear_free(&point->X); - BN_clear_free(&point->Y); - BN_clear_free(&point->Z); + BN_free(&point->X); + BN_free(&point->Y); + BN_free(&point->Z); point->Z_is_one = 0; } @@ -1324,7 +1324,7 @@ ec_GFp_simple_points_make_affine(const EC_GROUP *group, size_t num, EC_POINT *po * locally! */ for (i = pow2 / 2 - 1; i > 0; i--) { - BN_clear_free(heap[i]); + BN_free(heap[i]); } free(heap); } diff --git a/lib/libcrypto/ecdsa/ecs_asn1.c b/lib/libcrypto/ecdsa/ecs_asn1.c index 9e286138e80..9db114a2d18 100644 --- a/lib/libcrypto/ecdsa/ecs_asn1.c +++ b/lib/libcrypto/ecdsa/ecs_asn1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecs_asn1.c,v 1.12 2022/11/26 16:08:52 tb Exp $ */ +/* $OpenBSD: ecs_asn1.c,v 1.13 2023/03/07 09:27:10 jsing Exp $ */ /* ==================================================================== * Copyright (c) 2000-2002 The OpenSSL Project. All rights reserved. * @@ -141,8 +141,8 @@ ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s) if (r == NULL || s == NULL) return 0; - BN_clear_free(sig->r); - BN_clear_free(sig->s); + BN_free(sig->r); + BN_free(sig->s); sig->r = r; sig->s = s; return 1; diff --git a/lib/libcrypto/ecdsa/ecs_lib.c b/lib/libcrypto/ecdsa/ecs_lib.c index 5e95c5ed605..5c44c793eda 100644 --- a/lib/libcrypto/ecdsa/ecs_lib.c +++ b/lib/libcrypto/ecdsa/ecs_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecs_lib.c,v 1.15 2022/11/26 16:08:52 tb Exp $ */ +/* $OpenBSD: ecs_lib.c,v 1.16 2023/03/07 09:27:10 jsing Exp $ */ /* ==================================================================== * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved. * @@ -221,7 +221,7 @@ ECDSA_size(const EC_KEY *r) ret = 0; err: - BN_clear_free(order); + BN_free(order); return ret; } diff --git a/lib/libcrypto/ecdsa/ecs_ossl.c b/lib/libcrypto/ecdsa/ecs_ossl.c index f169b06bd5d..271c8435f8a 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.28 2023/03/04 21:39:34 tb Exp $ */ +/* $OpenBSD: ecs_ossl.c,v 1.29 2023/03/07 09:27:10 jsing Exp $ */ /* * Written by Nils Larsch for the OpenSSL project */ @@ -230,22 +230,22 @@ ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) ECDSAerror(ERR_R_BN_LIB); goto err; } - BN_clear_free(*rp); - BN_clear_free(*kinvp); + BN_free(*rp); + BN_free(*kinvp); *rp = r; *kinvp = k; ret = 1; err: if (ret == 0) { - BN_clear_free(k); - BN_clear_free(r); + BN_free(k); + BN_free(r); } if (ctx_in == NULL) BN_CTX_free(ctx); BN_free(order); EC_POINT_free(point); - BN_clear_free(X); + BN_free(X); return (ret); } @@ -412,12 +412,12 @@ ecdsa_do_sign(const unsigned char *dgst, int dgst_len, ret = NULL; } BN_CTX_free(ctx); - BN_clear_free(b); - BN_clear_free(binv); - BN_clear_free(bm); - BN_clear_free(bxr); - BN_clear_free(kinv); - BN_clear_free(m); + BN_free(b); + BN_free(binv); + BN_free(bm); + BN_free(bxr); + BN_free(kinv); + BN_free(m); BN_free(order); BN_free(range); return ret; diff --git a/lib/libcrypto/gost/gostr341001_key.c b/lib/libcrypto/gost/gostr341001_key.c index e44c48622c7..62694318d58 100644 --- a/lib/libcrypto/gost/gostr341001_key.c +++ b/lib/libcrypto/gost/gostr341001_key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gostr341001_key.c,v 1.11 2023/01/15 13:58:44 tb Exp $ */ +/* $OpenBSD: gostr341001_key.c,v 1.12 2023/03/07 09:27:10 jsing Exp $ */ /* * Copyright (c) 2014 Dmitry Eremin-Solenikov * Copyright (c) 2005-2006 Cryptocom LTD @@ -103,7 +103,7 @@ GOST_KEY_free(GOST_KEY *r) EC_GROUP_free(r->group); EC_POINT_free(r->pub_key); - BN_clear_free(r->priv_key); + BN_free(r->priv_key); freezero(r, sizeof(GOST_KEY)); } @@ -256,7 +256,7 @@ GOST_KEY_get0_private_key(const GOST_KEY *key) int GOST_KEY_set_private_key(GOST_KEY *key, const BIGNUM *priv_key) { - BN_clear_free(key->priv_key); + BN_free(key->priv_key); key->priv_key = BN_dup(priv_key); return (key->priv_key == NULL) ? 0 : 1; } @@ -310,12 +310,12 @@ GOST_KEY_get_size(const GOST_KEY *r) return 0; if (EC_GROUP_get_order(group, order, NULL) == 0) { - BN_clear_free(order); + BN_free(order); return 0; } i = BN_num_bytes(order); - BN_clear_free(order); + BN_free(order); return (i); } #endif diff --git a/lib/libcrypto/rsa/rsa_lib.c b/lib/libcrypto/rsa/rsa_lib.c index 17204849525..3689c0b54d1 100644 --- a/lib/libcrypto/rsa/rsa_lib.c +++ b/lib/libcrypto/rsa/rsa_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsa_lib.c,v 1.44 2022/11/26 16:08:54 tb Exp $ */ +/* $OpenBSD: rsa_lib.c,v 1.45 2023/03/07 09:27:10 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -200,14 +200,14 @@ RSA_free(RSA *r) CRYPTO_free_ex_data(CRYPTO_EX_INDEX_RSA, r, &r->ex_data); - BN_clear_free(r->n); - BN_clear_free(r->e); - BN_clear_free(r->d); - BN_clear_free(r->p); - BN_clear_free(r->q); - BN_clear_free(r->dmp1); - BN_clear_free(r->dmq1); - BN_clear_free(r->iqmp); + BN_free(r->n); + BN_free(r->e); + BN_free(r->d); + BN_free(r->p); + BN_free(r->q); + BN_free(r->dmp1); + BN_free(r->dmq1); + BN_free(r->iqmp); BN_BLINDING_free(r->blinding); BN_BLINDING_free(r->mt_blinding); RSA_PSS_PARAMS_free(r->pss); -- 2.20.1