diff mbox series

[1/2] ecc: add l_ecc_scalar_clone

Message ID 20240313164425.690572-1-prestwoj@gmail.com (mailing list archive)
State Accepted, archived
Headers show
Series [1/2] ecc: add l_ecc_scalar_clone | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-ci-build success Build - Configure
prestwoj/iwd-ci-clang success clang PASS
prestwoj/iwd-ci-makecheckvalgrind success Make Check w/Valgrind
prestwoj/iwd-ci-makecheck success Make Check
prestwoj/iwd-ci-makedistcheck success Make Distcheck
prestwoj/iwd-ci-testrunner success test-runner PASS

Commit Message

James Prestwood March 13, 2024, 4:44 p.m. UTC
---
 ell/ecc.c   | 8 ++++++++
 ell/ecc.h   | 1 +
 ell/ell.sym | 1 +
 3 files changed, 10 insertions(+)

Comments

Denis Kenzior March 18, 2024, 2:31 p.m. UTC | #1
Hi James,

On 3/13/24 11:44, James Prestwood wrote:
> ---
>   ell/ecc.c   | 8 ++++++++
>   ell/ecc.h   | 1 +
>   ell/ell.sym | 1 +
>   3 files changed, 10 insertions(+)

All applied, thanks.

Regards,
-Denis
diff mbox series

Patch

diff --git a/ell/ecc.c b/ell/ecc.c
index 8302347..d8d9c1f 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 5a8cf03..3502b98 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 2c207d6..28b55d3 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;