-/* $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.
*
}
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,
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,
-/* $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.
*/
# 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 *);
-/* $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.
*/
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;
}
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
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;
}
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);
}
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;
}
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);
}
-/* $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.
*/
}
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,
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,
-/* $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.
*/
}
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,
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,
-/* $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.
}
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,
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,