From: tb Date: Tue, 20 Apr 2021 17:28:18 +0000 (+0000) Subject: Provide EC_POINT_{g,s}et_Jprojective_coordinates for internal use X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=4f21b6f2441fb2ec34ae8b50517b259ff5f364ea;p=openbsd Provide EC_POINT_{g,s}et_Jprojective_coordinates for internal use ok jsing --- diff --git a/lib/libcrypto/ec/ec.h b/lib/libcrypto/ec/ec.h index ebd80b91fdb..ff60e80952e 100644 --- a/lib/libcrypto/ec/ec.h +++ b/lib/libcrypto/ec/ec.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ec.h,v 1.20 2021/04/20 17:16:37 tb Exp $ */ +/* $OpenBSD: ec.h,v 1.21 2021/04/20 17:28:18 tb Exp $ */ /* * Originally written by Bodo Moeller for the OpenSSL project. */ @@ -454,6 +454,12 @@ const EC_METHOD *EC_POINT_method_of(const EC_POINT *point); */ int EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point); +#if defined(LIBRESSL_INTERNAL) +int EC_POINT_set_Jprojective_coordinates(const EC_GROUP *group, EC_POINT *p, + const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *ctx); +int EC_POINT_get_Jprojective_coordinates(const EC_GROUP *group, + const EC_POINT *p, BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *ctx); +#else /** Sets the jacobian projective coordinates of a EC_POINT over GFp * \param group underlying EC_GROUP object * \param p EC_POINT object @@ -477,6 +483,7 @@ int EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group, EC_POINT *p, */ int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group, const EC_POINT *p, BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *ctx); +#endif #if defined(LIBRESSL_INTERNAL) int EC_POINT_set_affine_coordinates(const EC_GROUP *group, EC_POINT *p, diff --git a/lib/libcrypto/ec/ec_lcl.h b/lib/libcrypto/ec/ec_lcl.h index 4addc860ede..7570cdc7f2e 100644 --- a/lib/libcrypto/ec/ec_lcl.h +++ b/lib/libcrypto/ec/ec_lcl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_lcl.h,v 1.15 2021/04/20 17:16:37 tb Exp $ */ +/* $OpenBSD: ec_lcl.h,v 1.16 2021/04/20 17:28:18 tb Exp $ */ /* * Originally written by Bodo Moeller for the OpenSSL project. */ @@ -122,16 +122,16 @@ struct ec_method_st { int (*point_copy)(EC_POINT *, const EC_POINT *); /* used by EC_POINT_set_to_infinity, - * EC_POINT_set_Jprojective_coordinates_GFp, - * EC_POINT_get_Jprojective_coordinates_GFp, + * EC_POINT_set_Jprojective_coordinates, + * EC_POINT_get_Jprojective_coordinates, * EC_POINT_set_affine_coordinates, * EC_POINT_get_affine_coordinates, * EC_POINT_set_compressed_coordinates_GFp, ..._GF2m: */ int (*point_set_to_infinity)(const EC_GROUP *, EC_POINT *); - int (*point_set_Jprojective_coordinates_GFp)(const EC_GROUP *, EC_POINT *, + int (*point_set_Jprojective_coordinates)(const EC_GROUP *, EC_POINT *, const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *); - int (*point_get_Jprojective_coordinates_GFp)(const EC_GROUP *, const EC_POINT *, + int (*point_get_Jprojective_coordinates)(const EC_GROUP *, const EC_POINT *, BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *); int (*point_set_affine_coordinates)(const EC_GROUP *, EC_POINT *, const BIGNUM *x, const BIGNUM *y, BN_CTX *); @@ -320,10 +320,10 @@ void ec_GFp_simple_point_finish(EC_POINT *); void ec_GFp_simple_point_clear_finish(EC_POINT *); int ec_GFp_simple_point_copy(EC_POINT *, const EC_POINT *); int ec_GFp_simple_point_set_to_infinity(const EC_GROUP *, EC_POINT *); -int ec_GFp_simple_set_Jprojective_coordinates_GFp(const EC_GROUP *, EC_POINT *, - const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *); -int ec_GFp_simple_get_Jprojective_coordinates_GFp(const EC_GROUP *, const EC_POINT *, - BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *); +int ec_GFp_simple_set_Jprojective_coordinates(const EC_GROUP *, EC_POINT *, + const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *); +int ec_GFp_simple_get_Jprojective_coordinates(const EC_GROUP *, + const EC_POINT *, BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *); int ec_GFp_simple_point_set_affine_coordinates(const EC_GROUP *, EC_POINT *, const BIGNUM *x, const BIGNUM *y, BN_CTX *); int ec_GFp_simple_point_get_affine_coordinates(const EC_GROUP *, const EC_POINT *, diff --git a/lib/libcrypto/ec/ec_lib.c b/lib/libcrypto/ec/ec_lib.c index 1be688824db..a5cf84b78c8 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.37 2021/04/20 17:17:47 tb Exp $ */ +/* $OpenBSD: ec_lib.c,v 1.38 2021/04/20 17:28:18 tb Exp $ */ /* * Originally written by Bodo Moeller for the OpenSSL project. */ @@ -922,12 +922,11 @@ EC_POINT_set_to_infinity(const EC_GROUP * group, EC_POINT * point) return group->meth->point_set_to_infinity(group, point); } - -int -EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group, EC_POINT *point, +int +EC_POINT_set_Jprojective_coordinates(const EC_GROUP *group, EC_POINT *point, const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *ctx) { - if (group->meth->point_set_Jprojective_coordinates_GFp == 0) { + if (group->meth->point_set_Jprojective_coordinates == 0) { ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return 0; } @@ -935,15 +934,15 @@ EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group, EC_POINT *point, ECerror(EC_R_INCOMPATIBLE_OBJECTS); return 0; } - return group->meth->point_set_Jprojective_coordinates_GFp(group, point, x, y, z, ctx); + return group->meth->point_set_Jprojective_coordinates(group, point, + x, y, z, ctx); } - -int -EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group, +int +EC_POINT_get_Jprojective_coordinates(const EC_GROUP *group, const EC_POINT *point, BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *ctx) { - if (group->meth->point_get_Jprojective_coordinates_GFp == 0) { + if (group->meth->point_get_Jprojective_coordinates == 0) { ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return 0; } @@ -951,7 +950,22 @@ EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group, ECerror(EC_R_INCOMPATIBLE_OBJECTS); return 0; } - return group->meth->point_get_Jprojective_coordinates_GFp(group, point, x, y, z, ctx); + return group->meth->point_get_Jprojective_coordinates(group, point, + x, y, z, ctx); +} + +int +EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group, EC_POINT *point, + const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *ctx) +{ + return EC_POINT_set_Jprojective_coordinates(group, point, x, y, z, ctx); +} + +int +EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group, + const EC_POINT *point, BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *ctx) +{ + return EC_POINT_get_Jprojective_coordinates(group, point, x, y, z, ctx); } int diff --git a/lib/libcrypto/ec/ecp_mont.c b/lib/libcrypto/ec/ecp_mont.c index f4dff9aa463..7160692e9e3 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.17 2018/11/05 20:18:21 tb Exp $ */ +/* $OpenBSD: ecp_mont.c,v 1.18 2021/04/20 17:28:18 tb Exp $ */ /* * Originally written by Bodo Moeller for the OpenSSL project. */ @@ -86,10 +86,10 @@ EC_GFp_mont_method(void) .point_clear_finish = ec_GFp_simple_point_clear_finish, .point_copy = ec_GFp_simple_point_copy, .point_set_to_infinity = ec_GFp_simple_point_set_to_infinity, - .point_set_Jprojective_coordinates_GFp = - ec_GFp_simple_set_Jprojective_coordinates_GFp, - .point_get_Jprojective_coordinates_GFp = - ec_GFp_simple_get_Jprojective_coordinates_GFp, + .point_set_Jprojective_coordinates = + ec_GFp_simple_set_Jprojective_coordinates, + .point_get_Jprojective_coordinates = + ec_GFp_simple_get_Jprojective_coordinates, .point_set_affine_coordinates = ec_GFp_simple_point_set_affine_coordinates, .point_get_affine_coordinates = diff --git a/lib/libcrypto/ec/ecp_nist.c b/lib/libcrypto/ec/ecp_nist.c index 073c0419cf2..c34c708025d 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.15 2018/11/05 20:18:21 tb Exp $ */ +/* $OpenBSD: ecp_nist.c,v 1.16 2021/04/20 17:28:18 tb Exp $ */ /* * Written by Nils Larsch for the OpenSSL project. */ @@ -87,10 +87,10 @@ EC_GFp_nist_method(void) .point_clear_finish = ec_GFp_simple_point_clear_finish, .point_copy = ec_GFp_simple_point_copy, .point_set_to_infinity = ec_GFp_simple_point_set_to_infinity, - .point_set_Jprojective_coordinates_GFp = - ec_GFp_simple_set_Jprojective_coordinates_GFp, - .point_get_Jprojective_coordinates_GFp = - ec_GFp_simple_get_Jprojective_coordinates_GFp, + .point_set_Jprojective_coordinates = + ec_GFp_simple_set_Jprojective_coordinates, + .point_get_Jprojective_coordinates = + ec_GFp_simple_get_Jprojective_coordinates, .point_set_affine_coordinates = ec_GFp_simple_point_set_affine_coordinates, .point_get_affine_coordinates = diff --git a/lib/libcrypto/ec/ecp_nistp224.c b/lib/libcrypto/ec/ecp_nistp224.c index c5fc738a02e..10ade9dbb53 100644 --- a/lib/libcrypto/ec/ecp_nistp224.c +++ b/lib/libcrypto/ec/ecp_nistp224.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecp_nistp224.c,v 1.24 2021/04/20 17:16:37 tb Exp $ */ +/* $OpenBSD: ecp_nistp224.c,v 1.25 2021/04/20 17:28:18 tb Exp $ */ /* * Written by Emilia Kasper (Google) for the OpenSSL project. */ @@ -250,10 +250,10 @@ EC_GFp_nistp224_method(void) .point_clear_finish = ec_GFp_simple_point_clear_finish, .point_copy = ec_GFp_simple_point_copy, .point_set_to_infinity = ec_GFp_simple_point_set_to_infinity, - .point_set_Jprojective_coordinates_GFp = - ec_GFp_simple_set_Jprojective_coordinates_GFp, - .point_get_Jprojective_coordinates_GFp = - ec_GFp_simple_get_Jprojective_coordinates_GFp, + .point_set_Jprojective_coordinates = + ec_GFp_simple_set_Jprojective_coordinates, + .point_get_Jprojective_coordinates = + ec_GFp_simple_get_Jprojective_coordinates, .point_set_affine_coordinates = ec_GFp_simple_point_set_affine_coordinates, .point_get_affine_coordinates = @@ -1409,8 +1409,8 @@ ec_GFp_nistp224_points_mul(const EC_GROUP * group, EC_POINT * r, ECerror(ERR_R_BN_LIB); goto err; } - if (!EC_POINT_set_Jprojective_coordinates_GFp(group, - generator, x, y, z, ctx)) + if (!EC_POINT_set_Jprojective_coordinates(group, generator, + x, y, z, ctx)) goto err; if (0 == EC_POINT_cmp(group, generator, group->generator, ctx)) /* precomputation matches generator */ @@ -1536,7 +1536,7 @@ ec_GFp_nistp224_points_mul(const EC_GROUP * group, EC_POINT * r, ECerror(ERR_R_BN_LIB); goto err; } - ret = EC_POINT_set_Jprojective_coordinates_GFp(group, r, x, y, z, ctx); + ret = EC_POINT_set_Jprojective_coordinates(group, r, x, y, z, ctx); err: BN_CTX_end(ctx); diff --git a/lib/libcrypto/ec/ecp_nistp256.c b/lib/libcrypto/ec/ecp_nistp256.c index 38e87ecd03c..674143cc3ee 100644 --- a/lib/libcrypto/ec/ecp_nistp256.c +++ b/lib/libcrypto/ec/ecp_nistp256.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecp_nistp256.c,v 1.23 2021/04/20 17:16:37 tb Exp $ */ +/* $OpenBSD: ecp_nistp256.c,v 1.24 2021/04/20 17:28:18 tb Exp $ */ /* * Written by Adam Langley (Google) for the OpenSSL project */ @@ -1704,10 +1704,10 @@ EC_GFp_nistp256_method(void) .point_clear_finish = ec_GFp_simple_point_clear_finish, .point_copy = ec_GFp_simple_point_copy, .point_set_to_infinity = ec_GFp_simple_point_set_to_infinity, - .point_set_Jprojective_coordinates_GFp = - ec_GFp_simple_set_Jprojective_coordinates_GFp, - .point_get_Jprojective_coordinates_GFp = - ec_GFp_simple_get_Jprojective_coordinates_GFp, + .point_set_Jprojective_coordinates = + ec_GFp_simple_set_Jprojective_coordinates, + .point_get_Jprojective_coordinates = + ec_GFp_simple_get_Jprojective_coordinates, .point_set_affine_coordinates = ec_GFp_simple_point_set_affine_coordinates, .point_get_affine_coordinates = @@ -1959,8 +1959,8 @@ ec_GFp_nistp256_points_mul(const EC_GROUP * group, EC_POINT * r, ECerror(ERR_R_BN_LIB); goto err; } - if (!EC_POINT_set_Jprojective_coordinates_GFp(group, - generator, x, y, z, ctx)) + if (!EC_POINT_set_Jprojective_coordinates(group, generator, + x, y, z, ctx)) goto err; if (0 == EC_POINT_cmp(group, generator, group->generator, ctx)) /* precomputation matches generator */ @@ -2089,7 +2089,7 @@ ec_GFp_nistp256_points_mul(const EC_GROUP * group, EC_POINT * r, ECerror(ERR_R_BN_LIB); goto err; } - ret = EC_POINT_set_Jprojective_coordinates_GFp(group, r, x, y, z, ctx); + ret = EC_POINT_set_Jprojective_coordinates(group, r, x, y, z, ctx); err: BN_CTX_end(ctx); diff --git a/lib/libcrypto/ec/ecp_nistp521.c b/lib/libcrypto/ec/ecp_nistp521.c index e5ccbb1b216..3d38c723961 100644 --- a/lib/libcrypto/ec/ecp_nistp521.c +++ b/lib/libcrypto/ec/ecp_nistp521.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecp_nistp521.c,v 1.24 2021/04/20 17:16:38 tb Exp $ */ +/* $OpenBSD: ecp_nistp521.c,v 1.25 2021/04/20 17:28:18 tb Exp $ */ /* * Written by Adam Langley (Google) for the OpenSSL project */ @@ -1594,10 +1594,10 @@ EC_GFp_nistp521_method(void) .point_clear_finish = ec_GFp_simple_point_clear_finish, .point_copy = ec_GFp_simple_point_copy, .point_set_to_infinity = ec_GFp_simple_point_set_to_infinity, - .point_set_Jprojective_coordinates_GFp = - ec_GFp_simple_set_Jprojective_coordinates_GFp, - .point_get_Jprojective_coordinates_GFp = - ec_GFp_simple_get_Jprojective_coordinates_GFp, + .point_set_Jprojective_coordinates = + ec_GFp_simple_set_Jprojective_coordinates, + .point_get_Jprojective_coordinates = + ec_GFp_simple_get_Jprojective_coordinates, .point_set_affine_coordinates = ec_GFp_simple_point_set_affine_coordinates, .point_get_affine_coordinates = @@ -1848,8 +1848,8 @@ ec_GFp_nistp521_points_mul(const EC_GROUP * group, EC_POINT * r, ECerror(ERR_R_BN_LIB); goto err; } - if (!EC_POINT_set_Jprojective_coordinates_GFp(group, - generator, x, y, z, ctx)) + if (!EC_POINT_set_Jprojective_coordinates(group, generator, + x, y, z, ctx)) goto err; if (0 == EC_POINT_cmp(group, generator, group->generator, ctx)) /* precomputation matches generator */ @@ -1978,7 +1978,7 @@ ec_GFp_nistp521_points_mul(const EC_GROUP * group, EC_POINT * r, ECerror(ERR_R_BN_LIB); goto err; } - ret = EC_POINT_set_Jprojective_coordinates_GFp(group, r, x, y, z, ctx); + ret = EC_POINT_set_Jprojective_coordinates(group, r, x, y, z, ctx); err: BN_CTX_end(ctx); diff --git a/lib/libcrypto/ec/ecp_nistz256.c b/lib/libcrypto/ec/ecp_nistz256.c index 13c4cd2f349..619249964be 100644 --- a/lib/libcrypto/ec/ecp_nistz256.c +++ b/lib/libcrypto/ec/ecp_nistz256.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecp_nistz256.c,v 1.8 2021/04/20 17:16:38 tb Exp $ */ +/* $OpenBSD: ecp_nistz256.c,v 1.9 2021/04/20 17:28:18 tb Exp $ */ /* Copyright (c) 2014, Intel Corporation. * * Permission to use, copy, modify, and/or distribute this software for any @@ -1159,10 +1159,10 @@ EC_GFp_nistz256_method(void) .point_clear_finish = ec_GFp_simple_point_clear_finish, .point_copy = ec_GFp_simple_point_copy, .point_set_to_infinity = ec_GFp_simple_point_set_to_infinity, - .point_set_Jprojective_coordinates_GFp = - ec_GFp_simple_set_Jprojective_coordinates_GFp, - .point_get_Jprojective_coordinates_GFp = - ec_GFp_simple_get_Jprojective_coordinates_GFp, + .point_set_Jprojective_coordinates = + ec_GFp_simple_set_Jprojective_coordinates, + .point_get_Jprojective_coordinates = + ec_GFp_simple_get_Jprojective_coordinates, .point_set_affine_coordinates = ec_GFp_simple_point_set_affine_coordinates, .point_get_affine_coordinates = ecp_nistz256_get_affine, diff --git a/lib/libcrypto/ec/ecp_smpl.c b/lib/libcrypto/ec/ecp_smpl.c index e1fd9007c7e..92234274594 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.30 2021/04/20 17:16:38 tb Exp $ */ +/* $OpenBSD: ecp_smpl.c,v 1.31 2021/04/20 17:28:18 tb Exp $ */ /* Includes code written by Lenka Fibikova * for the OpenSSL project. * Includes code written by Bodo Moeller for the OpenSSL project. @@ -87,10 +87,10 @@ EC_GFp_simple_method(void) .point_clear_finish = ec_GFp_simple_point_clear_finish, .point_copy = ec_GFp_simple_point_copy, .point_set_to_infinity = ec_GFp_simple_point_set_to_infinity, - .point_set_Jprojective_coordinates_GFp = - ec_GFp_simple_set_Jprojective_coordinates_GFp, - .point_get_Jprojective_coordinates_GFp = - ec_GFp_simple_get_Jprojective_coordinates_GFp, + .point_set_Jprojective_coordinates = + ec_GFp_simple_set_Jprojective_coordinates, + .point_get_Jprojective_coordinates = + ec_GFp_simple_get_Jprojective_coordinates, .point_set_affine_coordinates = ec_GFp_simple_point_set_affine_coordinates, .point_get_affine_coordinates = @@ -413,9 +413,10 @@ ec_GFp_simple_point_set_to_infinity(const EC_GROUP * group, EC_POINT * point) } -int -ec_GFp_simple_set_Jprojective_coordinates_GFp(const EC_GROUP * group, EC_POINT * point, - const BIGNUM * x, const BIGNUM * y, const BIGNUM * z, BN_CTX * ctx) +int +ec_GFp_simple_set_Jprojective_coordinates(const EC_GROUP *group, + EC_POINT *point, const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, + BN_CTX *ctx) { BN_CTX *new_ctx = NULL; int ret = 0; @@ -465,10 +466,9 @@ ec_GFp_simple_set_Jprojective_coordinates_GFp(const EC_GROUP * group, EC_POINT * return ret; } - -int -ec_GFp_simple_get_Jprojective_coordinates_GFp(const EC_GROUP * group, const EC_POINT * point, - BIGNUM * x, BIGNUM * y, BIGNUM * z, BN_CTX * ctx) +int +ec_GFp_simple_get_Jprojective_coordinates(const EC_GROUP *group, + const EC_POINT *point, BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *ctx) { BN_CTX *new_ctx = NULL; int ret = 0; @@ -513,8 +513,7 @@ ec_GFp_simple_get_Jprojective_coordinates_GFp(const EC_GROUP * group, const EC_P return ret; } - -int +int ec_GFp_simple_point_set_affine_coordinates(const EC_GROUP * group, EC_POINT * point, const BIGNUM * x, const BIGNUM * y, BN_CTX * ctx) { @@ -523,11 +522,11 @@ ec_GFp_simple_point_set_affine_coordinates(const EC_GROUP * group, EC_POINT * po ECerror(ERR_R_PASSED_NULL_PARAMETER); return 0; } - return EC_POINT_set_Jprojective_coordinates_GFp(group, point, x, y, BN_value_one(), ctx); + return EC_POINT_set_Jprojective_coordinates(group, point, x, y, + BN_value_one(), ctx); } - -int +int ec_GFp_simple_point_get_affine_coordinates(const EC_GROUP * group, const EC_POINT * point, BIGNUM * x, BIGNUM * y, BN_CTX * ctx) {