summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/libcrypto/ec/ec2_smpl.c7
-rw-r--r--lib/libcrypto/ec/ec_local.h12
-rw-r--r--lib/libcrypto/ec/ec_oct.c66
-rw-r--r--lib/libcrypto/ec/ecp_mont.c7
-rw-r--r--lib/libcrypto/ec/ecp_nist.c7
-rw-r--r--lib/libcrypto/ec/ecp_smpl.c7
6 files changed, 27 insertions, 79 deletions
diff --git a/lib/libcrypto/ec/ec2_smpl.c b/lib/libcrypto/ec/ec2_smpl.c
index c7ea0d97650..f995ff87181 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.31 2023/03/07 09:27:10 jsing Exp $ */
+/* $OpenBSD: ec2_smpl.c,v 1.32 2023/03/08 04:50:27 jsing Exp $ */
/* ====================================================================
* Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
*
@@ -724,7 +724,6 @@ ec_GF2m_simple_field_div(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a,
}
static const EC_METHOD ec_GF2m_simple_method = {
- .flags = EC_FLAGS_DEFAULT_OCT,
.field_type = NID_X9_62_characteristic_two_field,
.group_init = ec_GF2m_simple_group_init,
.group_finish = ec_GF2m_simple_group_finish,
@@ -744,6 +743,10 @@ static const EC_METHOD ec_GF2m_simple_method = {
ec_GF2m_simple_point_set_affine_coordinates,
.point_get_affine_coordinates =
ec_GF2m_simple_point_get_affine_coordinates,
+ .point_set_compressed_coordinates =
+ ec_GF2m_simple_set_compressed_coordinates,
+ .point2oct = ec_GF2m_simple_point2oct,
+ .oct2point = ec_GF2m_simple_oct2point,
.add = ec_GF2m_simple_add,
.dbl = ec_GF2m_simple_dbl,
.invert = ec_GF2m_simple_invert,
diff --git a/lib/libcrypto/ec/ec_local.h b/lib/libcrypto/ec/ec_local.h
index a1d7c9d3f2f..d4cb777c837 100644
--- a/lib/libcrypto/ec/ec_local.h
+++ b/lib/libcrypto/ec/ec_local.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ec_local.h,v 1.9 2023/03/07 05:50:59 jsing Exp $ */
+/* $OpenBSD: ec_local.h,v 1.10 2023/03/08 04:50:27 jsing Exp $ */
/*
* Originally written by Bodo Moeller for the OpenSSL project.
*/
@@ -86,17 +86,7 @@ __BEGIN_HIDDEN_DECLS
# endif
#endif
-/* Use default functions for poin2oct, oct2point and compressed coordinates */
-#define EC_FLAGS_DEFAULT_OCT 0x1
-
struct ec_method_st {
-
- /*
- * Methods and members exposed directly by the public API.
- */
-
- int flags;
-
int field_type;
int (*group_init)(EC_GROUP *);
diff --git a/lib/libcrypto/ec/ec_oct.c b/lib/libcrypto/ec/ec_oct.c
index 0e651991fd1..ef17ec59a59 100644
--- a/lib/libcrypto/ec/ec_oct.c
+++ b/lib/libcrypto/ec/ec_oct.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ec_oct.c,v 1.9 2022/11/26 16:08:52 tb Exp $ */
+/* $OpenBSD: ec_oct.c,v 1.10 2023/03/08 04:50:27 jsing Exp $ */
/*
* Originally written by Bodo Moeller for the OpenSSL project.
*/
@@ -74,8 +74,7 @@ int
EC_POINT_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *point,
const BIGNUM *x, int y_bit, BN_CTX *ctx)
{
- if (group->meth->point_set_compressed_coordinates == NULL &&
- !(group->meth->flags & EC_FLAGS_DEFAULT_OCT)) {
+ if (group->meth->point_set_compressed_coordinates == NULL) {
ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
return 0;
}
@@ -83,29 +82,8 @@ EC_POINT_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *point,
ECerror(EC_R_INCOMPATIBLE_OBJECTS);
return 0;
}
- if (group->meth->flags & EC_FLAGS_DEFAULT_OCT) {
- if (group->meth->field_type == NID_X9_62_prime_field)
- return ec_GFp_simple_set_compressed_coordinates(
- group, point, x, y_bit, ctx);
- else
-#ifdef OPENSSL_NO_EC2M
- {
- ECerror(EC_R_GF2M_NOT_SUPPORTED);
- return 0;
- }
-#else
- return ec_GF2m_simple_set_compressed_coordinates(
- group, point, x, y_bit, ctx);
-#endif
- }
- if (!group->meth->point_set_compressed_coordinates(group, point, x,
- y_bit, ctx))
- return 0;
- if (EC_POINT_is_on_curve(group, point, ctx) <= 0) {
- ECerror(EC_R_POINT_IS_NOT_ON_CURVE);
- return 0;
- }
- return 1;
+ return group->meth->point_set_compressed_coordinates(group, point,
+ x, y_bit, ctx);
}
int
@@ -129,8 +107,7 @@ EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *point,
point_conversion_form_t form,
unsigned char *buf, size_t len, BN_CTX *ctx)
{
- if (group->meth->point2oct == 0
- && !(group->meth->flags & EC_FLAGS_DEFAULT_OCT)) {
+ if (group->meth->point2oct == NULL) {
ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
return 0;
}
@@ -138,21 +115,6 @@ EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *point,
ECerror(EC_R_INCOMPATIBLE_OBJECTS);
return 0;
}
- if (group->meth->flags & EC_FLAGS_DEFAULT_OCT) {
- if (group->meth->field_type == NID_X9_62_prime_field)
- return ec_GFp_simple_point2oct(group, point,
- form, buf, len, ctx);
- else
-#ifdef OPENSSL_NO_EC2M
- {
- ECerror(EC_R_GF2M_NOT_SUPPORTED);
- return 0;
- }
-#else
- return ec_GF2m_simple_point2oct(group, point,
- form, buf, len, ctx);
-#endif
- }
return group->meth->point2oct(group, point, form, buf, len, ctx);
}
@@ -160,8 +122,7 @@ int
EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *point,
const unsigned char *buf, size_t len, BN_CTX *ctx)
{
- if (group->meth->oct2point == 0 &&
- !(group->meth->flags & EC_FLAGS_DEFAULT_OCT)) {
+ if (group->meth->oct2point == NULL) {
ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
return 0;
}
@@ -169,20 +130,5 @@ EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *point,
ECerror(EC_R_INCOMPATIBLE_OBJECTS);
return 0;
}
- if (group->meth->flags & EC_FLAGS_DEFAULT_OCT) {
- if (group->meth->field_type == NID_X9_62_prime_field)
- return ec_GFp_simple_oct2point(group, point,
- buf, len, ctx);
- else
-#ifdef OPENSSL_NO_EC2M
- {
- ECerror(EC_R_GF2M_NOT_SUPPORTED);
- return 0;
- }
-#else
- return ec_GF2m_simple_oct2point(group, point,
- buf, len, ctx);
-#endif
- }
return group->meth->oct2point(group, point, buf, len, ctx);
}
diff --git a/lib/libcrypto/ec/ecp_mont.c b/lib/libcrypto/ec/ecp_mont.c
index f26107c20b9..d0d497b0114 100644
--- a/lib/libcrypto/ec/ecp_mont.c
+++ b/lib/libcrypto/ec/ecp_mont.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ecp_mont.c,v 1.25 2023/03/07 05:41:18 jsing Exp $ */
+/* $OpenBSD: ecp_mont.c,v 1.26 2023/03/08 04:50:27 jsing Exp $ */
/*
* Originally written by Bodo Moeller for the OpenSSL project.
*/
@@ -233,7 +233,6 @@ ec_GFp_mont_field_set_to_one(const EC_GROUP *group, BIGNUM *r, BN_CTX *ctx)
}
static const EC_METHOD ec_GFp_mont_method = {
- .flags = EC_FLAGS_DEFAULT_OCT,
.field_type = NID_X9_62_prime_field,
.group_init = ec_GFp_mont_group_init,
.group_finish = ec_GFp_mont_group_finish,
@@ -257,6 +256,10 @@ static const EC_METHOD ec_GFp_mont_method = {
ec_GFp_simple_point_set_affine_coordinates,
.point_get_affine_coordinates =
ec_GFp_simple_point_get_affine_coordinates,
+ .point_set_compressed_coordinates =
+ ec_GFp_simple_set_compressed_coordinates,
+ .point2oct = ec_GFp_simple_point2oct,
+ .oct2point = ec_GFp_simple_oct2point,
.add = ec_GFp_simple_add,
.dbl = ec_GFp_simple_dbl,
.invert = ec_GFp_simple_invert,
diff --git a/lib/libcrypto/ec/ecp_nist.c b/lib/libcrypto/ec/ecp_nist.c
index 3a81a0e8d9b..e3c13f7c65f 100644
--- a/lib/libcrypto/ec/ecp_nist.c
+++ b/lib/libcrypto/ec/ecp_nist.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ecp_nist.c,v 1.22 2023/03/07 05:45:14 jsing Exp $ */
+/* $OpenBSD: ecp_nist.c,v 1.23 2023/03/08 04:50:27 jsing Exp $ */
/*
* Written by Nils Larsch for the OpenSSL project.
*/
@@ -168,7 +168,6 @@ ec_GFp_nist_field_sqr(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a,
}
static const EC_METHOD ec_GFp_nist_method = {
- .flags = EC_FLAGS_DEFAULT_OCT,
.field_type = NID_X9_62_prime_field,
.group_init = ec_GFp_simple_group_init,
.group_finish = ec_GFp_simple_group_finish,
@@ -192,6 +191,10 @@ static const EC_METHOD ec_GFp_nist_method = {
ec_GFp_simple_point_set_affine_coordinates,
.point_get_affine_coordinates =
ec_GFp_simple_point_get_affine_coordinates,
+ .point_set_compressed_coordinates =
+ ec_GFp_simple_set_compressed_coordinates,
+ .point2oct = ec_GFp_simple_point2oct,
+ .oct2point = ec_GFp_simple_oct2point,
.add = ec_GFp_simple_add,
.dbl = ec_GFp_simple_dbl,
.invert = ec_GFp_simple_invert,
diff --git a/lib/libcrypto/ec/ecp_smpl.c b/lib/libcrypto/ec/ecp_smpl.c
index df9806445c5..c33347ad857 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.40 2023/03/07 09:27:10 jsing Exp $ */
+/* $OpenBSD: ecp_smpl.c,v 1.41 2023/03/08 04:50:27 jsing Exp $ */
/* Includes code written by Lenka Fibikova <fibikova@exp-math.uni-essen.de>
* for the OpenSSL project.
* Includes code written by Bodo Moeller for the OpenSSL project.
@@ -1654,7 +1654,6 @@ ec_GFp_simple_mul_double_nonct(const EC_GROUP *group, EC_POINT *r,
}
static const EC_METHOD ec_GFp_simple_method = {
- .flags = EC_FLAGS_DEFAULT_OCT,
.field_type = NID_X9_62_prime_field,
.group_init = ec_GFp_simple_group_init,
.group_finish = ec_GFp_simple_group_finish,
@@ -1678,6 +1677,10 @@ static const EC_METHOD ec_GFp_simple_method = {
ec_GFp_simple_point_set_affine_coordinates,
.point_get_affine_coordinates =
ec_GFp_simple_point_get_affine_coordinates,
+ .point_set_compressed_coordinates =
+ ec_GFp_simple_set_compressed_coordinates,
+ .point2oct = ec_GFp_simple_point2oct,
+ .oct2point = ec_GFp_simple_oct2point,
.add = ec_GFp_simple_add,
.dbl = ec_GFp_simple_dbl,
.invert = ec_GFp_simple_invert,