aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Prestwood <prestwoj@gmail.com>2024-03-13 09:44:24 -0700
committerDenis Kenzior <denkenz@gmail.com>2024-03-18 09:31:07 -0500
commitf5e27f0085f9b51015d4cd5aa0891f2cfd37e426 (patch)
tree2557d683fcc68fe17779efbfbd3b740e9039e6d2
parent0c9e9d69f97ae8b8eacabfd0cabe38ff6b74f5ee (diff)
ecc: add l_ecc_scalar_clone
-rw-r--r--ell/ecc.c8
-rw-r--r--ell/ecc.h1
-rw-r--r--ell/ell.sym1
3 files changed, 10 insertions, 0 deletions
diff --git a/ell/ecc.c b/ell/ecc.c
index 83023478..d8d9c1ff 100644
--- a/ell/ecc.c
+++ b/ell/ecc.c
@@ -806,6 +806,14 @@ LIB_EXPORT struct l_ecc_scalar *l_ecc_scalar_new(
return NULL;
}
+LIB_EXPORT struct l_ecc_scalar *l_ecc_scalar_clone(const struct l_ecc_scalar *s)
+{
+ if (!s)
+ return NULL;
+
+ return l_memdup(s, sizeof(*s));
+}
+
/*
* Build a scalar = value modulo p where p is the prime number for a given
* curve. bytes can contain a number with up to 2x number of digits as the
diff --git a/ell/ecc.h b/ell/ecc.h
index 5a8cf034..3502b989 100644
--- a/ell/ecc.h
+++ b/ell/ecc.h
@@ -62,6 +62,7 @@ DEFINE_CLEANUP_FUNC(l_ecc_point_free);
struct l_ecc_scalar *l_ecc_scalar_new(const struct l_ecc_curve *curve,
const void *buf, size_t len);
+struct l_ecc_scalar *l_ecc_scalar_clone(const struct l_ecc_scalar *s);
struct l_ecc_scalar *l_ecc_scalar_new_random(
const struct l_ecc_curve *curve);
struct l_ecc_scalar *l_ecc_scalar_new_modp(const struct l_ecc_curve *curve,
diff --git a/ell/ell.sym b/ell/ell.sym
index 2c207d60..28b55d36 100644
--- a/ell/ell.sym
+++ b/ell/ell.sym
@@ -611,6 +611,7 @@ global:
l_ecc_scalar_legendre;
l_ecc_scalar_multiply;
l_ecc_scalar_new;
+ l_ecc_scalar_clone;
l_ecc_scalar_new_random;
l_ecc_scalar_new_modp;
l_ecc_scalar_new_modn;