From: James Prestwood <prestwoj@gmail.com>
To: ell@lists.linux.dev
Cc: James Prestwood <prestwoj@gmail.com>
Subject: [PATCH] ecc: add l_ecc_point_is_infinity
Date: Thu, 12 Oct 2023 06:38:12 -0700 [thread overview]
Message-ID: <20231012133812.139893-1-prestwoj@gmail.com> (raw)
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.
---
ell/ecc.c | 5 +++++
ell/ecc.h | 1 +
ell/ell.sym | 1 +
3 files changed, 7 insertions(+)
diff --git a/ell/ecc.c b/ell/ecc.c
index 73ddb96..518f405 100644
--- a/ell/ecc.c
+++ b/ell/ecc.c
@@ -1026,3 +1026,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 981bf95..2c2c73a 100644
--- a/ell/ecc.h
+++ b/ell/ecc.h
@@ -114,6 +114,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 7b5caa1..84c45b1 100644
--- a/ell/ell.sym
+++ b/ell/ell.sym
@@ -594,6 +594,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;
--
2.25.1
next reply other threads:[~2023-10-12 13:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-12 13:38 James Prestwood [this message]
2023-10-17 15:00 ` [PATCH] ecc: add l_ecc_point_is_infinity Denis Kenzior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231012133812.139893-1-prestwoj@gmail.com \
--to=prestwoj@gmail.com \
--cc=ell@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).