summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/ec/ec_lib.c
diff options
context:
space:
mode:
authortb <>2025-01-06 10:56:46 +0000
committertb <>2025-01-06 10:56:46 +0000
commit1d5dc8af4f29575850958ce2ca4c6ffcc27dece5 (patch)
tree5250419bf796593e37d9a70cab2f081aaa78174e /src/lib/libcrypto/ec/ec_lib.c
parent41644a653441af880b86e412a5c8e52ef0c53151 (diff)
downloadopenbsd-1d5dc8af4f29575850958ce2ca4c6ffcc27dece5.tar.gz
openbsd-1d5dc8af4f29575850958ce2ca4c6ffcc27dece5.tar.bz2
openbsd-1d5dc8af4f29575850958ce2ca4c6ffcc27dece5.zip
Prepare removal accessors for Jprojective coordinates
That the BN-driven EC code uses Jacobian projective coordinates as an optimization is an implementation detail. As such this should never have leaked out of the library as part of the public API. No consumer should ever care and if they do they're doing it wrong. The only port that cares is one of those stupid little perl modules that expose all the things and transform terrible OpenSSL regress tests into similarly horrible Perl. In practice, only affine coordinates matter (perhaps in compressed form). This prunes two more function pointers from EC_GROUP and prepares the removal of the field_set_to_one() method which is now only used in ec_points_make_affine(). ok jsing sthen
Diffstat (limited to 'src/lib/libcrypto/ec/ec_lib.c')
-rw-r--r--src/lib/libcrypto/ec/ec_lib.c76
1 files changed, 5 insertions, 71 deletions
diff --git a/src/lib/libcrypto/ec/ec_lib.c b/src/lib/libcrypto/ec/ec_lib.c
index d961ad0ee4..03c6f3aa90 100644
--- a/src/lib/libcrypto/ec/ec_lib.c
+++ b/src/lib/libcrypto/ec/ec_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_lib.c,v 1.94 2025/01/05 16:07:08 tb Exp $ */ 1/* $OpenBSD: ec_lib.c,v 1.95 2025/01/06 10:56:46 tb Exp $ */
2/* 2/*
3 * Originally written by Bodo Moeller for the OpenSSL project. 3 * Originally written by Bodo Moeller for the OpenSSL project.
4 */ 4 */
@@ -908,78 +908,11 @@ EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point)
908LCRYPTO_ALIAS(EC_POINT_set_to_infinity); 908LCRYPTO_ALIAS(EC_POINT_set_to_infinity);
909 909
910int 910int
911EC_POINT_set_Jprojective_coordinates(const EC_GROUP *group, EC_POINT *point,
912 const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *ctx_in)
913{
914 BN_CTX *ctx;
915 int ret = 0;
916
917 if ((ctx = ctx_in) == NULL)
918 ctx = BN_CTX_new();
919 if (ctx == NULL)
920 goto err;
921
922 if (group->meth->point_set_Jprojective_coordinates == NULL) {
923 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
924 goto err;
925 }
926 if (group->meth != point->meth) {
927 ECerror(EC_R_INCOMPATIBLE_OBJECTS);
928 goto err;
929 }
930 if (!group->meth->point_set_Jprojective_coordinates(group, point,
931 x, y, z, ctx))
932 goto err;
933
934 if (EC_POINT_is_on_curve(group, point, ctx) <= 0) {
935 ECerror(EC_R_POINT_IS_NOT_ON_CURVE);
936 goto err;
937 }
938
939 ret = 1;
940
941 err:
942 if (ctx != ctx_in)
943 BN_CTX_free(ctx);
944
945 return ret;
946}
947
948int
949EC_POINT_get_Jprojective_coordinates(const EC_GROUP *group,
950 const EC_POINT *point, BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *ctx_in)
951{
952 BN_CTX *ctx;
953 int ret = 0;
954
955 if ((ctx = ctx_in) == NULL)
956 ctx = BN_CTX_new();
957 if (ctx == NULL)
958 goto err;
959
960 if (group->meth->point_get_Jprojective_coordinates == NULL) {
961 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
962 goto err;
963 }
964 if (group->meth != point->meth) {
965 ECerror(EC_R_INCOMPATIBLE_OBJECTS);
966 goto err;
967 }
968 ret = group->meth->point_get_Jprojective_coordinates(group, point,
969 x, y, z, ctx);
970
971 err:
972 if (ctx != ctx_in)
973 BN_CTX_free(ctx);
974
975 return ret;
976}
977
978int
979EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group, EC_POINT *point, 911EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group, EC_POINT *point,
980 const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *ctx) 912 const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *ctx)
981{ 913{
982 return EC_POINT_set_Jprojective_coordinates(group, point, x, y, z, ctx); 914 ECerror(ERR_R_DISABLED);
915 return 0;
983} 916}
984LCRYPTO_ALIAS(EC_POINT_set_Jprojective_coordinates_GFp); 917LCRYPTO_ALIAS(EC_POINT_set_Jprojective_coordinates_GFp);
985 918
@@ -987,7 +920,8 @@ int
987EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group, 920EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group,
988 const EC_POINT *point, BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *ctx) 921 const EC_POINT *point, BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *ctx)
989{ 922{
990 return EC_POINT_get_Jprojective_coordinates(group, point, x, y, z, ctx); 923 ECerror(ERR_R_DISABLED);
924 return 0;
991} 925}
992LCRYPTO_ALIAS(EC_POINT_get_Jprojective_coordinates_GFp); 926LCRYPTO_ALIAS(EC_POINT_get_Jprojective_coordinates_GFp);
993 927