From e3bdd39cc031d39a8ea071c9a8ecea5b6a958967 Mon Sep 17 00:00:00 2001 From: tb <> Date: Tue, 20 Apr 2021 17:32:57 +0000 Subject: Prepare to provide EC_POINT_set_compressed_coordinates ok jsing --- src/lib/libcrypto/ec/ec_oct.c | 52 ++++++++++++++----------------------------- 1 file changed, 17 insertions(+), 35 deletions(-) (limited to 'src/lib/libcrypto/ec/ec_oct.c') diff --git a/src/lib/libcrypto/ec/ec_oct.c b/src/lib/libcrypto/ec/ec_oct.c index a285c81459..a3a826d0f1 100644 --- a/src/lib/libcrypto/ec/ec_oct.c +++ b/src/lib/libcrypto/ec/ec_oct.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_oct.c,v 1.6 2020/12/04 08:55:30 tb Exp $ */ +/* $OpenBSD: ec_oct.c,v 1.7 2021/04/20 17:32:57 tb Exp $ */ /* * Originally written by Bodo Moeller for the OpenSSL project. */ @@ -70,9 +70,9 @@ #include "ec_lcl.h" -int -EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP * group, EC_POINT * point, - const BIGNUM * x, int y_bit, BN_CTX * ctx) +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 == 0 && !(group->meth->flags & EC_FLAGS_DEFAULT_OCT)) { @@ -108,40 +108,23 @@ EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP * group, EC_POINT * point return 1; } +int +EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, EC_POINT *point, + const BIGNUM *x, int y_bit, BN_CTX *ctx) +{ + return EC_POINT_set_compressed_coordinates(group, point, x, y_bit, ctx); +} + #ifndef OPENSSL_NO_EC2M -int -EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP * group, EC_POINT * point, - const BIGNUM * x, int y_bit, BN_CTX * ctx) +int +EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group, EC_POINT *point, + const BIGNUM *x, int y_bit, BN_CTX *ctx) { - if (group->meth->point_set_compressed_coordinates == 0 - && !(group->meth->flags & EC_FLAGS_DEFAULT_OCT)) { - ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); - return 0; - } - if (group->meth != point->meth) { - 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 - return ec_GF2m_simple_set_compressed_coordinates( - group, point, x, y_bit, ctx); - } - 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 EC_POINT_set_compressed_coordinates(group, point, x, y_bit, ctx); } #endif -size_t +size_t 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) @@ -173,8 +156,7 @@ EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *point, return group->meth->point2oct(group, point, form, buf, len, ctx); } - -int +int EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *point, const unsigned char *buf, size_t len, BN_CTX *ctx) { -- cgit v1.2.3-55-g6feb