From: Marcel Holtmann <marcel@holtmann.org>
To: ell@lists.linux.dev
Subject: [PATCH] ecc: Add helper for multiplying a scalar with a curve generator
Date: Mon, 6 Nov 2023 20:06:38 +0100 [thread overview]
Message-ID: <20231106190638.296812-1-marcel@holtmann.org> (raw)
The SPAKE2+ key exchange protocol requires the ability to multiply a
random number with the curve generator. Instead of exposing the curve
generator expose a helper function that provides the multiplication.
---
ell/ecc.c | 12 ++++++++++++
ell/ecc.h | 2 ++
ell/ell.sym | 1 +
3 files changed, 15 insertions(+)
diff --git a/ell/ecc.c b/ell/ecc.c
index 59bff7bd5af1..ff147b84ed74 100644
--- a/ell/ecc.c
+++ b/ell/ecc.c
@@ -940,6 +940,18 @@ LIB_EXPORT bool l_ecc_point_multiply(struct l_ecc_point *ret,
return true;
}
+LIB_EXPORT bool l_ecc_point_multiply_g(struct l_ecc_point *ret,
+ const struct l_ecc_scalar *scalar)
+{
+ if (unlikely(!ret || !scalar))
+ return false;
+
+ _ecc_point_mult(ret, &scalar->curve->g, scalar->c, NULL,
+ scalar->curve->p);
+
+ return true;
+}
+
LIB_EXPORT bool l_ecc_point_add(struct l_ecc_point *ret,
const struct l_ecc_point *a,
const struct l_ecc_point *b)
diff --git a/ell/ecc.h b/ell/ecc.h
index 2f6faa4e79cd..de116f018b44 100644
--- a/ell/ecc.h
+++ b/ell/ecc.h
@@ -83,6 +83,8 @@ bool l_ecc_scalar_add(struct l_ecc_scalar *ret, const struct l_ecc_scalar *a,
bool l_ecc_point_multiply(struct l_ecc_point *ret,
const struct l_ecc_scalar *scalar,
const struct l_ecc_point *point);
+bool l_ecc_point_multiply_g(struct l_ecc_point *ret,
+ const struct l_ecc_scalar *scalar);
bool l_ecc_point_add(struct l_ecc_point *ret, const struct l_ecc_point *a,
const struct l_ecc_point *b);
bool l_ecc_point_inverse(struct l_ecc_point *p);
diff --git a/ell/ell.sym b/ell/ell.sym
index c457a7620376..0f593e1fc402 100644
--- a/ell/ell.sym
+++ b/ell/ell.sym
@@ -593,6 +593,7 @@ global:
l_ecc_point_get_data;
l_ecc_point_inverse;
l_ecc_point_multiply;
+ l_ecc_point_multiply_g;
l_ecc_point_new;
l_ecc_point_from_sswu;
l_ecc_point_clone;
--
2.41.0
next reply other threads:[~2023-11-06 19:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-06 19:06 Marcel Holtmann [this message]
2023-11-08 2:24 ` [PATCH] ecc: Add helper for multiplying a scalar with a curve generator 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=20231106190638.296812-1-marcel@holtmann.org \
--to=marcel@holtmann.org \
--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).