Skip to contentSkip to conversation

ecc: moved ecc from IWD into ell

PATCH Superseded James Prestwood 1 participant 4 messages Dec 10, 2018 Kbuild

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v5 1/4 ecc: moved ecc from IWD into ell

IWD had its own implementation for ECC and math operations. Eventually TLS will indirectly require this (via ECDH) so it made sense to move everything into ell. Some changes had to be made to the original file to accomidate the ell style.

The original file (ecc.c) has remained mostly intact, and was put in ell/3rdparty/ folder. Any internal vli functions that needed to be exposed privately were defined in ecc-private.h. This allows us to create a new file ell/ecc.c which holds all the public APIs, as well as keep the original ECC unit tests.

To create a proper set of ECC APIs three new objects were added, l_ecc_curve, l_ecc_point and l_ecc_constant. The curve object is used to initialize any l_ecc_point/l_ecc_constant. The curve object can be obtained with l_ecc_curve_get(int group); This allows ELL to hide all the implementation details of the curve (byte size and curve parameters).

For now, the API set is limited to only what ECDH requires, but future patches will add a full set of operations needed for other ECC protocols.

v5:
- Renamed l_ecc_constant to l_ecc_scalar
- Fixed some confusing comments/commit message
- Added HAVE_CONFIG_H block
- Added symbols to ell.sym

---
 Makefile.am        |   9 +-
 ell/ecc-external.c | 934 +++++++++++++++++++++++++++++++++++++++++++++
 ell/ecc-private.h  |  88 +++++
 ell/ecc.c          | 378 ++++++++++++++++++
 ell/ecc.h          |  70 ++++
 ell/ell.h          |   1 +
 ell/ell.sym        |  11 +
 7 files changed, 1489 insertions(+), 2 deletions(-)
 create mode 100644 ell/ecc-external.c
 create mode 100644 ell/ecc-private.h
 create mode 100644 ell/ecc.c
 create mode 100644 ell/ecc.h
Makefile.am +7 -2
index d115360..f6ac643 100644
@@ -49,7 +49,8 @@ pkginclude_HEADERS = ell/ell.h \
 			ell/dir.h \
 			ell/net.h \
 			ell/dhcp.h \
-			ell/cert.h
+			ell/cert.h \
+			ell/ecc.h
 
 lib_LTLIBRARIES = ell/libell.la
 
@@ -112,7 +113,11 @@ ell_libell_la_SOURCES = $(linux_headers) \
 			ell/dhcp-transport.c \
 			ell/dhcp-lease.c \
 			ell/cert.c \
-			ell/cert-private.h
+			ell/cert-private.h \
+			ell/ecc-private.h \
+			ell/ecc.h \
+			ell/ecc-external.c \
+			ell/ecc.c
 
 ell_libell_la_LDFLAGS = -no-undefined \
 			-Wl,--version-script=$(top_srcdir)/ell/ell.sym \
ell/ecc-external.c new file +934 -0

934 lines not on this page · raw message

ell/ecc-private.h new file +88 -0

88 lines not on this page · raw message

ell/ecc.c new file +378 -0

378 lines not on this page · raw message

ell/ecc.h new file +70 -0

70 lines not on this page · raw message

ell/ell.h +1 -0
index 4b0eac4..7bc26bc 100644
@@ -57,3 +57,4 @@
 #include <ell/dbus-client.h>
 #include <ell/dhcp.h>
 #include <ell/cert.h>
+#include <ell/ecc.h>
ell/ell.sym +11 -0
index 9cea0c1..a05cd45 100644
@@ -449,6 +449,17 @@ global:
 	l_certchain_foreach_from_ca;
 	l_certchain_find;
 	l_certchain_verify;
+	l_ecc_curve_get;
+	l_ecc_valid_point;
+	l_ecc_point_new;
+	l_ecc_point_from_data;
+	l_ecc_point_get_x;
+	l_ecc_point_get_data;
+	l_ecc_point_free;
+	l_ecc_scalar_new;
+	l_ecc_scalar_new_random;
+	l_ecc_scalar_get_data;
+	l_ecc_scalar_free;
 local:
 	*;
 };
Signature · 1 line
2.17.1
#1 lore raw

PATCH v5 2/4 unit: moved ECC unit tests from IWD

The test was just modified to use the new l_ecc API's

---
 Makefile.am     |   5 +-
 unit/test-ecc.c | 346 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 350 insertions(+), 1 deletion(-)
 create mode 100644 unit/test-ecc.c
Makefile.am +4 -1
index f6ac643..061a36f 100644
@@ -162,7 +162,8 @@ unit_tests = unit/test-unit \
 			unit/test-uuid \
 			unit/test-pbkdf2 \
 			unit/test-dhcp \
-			unit/test-dir-watch
+			unit/test-dir-watch \
+			unit/test-ecc
 
 dbus_tests = unit/test-hwdb \
 			unit/test-dbus \
@@ -281,6 +282,8 @@ unit_test_dhcp_LDADD = ell/libell-private.la
 
 unit_test_dir_watch_LDADD = ell/libell-private.la
 
+unit_test_ecc_LDADD = ell/libell-private.la
+
 if MAINTAINER_MODE
 noinst_LTLIBRARIES += unit/example-plugin.la
 endif
unit/test-ecc.c new file +346 -0

346 lines not on this page · raw message

Signature · 1 line
2.17.1
#2 lore raw

PATCH v5 3/4 ecdh: moved ECDH from IWD

In reply to James Prestwood

Moved the ECDH implementation from IWD. API changes were made to utilize l_ecc_point/l_ecc_constant types, as well as the curve object. Some sanity checks were also added to ensure random keys were within the allowable range.

---
 Makefile.am |   6 ++-
 ell/ecdh.c  | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 ell/ecdh.h  |  53 +++++++++++++++++++++++++
 ell/ell.h   |   1 +
 ell/ell.sym |   2 +
 5 files changed, 169 insertions(+), 2 deletions(-)
 create mode 100644 ell/ecdh.c
 create mode 100644 ell/ecdh.h
Makefile.am +4 -2
index 061a36f..821ddc8 100644
@@ -50,7 +50,8 @@ pkginclude_HEADERS = ell/ell.h \
 			ell/net.h \
 			ell/dhcp.h \
 			ell/cert.h \
-			ell/ecc.h
+			ell/ecc.h \
+			ell/ecdh.h
 
 lib_LTLIBRARIES = ell/libell.la
 
@@ -117,7 +118,8 @@ ell_libell_la_SOURCES = $(linux_headers) \
 			ell/ecc-private.h \
 			ell/ecc.h \
 			ell/ecc-external.c \
-			ell/ecc.c
+			ell/ecc.c \
+			ell/ecdh.c
 
 ell_libell_la_LDFLAGS = -no-undefined \
 			-Wl,--version-script=$(top_srcdir)/ell/ell.sym \
ell/ecdh.c new file +109 -0

109 lines not on this page · raw message

ell/ecdh.h new file +53 -0

53 lines not on this page · raw message

ell/ell.h +1 -0
index 7bc26bc..aab6417 100644
@@ -58,3 +58,4 @@
 #include <ell/dhcp.h>
 #include <ell/cert.h>
 #include <ell/ecc.h>
+#include <ell/ecdh.h>
ell/ell.sym +2 -0
index a05cd45..1ec227f 100644
@@ -460,6 +460,8 @@ global:
 	l_ecc_scalar_new_random;
 	l_ecc_scalar_get_data;
 	l_ecc_scalar_free;
+	l_ecdh_generate_key_pair;
+	l_ecdh_generate_shared_secret;
 local:
 	*;
 };
Signature · 1 line
2.17.1
#3 lore raw

PATCH v5 4/4 unit: moved ECDH unit tests from IWD

In reply to James Prestwood
---
 .gitignore       |   2 +
 Makefile.am      |   6 +-
 unit/test-ecdh.c | 163 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 170 insertions(+), 1 deletion(-)
 create mode 100644 unit/test-ecdh.c
.gitignore +2 -0
index 16725f5..75ab7b2 100644
@@ -56,6 +56,8 @@ unit/test-key
 unit/test-pbkdf2
 unit/test-dhcp
 unit/test-dir-watch
+unit/test-ecc
+unit/test-ecdh
 unit/cert-*.pem
 unit/cert-*.csr
 unit/cert-*.srl
Makefile.am +5 -1
index 821ddc8..8401972 100644
@@ -165,7 +165,8 @@ unit_tests = unit/test-unit \
 			unit/test-pbkdf2 \
 			unit/test-dhcp \
 			unit/test-dir-watch \
-			unit/test-ecc
+			unit/test-ecc \
+			unit/test-ecdh
 
 dbus_tests = unit/test-hwdb \
 			unit/test-dbus \
@@ -286,6 +287,9 @@ unit_test_dir_watch_LDADD = ell/libell-private.la
 
 unit_test_ecc_LDADD = ell/libell-private.la
 
+unit_test_ecdh_LDADD = ell/libell-private.la
+unit_test_ecdh_LDFLAGS = -Wl,-wrap,l_getrandom
+
 if MAINTAINER_MODE
 noinst_LTLIBRARIES += unit/example-plugin.la
 endif
unit/test-ecdh.c new file +163 -0

163 lines not on this page · raw message

Signature · 1 line
2.17.1