Provide EC_POINT_{g,s}et_Jprojective_coordinates for internal use
authortb <tb@openbsd.org>
Tue, 20 Apr 2021 17:28:18 +0000 (17:28 +0000)
committertb <tb@openbsd.org>
Tue, 20 Apr 2021 17:28:18 +0000 (17:28 +0000)
ok jsing

lib/libcrypto/ec/ec.h
lib/libcrypto/ec/ec_lcl.h
lib/libcrypto/ec/ec_lib.c
lib/libcrypto/ec/ecp_mont.c
lib/libcrypto/ec/ecp_nist.c
lib/libcrypto/ec/ecp_nistp224.c
lib/libcrypto/ec/ecp_nistp256.c
lib/libcrypto/ec/ecp_nistp521.c
lib/libcrypto/ec/ecp_nistz256.c
lib/libcrypto/ec/ecp_smpl.c

index ebd80b9..ff60e80 100644 (file)
@@ -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,
index 4addc86..7570cdc 100644 (file)
@@ -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 *,
index 1be6888..a5cf84b 100644 (file)
@@ -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
index f4dff9a..7160692 100644 (file)
@@ -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 =
index 073c041..c34c708 100644 (file)
@@ -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 =
index c5fc738..10ade9d 100644 (file)
@@ -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);
index 38e87ec..674143c 100644 (file)
@@ -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);
index e5ccbb1..3d38c72 100644 (file)
@@ -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);
index 13c4cd2..6192499 100644 (file)
@@ -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,
index e1fd900..9223427 100644 (file)
@@ -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 <fibikova@exp-math.uni-essen.de>
  * 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)
 {