aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Prestwood <prestwoj@gmail.com>2023-10-12 06:38:12 -0700
committerDenis Kenzior <denkenz@gmail.com>2023-10-17 09:59:59 -0500
commit79f97d9b00485e7ad6f9344fbafeb57957890ccc (patch)
tree1ffa9c762adc2403f57a8f887acecfcf0f6b0de0
parent8ea2d161da73e336fe8e5fa5809fd621dfd064b3 (diff)
ecc: add l_ecc_point_is_infinity
When creating a point from raw data the validity and if infinity is checked but there doesn't exist any way to check a point for infinity after doing some arithmetic on it. Some specs requires a resulting point be checked for infinity.
-rw-r--r--ell/ecc.c5
-rw-r--r--ell/ecc.h1
-rw-r--r--ell/ell.sym1
3 files changed, 7 insertions, 0 deletions
diff --git a/ell/ecc.c b/ell/ecc.c
index a28bbb6d..59bff7bd 100644
--- a/ell/ecc.c
+++ b/ell/ecc.c
@@ -1011,3 +1011,8 @@ LIB_EXPORT bool l_ecc_points_are_equal(const struct l_ecc_point *a,
return ((memcmp(a->x, b->x, a->curve->ndigits * 8) == 0) &&
(memcmp(a->y, b->y, a->curve->ndigits * 8) == 0));
}
+
+LIB_EXPORT bool l_ecc_point_is_infinity(const struct l_ecc_point *p)
+{
+ return _ecc_point_is_zero(p);
+}
diff --git a/ell/ecc.h b/ell/ecc.h
index 47cb5af2..2f6faa4e 100644
--- a/ell/ecc.h
+++ b/ell/ecc.h
@@ -99,6 +99,7 @@ bool l_ecc_scalars_are_equal(const struct l_ecc_scalar *a,
bool l_ecc_points_are_equal(const struct l_ecc_point *a,
const struct l_ecc_point *b);
+bool l_ecc_point_is_infinity(const struct l_ecc_point *p);
#ifdef __cplusplus
}
diff --git a/ell/ell.sym b/ell/ell.sym
index 7d07c868..c457a762 100644
--- a/ell/ell.sym
+++ b/ell/ell.sym
@@ -598,6 +598,7 @@ global:
l_ecc_point_clone;
l_ecc_point_get_curve;
l_ecc_points_are_equal;
+ l_ecc_point_is_infinity;
l_ecc_scalar_add;
l_ecc_scalar_free;
l_ecc_scalar_get_data;