From 53a919ddf8f4c663b3beca57c18dc025e1f71fa0 Mon Sep 17 00:00:00 2001 From: tb <> Date: Sun, 9 Mar 2025 15:33:35 +0000 Subject: Unexport EC_METHOD and all API using it This is an implementation detail and there is no reason to leak it from the library. This removes EC_GFp_{mont,simple}_method(), EC_GROUP_{method_of,new}(), EC_METHOD_get_field_type(), EC_POINT_method_of() from the public API. EC_GROUP_copy() is now quite useless, so it will go as well. ok jsing --- src/lib/libcrypto/Symbols.list | 6 ------ src/lib/libcrypto/ec/ec.h | 12 +----------- src/lib/libcrypto/ec/ec_lib.c | 27 +-------------------------- src/lib/libcrypto/ec/ec_local.h | 9 ++++++--- src/lib/libcrypto/ec/ecp_methods.c | 4 +--- src/lib/libcrypto/hidden/openssl/ec.h | 8 +------- 6 files changed, 10 insertions(+), 56 deletions(-) (limited to 'src') diff --git a/src/lib/libcrypto/Symbols.list b/src/lib/libcrypto/Symbols.list index cae2ac924d..647dfa6065 100644 --- a/src/lib/libcrypto/Symbols.list +++ b/src/lib/libcrypto/Symbols.list @@ -861,8 +861,6 @@ ECPKParameters_print_fp ECParameters_dup ECParameters_print ECParameters_print_fp -EC_GFp_mont_method -EC_GFp_simple_method EC_GROUP_check EC_GROUP_check_discriminant EC_GROUP_clear_free @@ -883,8 +881,6 @@ EC_GROUP_get_order EC_GROUP_get_point_conversion_form EC_GROUP_get_seed_len EC_GROUP_have_precompute_mult -EC_GROUP_method_of -EC_GROUP_new EC_GROUP_new_by_curve_name EC_GROUP_new_curve_GFp EC_GROUP_order_bits @@ -942,7 +938,6 @@ EC_KEY_set_private_key EC_KEY_set_public_key EC_KEY_set_public_key_affine_coordinates EC_KEY_up_ref -EC_METHOD_get_field_type EC_POINT_add EC_POINT_bn2point EC_POINT_clear_free @@ -959,7 +954,6 @@ EC_POINT_invert EC_POINT_is_at_infinity EC_POINT_is_on_curve EC_POINT_make_affine -EC_POINT_method_of EC_POINT_mul EC_POINT_new EC_POINT_oct2point diff --git a/src/lib/libcrypto/ec/ec.h b/src/lib/libcrypto/ec/ec.h index dd06dcb8b4..0229a4bf41 100644 --- a/src/lib/libcrypto/ec/ec.h +++ b/src/lib/libcrypto/ec/ec.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ec.h,v 1.49 2025/01/25 17:59:44 tb Exp $ */ +/* $OpenBSD: ec.h,v 1.50 2025/03/09 15:33:35 tb Exp $ */ /* * Originally written by Bodo Moeller for the OpenSSL project. */ @@ -95,23 +95,15 @@ typedef enum { POINT_CONVERSION_HYBRID = 6 } point_conversion_form_t; -typedef struct ec_method_st EC_METHOD; typedef struct ec_group_st EC_GROUP; typedef struct ec_point_st EC_POINT; -const EC_METHOD *EC_GFp_simple_method(void); -const EC_METHOD *EC_GFp_mont_method(void); - -EC_GROUP *EC_GROUP_new(const EC_METHOD *meth); void EC_GROUP_free(EC_GROUP *group); void EC_GROUP_clear_free(EC_GROUP *group); int EC_GROUP_copy(EC_GROUP *dst, const EC_GROUP *src); EC_GROUP *EC_GROUP_dup(const EC_GROUP *src); -const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group); -int EC_METHOD_get_field_type(const EC_METHOD *meth); - int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator, const BIGNUM *order, const BIGNUM *cofactor); const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group); @@ -172,8 +164,6 @@ void EC_POINT_clear_free(EC_POINT *point); int EC_POINT_copy(EC_POINT *dst, const EC_POINT *src); EC_POINT *EC_POINT_dup(const EC_POINT *src, const EC_GROUP *group); -const EC_METHOD *EC_POINT_method_of(const EC_POINT *point); - int EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point); int EC_POINT_set_affine_coordinates(const EC_GROUP *group, EC_POINT *p, diff --git a/src/lib/libcrypto/ec/ec_lib.c b/src/lib/libcrypto/ec/ec_lib.c index a6259ed581..874c3f1d45 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.116 2025/01/25 13:13:57 tb Exp $ */ +/* $OpenBSD: ec_lib.c,v 1.117 2025/03/09 15:33:35 tb Exp $ */ /* * Originally written by Bodo Moeller for the OpenSSL project. */ @@ -117,7 +117,6 @@ EC_GROUP_new(const EC_METHOD *meth) return NULL; } -LCRYPTO_ALIAS(EC_GROUP_new); void EC_GROUP_free(EC_GROUP *group) @@ -1406,30 +1405,6 @@ EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, } LCRYPTO_ALIAS(EC_POINTs_mul); -const EC_METHOD * -EC_GROUP_method_of(const EC_GROUP *group) -{ - ECerror(ERR_R_DISABLED); - return NULL; -} -LCRYPTO_ALIAS(EC_GROUP_method_of); - -int -EC_METHOD_get_field_type(const EC_METHOD *meth) -{ - ECerror(ERR_R_DISABLED); - return NID_undef; -} -LCRYPTO_ALIAS(EC_METHOD_get_field_type); - -const EC_METHOD * -EC_POINT_method_of(const EC_POINT *point) -{ - ECerror(ERR_R_DISABLED); - return NULL; -} -LCRYPTO_ALIAS(EC_POINT_method_of); - int EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx_in) { diff --git a/src/lib/libcrypto/ec/ec_local.h b/src/lib/libcrypto/ec/ec_local.h index d1e3c1fa4a..9c188c0197 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.65 2025/01/25 13:15:21 tb Exp $ */ +/* $OpenBSD: ec_local.h,v 1.66 2025/03/09 15:33:35 tb Exp $ */ /* * Originally written by Bodo Moeller for the OpenSSL project. */ @@ -79,7 +79,7 @@ __BEGIN_HIDDEN_DECLS -struct ec_method_st { +typedef struct ec_method_st { int (*group_set_curve)(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); int (*group_get_curve)(const EC_GROUP *, BIGNUM *p, BIGNUM *a, @@ -124,7 +124,7 @@ struct ec_method_st { BN_CTX *); int (*field_decode)(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *); -} /* EC_METHOD */; +} EC_METHOD; struct ec_group_st { const EC_METHOD *meth; @@ -170,6 +170,9 @@ struct ec_point_st { int Z_is_one; /* enable optimized point arithmetics for special case */ } /* EC_POINT */; +const EC_METHOD *EC_GFp_simple_method(void); +const EC_METHOD *EC_GFp_mont_method(void); + /* Compute r = generator * m + point * n in non-constant time. */ int ec_wnaf_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *m, const EC_POINT *point, const BIGNUM *n, BN_CTX *ctx); diff --git a/src/lib/libcrypto/ec/ecp_methods.c b/src/lib/libcrypto/ec/ecp_methods.c index d1d0add538..544c2be4d4 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.43 2025/02/13 11:19:49 tb Exp $ */ +/* $OpenBSD: ecp_methods.c,v 1.44 2025/03/09 15:33:35 tb Exp $ */ /* Includes code written by Lenka Fibikova * for the OpenSSL project. * Includes code written by Bodo Moeller for the OpenSSL project. @@ -1299,7 +1299,6 @@ EC_GFp_simple_method(void) { return &ec_GFp_simple_method; } -LCRYPTO_ALIAS(EC_GFp_simple_method); static const EC_METHOD ec_GFp_mont_method = { .group_set_curve = ec_mont_group_set_curve, @@ -1325,4 +1324,3 @@ EC_GFp_mont_method(void) { return &ec_GFp_mont_method; } -LCRYPTO_ALIAS(EC_GFp_mont_method); diff --git a/src/lib/libcrypto/hidden/openssl/ec.h b/src/lib/libcrypto/hidden/openssl/ec.h index 0b64474c4b..8ffa017d2d 100644 --- a/src/lib/libcrypto/hidden/openssl/ec.h +++ b/src/lib/libcrypto/hidden/openssl/ec.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ec.h,v 1.7 2024/10/22 15:54:33 tb Exp $ */ +/* $OpenBSD: ec.h,v 1.8 2025/03/09 15:33:35 tb Exp $ */ /* * Copyright (c) 2023 Bob Beck * @@ -25,14 +25,9 @@ #endif #include "crypto_namespace.h" -LCRYPTO_USED(EC_GFp_simple_method); -LCRYPTO_USED(EC_GFp_mont_method); -LCRYPTO_USED(EC_GROUP_new); LCRYPTO_USED(EC_GROUP_free); LCRYPTO_USED(EC_GROUP_copy); LCRYPTO_USED(EC_GROUP_dup); -LCRYPTO_USED(EC_GROUP_method_of); -LCRYPTO_USED(EC_METHOD_get_field_type); LCRYPTO_USED(EC_GROUP_set_generator); LCRYPTO_USED(EC_GROUP_get0_generator); LCRYPTO_USED(EC_GROUP_get_order); @@ -62,7 +57,6 @@ LCRYPTO_USED(EC_POINT_new); LCRYPTO_USED(EC_POINT_free); LCRYPTO_USED(EC_POINT_copy); LCRYPTO_USED(EC_POINT_dup); -LCRYPTO_USED(EC_POINT_method_of); LCRYPTO_USED(EC_POINT_set_to_infinity); LCRYPTO_USED(EC_POINT_set_affine_coordinates); LCRYPTO_USED(EC_POINT_get_affine_coordinates); -- cgit v1.2.3-55-g6feb