diff options
author | tb <> | 2024-11-17 08:19:08 +0000 |
---|---|---|
committer | tb <> | 2024-11-17 08:19:08 +0000 |
commit | eb3904fc0e4d1e3e66d68777aa0d54cb90429971 (patch) | |
tree | 5705463a4646d1243a03d491a3969e04cdb08c7e | |
parent | a62b48c76c324585e4b919de1818465e2667289e (diff) | |
download | openbsd-eb3904fc0e4d1e3e66d68777aa0d54cb90429971.tar.gz openbsd-eb3904fc0e4d1e3e66d68777aa0d54cb90429971.tar.bz2 openbsd-eb3904fc0e4d1e3e66d68777aa0d54cb90429971.zip |
Minor simplifications in ec_cmp()
-rw-r--r-- | src/lib/libcrypto/ec/ecp_methods.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/lib/libcrypto/ec/ecp_methods.c b/src/lib/libcrypto/ec/ecp_methods.c index 1b763cf219..65dfd5ef00 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.8 2024/11/16 15:32:08 tb Exp $ */ | 1 | /* $OpenBSD: ecp_methods.c,v 1.9 2024/11/17 08:19:08 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. |
@@ -993,28 +993,26 @@ ec_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *ctx) | |||
993 | return ret; | 993 | return ret; |
994 | } | 994 | } |
995 | 995 | ||
996 | /* | ||
997 | * Returns -1 on error, 0 if the points are equal, 1 if the points are distinct. | ||
998 | */ | ||
999 | |||
996 | static int | 1000 | static int |
997 | ec_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx) | 1001 | ec_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx) |
998 | { | 1002 | { |
999 | /* | ||
1000 | * return values: -1 error 0 equal (in affine coordinates) 1 | ||
1001 | * not equal | ||
1002 | */ | ||
1003 | |||
1004 | int (*field_mul) (const EC_GROUP *, BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *); | 1003 | int (*field_mul) (const EC_GROUP *, BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *); |
1005 | int (*field_sqr) (const EC_GROUP *, BIGNUM *, const BIGNUM *, BN_CTX *); | 1004 | int (*field_sqr) (const EC_GROUP *, BIGNUM *, const BIGNUM *, BN_CTX *); |
1006 | BIGNUM *tmp1, *tmp2, *Za23, *Zb23; | 1005 | BIGNUM *tmp1, *tmp2, *Za23, *Zb23; |
1007 | const BIGNUM *tmp1_, *tmp2_; | 1006 | const BIGNUM *tmp1_, *tmp2_; |
1008 | int ret = -1; | 1007 | int ret = -1; |
1009 | 1008 | ||
1010 | if (EC_POINT_is_at_infinity(group, a)) | 1009 | if (EC_POINT_is_at_infinity(group, a) && EC_POINT_is_at_infinity(group, b)) |
1011 | return !EC_POINT_is_at_infinity(group, b); | 1010 | return 0; |
1012 | 1011 | if (EC_POINT_is_at_infinity(group, a) || EC_POINT_is_at_infinity(group, b)) | |
1013 | if (EC_POINT_is_at_infinity(group, b)) | ||
1014 | return 1; | 1012 | return 1; |
1015 | 1013 | ||
1016 | if (a->Z_is_one && b->Z_is_one) | 1014 | if (a->Z_is_one && b->Z_is_one) |
1017 | return ((BN_cmp(&a->X, &b->X) == 0) && BN_cmp(&a->Y, &b->Y) == 0) ? 0 : 1; | 1015 | return BN_cmp(&a->X, &b->X) != 0 || BN_cmp(&a->Y, &b->Y) != 0; |
1018 | 1016 | ||
1019 | field_mul = group->meth->field_mul; | 1017 | field_mul = group->meth->field_mul; |
1020 | field_sqr = group->meth->field_sqr; | 1018 | field_sqr = group->meth->field_sqr; |