From 183ebcd147bfd493e4856f28b1ff4c9c6dbd0730 Mon Sep 17 00:00:00 2001 From: tb <> Date: Wed, 1 Jan 2025 09:57:02 +0000 Subject: Garbage collect .group_init() For both in-tree methods these are just complicated ways of zeroing part of the group object. The group is allocated with calloc(), so it's all entirely pointless. ok jsing --- src/lib/libcrypto/ec/ec_lib.c | 12 +----------- src/lib/libcrypto/ec/ec_local.h | 3 +-- src/lib/libcrypto/ec/ecp_methods.c | 25 +------------------------ 3 files changed, 3 insertions(+), 37 deletions(-) (limited to 'src/lib') diff --git a/src/lib/libcrypto/ec/ec_lib.c b/src/lib/libcrypto/ec/ec_lib.c index 6644c4dfc7..aeb627dfba 100644 --- a/src/lib/libcrypto/ec/ec_lib.c +++ b/src/lib/libcrypto/ec/ec_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_lib.c,v 1.91 2024/12/12 10:02:00 tb Exp $ */ +/* $OpenBSD: ec_lib.c,v 1.92 2025/01/01 09:57:02 tb Exp $ */ /* * Originally written by Bodo Moeller for the OpenSSL project. */ @@ -84,10 +84,6 @@ EC_GROUP_new(const EC_METHOD *meth) ECerror(EC_R_SLOT_FULL); goto err; } - if (meth->group_init == NULL) { - ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); - goto err; - } if ((group = calloc(1, sizeof(*group))) == NULL) { ECerror(ERR_R_MALLOC_FAILURE); goto err; @@ -95,15 +91,9 @@ EC_GROUP_new(const EC_METHOD *meth) group->meth = meth; - BN_init(&group->order); - BN_init(&group->cofactor); - group->asn1_flag = OPENSSL_EC_NAMED_CURVE; group->asn1_form = POINT_CONVERSION_UNCOMPRESSED; - if (!meth->group_init(group)) - goto err; - return group; err: diff --git a/src/lib/libcrypto/ec/ec_local.h b/src/lib/libcrypto/ec/ec_local.h index ea1cd7adad..bce3f31d4d 100644 --- a/src/lib/libcrypto/ec/ec_local.h +++ b/src/lib/libcrypto/ec/ec_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_local.h,v 1.43 2024/12/12 10:00:15 tb Exp $ */ +/* $OpenBSD: ec_local.h,v 1.44 2025/01/01 09:57:02 tb Exp $ */ /* * Originally written by Bodo Moeller for the OpenSSL project. */ @@ -88,7 +88,6 @@ __BEGIN_HIDDEN_DECLS struct ec_method_st { int field_type; - int (*group_init)(EC_GROUP *); void (*group_finish)(EC_GROUP *); int (*group_copy)(EC_GROUP *, const EC_GROUP *); diff --git a/src/lib/libcrypto/ec/ecp_methods.c b/src/lib/libcrypto/ec/ecp_methods.c index 591d895c58..333922d351 100644 --- a/src/lib/libcrypto/ec/ecp_methods.c +++ b/src/lib/libcrypto/ec/ecp_methods.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecp_methods.c,v 1.15 2025/01/01 09:31:05 tb Exp $ */ +/* $OpenBSD: ecp_methods.c,v 1.16 2025/01/01 09:57:02 tb Exp $ */ /* Includes code written by Lenka Fibikova * for the OpenSSL project. * Includes code written by Bodo Moeller for the OpenSSL project. @@ -84,16 +84,6 @@ * representation (i.e. 'encoding' means multiplying by some factor R). */ -static int -ec_group_init(EC_GROUP *group) -{ - BN_init(&group->p); - BN_init(&group->a); - BN_init(&group->b); - group->a_is_minus3 = 0; - return 1; -} - static void ec_group_finish(EC_GROUP *group) { @@ -1536,17 +1526,6 @@ ec_mont_group_clear(EC_GROUP *group) group->mont_one = NULL; } -static int -ec_mont_group_init(EC_GROUP *group) -{ - int ok; - - ok = ec_group_init(group); - group->mont_ctx = NULL; - group->mont_one = NULL; - return ok; -} - static void ec_mont_group_finish(EC_GROUP *group) { @@ -1682,7 +1661,6 @@ ec_mont_field_set_to_one(const EC_GROUP *group, BIGNUM *r, BN_CTX *ctx) static const EC_METHOD ec_GFp_simple_method = { .field_type = NID_X9_62_prime_field, - .group_init = ec_group_init, .group_finish = ec_group_finish, .group_copy = ec_group_copy, .group_set_curve = ec_group_set_curve, @@ -1719,7 +1697,6 @@ LCRYPTO_ALIAS(EC_GFp_simple_method); static const EC_METHOD ec_GFp_mont_method = { .field_type = NID_X9_62_prime_field, - .group_init = ec_mont_group_init, .group_finish = ec_mont_group_finish, .group_copy = ec_mont_group_copy, .group_set_curve = ec_mont_group_set_curve, -- cgit v1.2.3-55-g6feb