ecc: moved ecc from IWD into ell
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:
- Changed L_ECC_SCALAR_MAX_BYTES to match l_ecc_scalar change
- Removed l_ecc_valid_point (full points are now verified in constructor)
- scalars/points now hold pointer to curve, and ndigits was removed
--- Makefile.am | 9 +- ell/ecc-external.c | 934 +++++++++++++++++++++++++++++++++++++++++++++ ell/ecc-private.h | 90 +++++ ell/ecc.c | 381 ++++++++++++++++++ ell/ecc.h | 68 ++++ ell/ell.h | 1 + ell/ell.sym | 10 + 7 files changed, 1491 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
@@ -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 +90 -0
90 lines not on this page · raw message
ell/ecc.c new file +381 -0
381 lines not on this page · raw message
ell/ecc.h new file +68 -0
68 lines not on this page · raw message
ell/ell.h +1 -0
@@ -57,3 +57,4 @@#include <ell/dbus-client.h> #include <ell/dhcp.h> #include <ell/cert.h> +#include <ell/ecc.h>
ell/ell.sym +10 -0
@@ -449,6 +449,16 @@ global: l_certchain_foreach_from_ca; l_certchain_find; l_certchain_verify; + l_ecc_curve_get; + 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
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
@@ -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
PATCH v5 3/4 ecdh: moved ECDH from IWD
In reply to James PrestwoodMoved 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
@@ -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
@@ -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
@@ -459,6 +459,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
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 | 161 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 168 insertions(+), 1 deletion(-) create mode 100644 unit/test-ecdh.c
.gitignore +2 -0
@@ -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
@@ -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 +161 -0
161 lines not on this page · raw message
Signature · 1 line
2.17.1