diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2024-10-22 12:06:09 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2024-10-22 12:06:09 +0000 |
commit | 1e193eb198a289691fc5301492c1b6795a182390 (patch) | |
tree | 5cc041b56f826b45d1307c9ced38a4c83e1d8dc4 /lib/libcrypto/ec/ec_lib.c | |
parent | 84659c729cf5d1214b487c26d608f164c422dd54 (diff) |
Provide and use ec_group_get_field_type()
All internal uses of EC_METHOD_get_field_type() and EC_GROUP_method_of()
are chained together. Implement this as a single API call that takes a
group and use it throughout. Gets rid of another eyesore in this part of
the tree. Not that there will be a shortage of eyesores anytime soon...
ok jsing
Diffstat (limited to 'lib/libcrypto/ec/ec_lib.c')
-rw-r--r-- | lib/libcrypto/ec/ec_lib.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/libcrypto/ec/ec_lib.c b/lib/libcrypto/ec/ec_lib.c index 1918d0ba527..6da20266622 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.72 2024/10/19 08:29:40 tb Exp $ */ +/* $OpenBSD: ec_lib.c,v 1.73 2024/10/22 12:06:08 tb Exp $ */ /* * Originally written by Bodo Moeller for the OpenSSL project. */ @@ -219,6 +219,15 @@ EC_METHOD_get_field_type(const EC_METHOD *meth) } LCRYPTO_ALIAS(EC_METHOD_get_field_type); +int +ec_group_get_field_type(const EC_GROUP *group) +{ + if (group == NULL || group->meth == NULL) + return NID_undef; + + return group->meth->field_type; +} + /* * If there is a user-provided cofactor, sanity check and use it. Otherwise * try computing the cofactor from generator order n and field cardinality q. @@ -663,8 +672,7 @@ EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx) BN_CTX *ctx_new = NULL; /* compare the field types */ - if (EC_METHOD_get_field_type(EC_GROUP_method_of(a)) != - EC_METHOD_get_field_type(EC_GROUP_method_of(b))) + if (ec_group_get_field_type(a) != ec_group_get_field_type(b)) return 1; /* compare the curve name (if present in both) */ if (EC_GROUP_get_curve_name(a) && EC_GROUP_get_curve_name(b) && |