ecc: moved ecc from IWD into ell
PATCH v2 1/5 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) required some changes. The ecc_point type is now exposed as l_ecc_point. Several vli_ functions were prefixed with "_" so they could be exposed privately. All ecc functions that needed to be exposed as library API's were prefixed with l_ecc, and changed to take a l_ecc_curve object, explained below.
A new type was also added, l_ecc_curve, which holds all the information for a given curve. Users will call l_curve_get(int group) to get a supported curve object. This curve object can then be passed to all l_ecc API's which avoids the need for the user to know any of the curve parameters (prime, g, n, b, etc.) or vli lengths. Some of these parameters may still need to be obtained, so several getters were added as well.
ECC constants and points are defined as their own types:
l_ecc_point/l_ecc_constant an are initialized with constructors. When constructing, raw input data is expected in big endian byte ordering (this is done because in most cases this data is coming from the network). When getting data back out, (e.g. after a math operation) the data will be automatically swapped back into BE ordering.
Currently, no math or point operations are being exposed publicly. This patch, in its current state, is here to support ECDH.
--- Makefile.am | 8 +- ell/ecc-private.h | 82 +++ ell/ecc.c | 1267 +++++++++++++++++++++++++++++++++++++++++++++ ell/ecc.h | 64 +++ ell/ell.h | 1 + 5 files changed, 1420 insertions(+), 2 deletions(-) create mode 100644 ell/ecc-private.h create mode 100644 ell/ecc.c create mode 100644 ell/ecc.h
Makefile.am +6 -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,10 @@ 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.c ell_libell_la_LDFLAGS = -no-undefined \ -Wl,--version-script=$(top_srcdir)/ell/ell.sym \
ell/ecc-private.h new file +82 -0
82 lines not on this page · raw message
ell/ecc.c new file +1267 -0
1,267 lines not on this page · raw message
ell/ecc.h new file +64 -0
64 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>
Signature · 1 line
2.17.1
PATCH v2 2/5 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
@@ -161,7 +161,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 \
@@ -280,6 +281,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 v2 3/5 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 | 7 +++- ell/ecdh.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++ ell/ecdh.h | 51 +++++++++++++++++++++++++ ell/ell.h | 1 + 4 files changed, 163 insertions(+), 2 deletions(-) create mode 100644 ell/ecdh.c create mode 100644 ell/ecdh.h
Makefile.am +5 -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
@@ -116,7 +117,9 @@ ell_libell_la_SOURCES = $(linux_headers) \ ell/cert-private.h \ ell/ecc-private.h \ ell/ecc.h \ - ell/ecc.c + ell/ecc.c \ + ell/ecdh.h \ + ell/ecdh.c ell_libell_la_LDFLAGS = -no-undefined \ -Wl,--version-script=$(top_srcdir)/ell/ell.sym \
ell/ecdh.c new file +106 -0
106 lines not on this page · raw message
ell/ecdh.h new file +51 -0
51 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>
Signature · 1 line
2.17.1
PATCH v2 4/5 unit: moved ECDH unit tests from IWD
In reply to James Prestwood--- Makefile.am | 6 +- unit/test-ecdh.c | 160 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 165 insertions(+), 1 deletion(-) create mode 100644 unit/test-ecdh.c
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 +160 -0
160 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v2 5/5 gitignore: added ecc/ecdh unit tests
In reply to James Prestwood--- .gitignore | 2 ++ 1 file changed, 2 insertions(+)
.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
Signature · 1 line
2.17.1