summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/ec/ecp_methods.c
diff options
context:
space:
mode:
authortb <>2024-11-30 21:09:59 +0000
committertb <>2024-11-30 21:09:59 +0000
commit56c2d56ad840436ee3e6f9e935795a718b9edb37 (patch)
tree6ae3aed64b6827756f2a5efd89b1c53c99db42c5 /src/lib/libcrypto/ec/ecp_methods.c
parent98f7a26186887ba45c08f5491bb6ef3a594837bd (diff)
downloadopenbsd-56c2d56ad840436ee3e6f9e935795a718b9edb37.tar.gz
openbsd-56c2d56ad840436ee3e6f9e935795a718b9edb37.tar.bz2
openbsd-56c2d56ad840436ee3e6f9e935795a718b9edb37.zip
Inline trivial EC point methods
Like most of the "group" methods these are shared between Montgomery curves and simple curves. There's no point in five methods hanging off the EC_METHODS struct whne they can just as well be inlined in the public API. It makes all files involved shorter... ok jsing
Diffstat (limited to 'src/lib/libcrypto/ec/ecp_methods.c')
-rw-r--r--src/lib/libcrypto/ec/ecp_methods.c60
1 files changed, 1 insertions, 59 deletions
diff --git a/src/lib/libcrypto/ec/ecp_methods.c b/src/lib/libcrypto/ec/ecp_methods.c
index b394206aea..b14cd0b158 100644
--- a/src/lib/libcrypto/ec/ecp_methods.c
+++ b/src/lib/libcrypto/ec/ecp_methods.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ecp_methods.c,v 1.11 2024/11/30 16:34:34 tb Exp $ */ 1/* $OpenBSD: ecp_methods.c,v 1.12 2024/11/30 21:09:59 tb Exp $ */
2/* Includes code written by Lenka Fibikova <fibikova@exp-math.uni-essen.de> 2/* Includes code written by Lenka Fibikova <fibikova@exp-math.uni-essen.de>
3 * for the OpenSSL project. 3 * for the OpenSSL project.
4 * Includes code written by Bodo Moeller for the OpenSSL project. 4 * Includes code written by Bodo Moeller for the OpenSSL project.
@@ -280,48 +280,6 @@ ec_group_check_discriminant(const EC_GROUP *group, BN_CTX *ctx)
280} 280}
281 281
282static int 282static int
283ec_point_init(EC_POINT * point)
284{
285 BN_init(&point->X);
286 BN_init(&point->Y);
287 BN_init(&point->Z);
288 point->Z_is_one = 0;
289
290 return 1;
291}
292
293static void
294ec_point_finish(EC_POINT *point)
295{
296 BN_free(&point->X);
297 BN_free(&point->Y);
298 BN_free(&point->Z);
299 point->Z_is_one = 0;
300}
301
302static int
303ec_point_copy(EC_POINT *dest, const EC_POINT *src)
304{
305 if (!bn_copy(&dest->X, &src->X))
306 return 0;
307 if (!bn_copy(&dest->Y, &src->Y))
308 return 0;
309 if (!bn_copy(&dest->Z, &src->Z))
310 return 0;
311 dest->Z_is_one = src->Z_is_one;
312
313 return 1;
314}
315
316static int
317ec_point_set_to_infinity(const EC_GROUP *group, EC_POINT *point)
318{
319 point->Z_is_one = 0;
320 BN_zero(&point->Z);
321 return 1;
322}
323
324static int
325ec_set_Jprojective_coordinates(const EC_GROUP *group, EC_POINT *point, 283ec_set_Jprojective_coordinates(const EC_GROUP *group, EC_POINT *point,
326 const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *ctx) 284 const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *ctx)
327{ 285{
@@ -891,12 +849,6 @@ ec_invert(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx)
891} 849}
892 850
893static int 851static int
894ec_is_at_infinity(const EC_GROUP *group, const EC_POINT *point)
895{
896 return BN_is_zero(&point->Z);
897}
898
899static int
900ec_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *ctx) 852ec_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *ctx)
901{ 853{
902 int (*field_mul) (const EC_GROUP *, BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *); 854 int (*field_mul) (const EC_GROUP *, BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *);
@@ -1738,10 +1690,6 @@ static const EC_METHOD ec_GFp_simple_method = {
1738 .group_get_degree = ec_group_get_degree, 1690 .group_get_degree = ec_group_get_degree,
1739 .group_order_bits = ec_group_simple_order_bits, 1691 .group_order_bits = ec_group_simple_order_bits,
1740 .group_check_discriminant = ec_group_check_discriminant, 1692 .group_check_discriminant = ec_group_check_discriminant,
1741 .point_init = ec_point_init,
1742 .point_finish = ec_point_finish,
1743 .point_copy = ec_point_copy,
1744 .point_set_to_infinity = ec_point_set_to_infinity,
1745 .point_set_Jprojective_coordinates = ec_set_Jprojective_coordinates, 1693 .point_set_Jprojective_coordinates = ec_set_Jprojective_coordinates,
1746 .point_get_Jprojective_coordinates = ec_get_Jprojective_coordinates, 1694 .point_get_Jprojective_coordinates = ec_get_Jprojective_coordinates,
1747 .point_set_affine_coordinates = ec_point_set_affine_coordinates, 1695 .point_set_affine_coordinates = ec_point_set_affine_coordinates,
@@ -1750,7 +1698,6 @@ static const EC_METHOD ec_GFp_simple_method = {
1750 .add = ec_add, 1698 .add = ec_add,
1751 .dbl = ec_dbl, 1699 .dbl = ec_dbl,
1752 .invert = ec_invert, 1700 .invert = ec_invert,
1753 .is_at_infinity = ec_is_at_infinity,
1754 .is_on_curve = ec_is_on_curve, 1701 .is_on_curve = ec_is_on_curve,
1755 .point_cmp = ec_cmp, 1702 .point_cmp = ec_cmp,
1756 .make_affine = ec_make_affine, 1703 .make_affine = ec_make_affine,
@@ -1780,10 +1727,6 @@ static const EC_METHOD ec_GFp_mont_method = {
1780 .group_get_degree = ec_group_get_degree, 1727 .group_get_degree = ec_group_get_degree,
1781 .group_order_bits = ec_group_simple_order_bits, 1728 .group_order_bits = ec_group_simple_order_bits,
1782 .group_check_discriminant = ec_group_check_discriminant, 1729 .group_check_discriminant = ec_group_check_discriminant,
1783 .point_init = ec_point_init,
1784 .point_finish = ec_point_finish,
1785 .point_copy = ec_point_copy,
1786 .point_set_to_infinity = ec_point_set_to_infinity,
1787 .point_set_Jprojective_coordinates = ec_set_Jprojective_coordinates, 1730 .point_set_Jprojective_coordinates = ec_set_Jprojective_coordinates,
1788 .point_get_Jprojective_coordinates = ec_get_Jprojective_coordinates, 1731 .point_get_Jprojective_coordinates = ec_get_Jprojective_coordinates,
1789 .point_set_affine_coordinates = ec_point_set_affine_coordinates, 1732 .point_set_affine_coordinates = ec_point_set_affine_coordinates,
@@ -1792,7 +1735,6 @@ static const EC_METHOD ec_GFp_mont_method = {
1792 .add = ec_add, 1735 .add = ec_add,
1793 .dbl = ec_dbl, 1736 .dbl = ec_dbl,
1794 .invert = ec_invert, 1737 .invert = ec_invert,
1795 .is_at_infinity = ec_is_at_infinity,
1796 .is_on_curve = ec_is_on_curve, 1738 .is_on_curve = ec_is_on_curve,
1797 .point_cmp = ec_cmp, 1739 .point_cmp = ec_cmp,
1798 .make_affine = ec_make_affine, 1740 .make_affine = ec_make_affine,