aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2023-11-06 20:06:38 +0100
committerDenis Kenzior <denkenz@gmail.com>2023-11-07 20:23:44 -0600
commit45e0ca286116bc5fd75ce03aa989b931894ceafc (patch)
tree265ab298be6ee3bdf6eddd3366261f51b8237698
parentc4e8419a9c96f6532ed8028d7d3d62e3940e026d (diff)
ecc: Add helper for multiplying a scalar with a curve generator
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.
-rw-r--r--ell/ecc.c12
-rw-r--r--ell/ecc.h2
-rw-r--r--ell/ell.sym1
3 files changed, 15 insertions, 0 deletions
diff --git a/ell/ecc.c b/ell/ecc.c
index 59bff7bd..ff147b84 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 2f6faa4e..de116f01 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 c457a762..0f593e1f 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;