From 90c4ea11168e40751810b5d56e83de147872a6ed Mon Sep 17 00:00:00 2001 From: tb <> Date: Mon, 6 Jan 2025 14:29:33 +0000 Subject: Remove get_order_bits() and get_degree() methods The degree made some sense when EC2M was a thing in libcrypto. Fortunately that's not the case anymore. The order handler never made sense. ok jsing --- src/lib/libcrypto/ec/ec_lib.c | 16 +++------------- src/lib/libcrypto/ec/ec_local.h | 5 +---- src/lib/libcrypto/ec/ecp_methods.c | 12 +----------- 3 files changed, 5 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/lib/libcrypto/ec/ec_lib.c b/src/lib/libcrypto/ec/ec_lib.c index f97144ea91..3c5a7d5c34 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.100 2025/01/06 14:25:10 tb Exp $ */ +/* $OpenBSD: ec_lib.c,v 1.101 2025/01/06 14:29:33 tb Exp $ */ /* * Originally written by Bodo Moeller for the OpenSSL project. */ @@ -404,7 +404,7 @@ EC_GROUP_get0_order(const EC_GROUP *group) int EC_GROUP_order_bits(const EC_GROUP *group) { - return group->meth->group_order_bits(group); + return BN_num_bits(group->order); } LCRYPTO_ALIAS(EC_GROUP_order_bits); @@ -592,11 +592,7 @@ LCRYPTO_ALIAS(EC_GROUP_new_curve_GFp); int EC_GROUP_get_degree(const EC_GROUP *group) { - if (group->meth->group_get_degree == NULL) { - ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); - return 0; - } - return group->meth->group_get_degree(group); + return BN_num_bits(group->p); } LCRYPTO_ALIAS(EC_GROUP_get_degree); @@ -1385,9 +1381,3 @@ EC_GROUP_have_precompute_mult(const EC_GROUP *group) return 0; } LCRYPTO_ALIAS(EC_GROUP_have_precompute_mult); - -int -ec_group_simple_order_bits(const EC_GROUP *group) -{ - return BN_num_bits(group->order); -} diff --git a/src/lib/libcrypto/ec/ec_local.h b/src/lib/libcrypto/ec/ec_local.h index fad66eb4ec..1201f6ef39 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.50 2025/01/06 14:10:32 tb Exp $ */ +/* $OpenBSD: ec_local.h,v 1.51 2025/01/06 14:29:33 tb Exp $ */ /* * Originally written by Bodo Moeller for the OpenSSL project. */ @@ -95,8 +95,6 @@ struct ec_method_st { int (*group_get_curve)(const EC_GROUP *, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *); - int (*group_get_degree)(const EC_GROUP *); - int (*group_order_bits)(const EC_GROUP *); int (*group_check_discriminant)(const EC_GROUP *, BN_CTX *); int (*point_set_affine_coordinates)(const EC_GROUP *, EC_POINT *, @@ -201,7 +199,6 @@ struct ec_point_st { int ec_wnaf_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *m, const EC_POINT *point, const BIGNUM *n, BN_CTX *ctx); -int ec_group_simple_order_bits(const EC_GROUP *group); int ec_group_is_builtin_curve(const EC_GROUP *group, int *out_nid); int ec_group_get_field_type(const EC_GROUP *group); diff --git a/src/lib/libcrypto/ec/ecp_methods.c b/src/lib/libcrypto/ec/ecp_methods.c index 042db054a8..d68022f5e6 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.23 2025/01/06 14:22:55 tb Exp $ */ +/* $OpenBSD: ecp_methods.c,v 1.24 2025/01/06 14:29:33 tb Exp $ */ /* Includes code written by Lenka Fibikova * for the OpenSSL project. * Includes code written by Bodo Moeller for the OpenSSL project. @@ -166,12 +166,6 @@ ec_group_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, return 1; } -static int -ec_group_get_degree(const EC_GROUP *group) -{ - return BN_num_bits(group->p); -} - static int ec_group_check_discriminant(const EC_GROUP *group, BN_CTX *ctx) { @@ -1520,8 +1514,6 @@ static const EC_METHOD ec_GFp_simple_method = { .field_type = NID_X9_62_prime_field, .group_set_curve = ec_group_set_curve, .group_get_curve = ec_group_get_curve, - .group_get_degree = ec_group_get_degree, - .group_order_bits = ec_group_simple_order_bits, .group_check_discriminant = ec_group_check_discriminant, .point_set_affine_coordinates = ec_point_set_affine_coordinates, .point_get_affine_coordinates = ec_point_get_affine_coordinates, @@ -1551,8 +1543,6 @@ static const EC_METHOD ec_GFp_mont_method = { .field_type = NID_X9_62_prime_field, .group_set_curve = ec_mont_group_set_curve, .group_get_curve = ec_group_get_curve, - .group_get_degree = ec_group_get_degree, - .group_order_bits = ec_group_simple_order_bits, .group_check_discriminant = ec_group_check_discriminant, .point_set_affine_coordinates = ec_point_set_affine_coordinates, .point_get_affine_coordinates = ec_point_get_affine_coordinates, -- cgit v1.2.3-55-g6feb