ecc: moved ecc from IWD into ell
PATCH v4 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) 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).
With this curve object you can create new points or constants. All constructors which take point/constant data expect the input to be in BE ordering. This was done because most of the time this data is coming from the network. Getting point/constant data back out will order the bytes back into BE ordering (internally its stored natively).
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.
--- Makefile.am | 9 +- ell/3rdparty/ecc.c | 934 +++++++++++++++++++++++++++++++++++++++++++++ ell/ecc-private.h | 88 +++++ ell/ecc.c | 371 ++++++++++++++++++ ell/ecc.h | 70 ++++ ell/ell.h | 1 + 6 files changed, 1471 insertions(+), 2 deletions(-) create mode 100644 ell/3rdparty/ecc.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/3rdparty/ecc.c \ + ell/ecc.c ell_libell_la_LDFLAGS = -no-undefined \ -Wl,--version-script=$(top_srcdir)/ell/ell.sym \
ell/3rdparty/ecc.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 +371 -0
371 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
@@ -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 v4 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
@@ -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 v4 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 | 3 +- ell/ecdh.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++ ell/ecdh.h | 51 +++++++++++++++++++++++++ ell/ell.h | 1 + 4 files changed, 160 insertions(+), 1 deletion(-) create mode 100644 ell/ecdh.c create mode 100644 ell/ecdh.h
Makefile.am +2 -1
@@ -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
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 v4 4/5 unit: moved ECDH unit tests from IWD
In reply to James Prestwood--- Makefile.am | 6 +- unit/test-ecdh.c | 163 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 168 insertions(+), 1 deletion(-) create mode 100644 unit/test-ecdh.c
Makefile.am +5 -1
@@ -164,7 +164,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 \
@@ -285,6 +286,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
PATCH v4 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
Hi James,
Quoted 101 lines
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 inecc-private.h. This allows us to create a new fileell/ecc.cwhich 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_pointandl_ecc_constant. The curve object is used to initialize any l_ecc_point/l_ecc_constant. The curve object can be obtained withl_ecc_curve_get(int group); This allows ELL to hide all the implementation details of the curve (byte size and curve parameters).With this curve object you can create new points or constants. All constructors which take point/constant data expect the input to be in BE ordering. This was done because most of the time this data is coming from the network. Getting point/constant data back out will order the bytes back into BE ordering (internally its stored natively).
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.
---Makefile.am | 9 +- ell/3rdparty/ecc.c | 934 +++++++++++++++++++++++++++++++++++++++++++++ ell/ecc-private.h | 88 +++++ ell/ecc.c | 371 ++++++++++++++++++ ell/ecc.h | 70 ++++ ell/ell.h | 1 + 6 files changed, 1471 insertions(+), 2 deletions(-)create mode 100644
ell/3rdparty/ecc.c
create mode 100644ell/ecc-private.h
create mode 100644ell/ecc.c
create mode 100644ell/ecc.hMakefile.am +2
-1@@ -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.laMakefile.am +5
-1@@ -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/3rdparty/ecc.c \ + ell/ecc.c ell_libell_la_LDFLAGS = -no-undefined \ -Wl,--version-script=$(top_srcdir)/ell/ell.sym \ell/3rdparty/ecc.c new file +28
-0@@ -0,0 +1,934 @@ +/* +* Copyright (c) 2013, Kenneth MacKay +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are +* met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h>
ell/3rdparty/ecc.c line 38
Quoted 10 lines
ell/3rdparty/ecc.c new file +10
-0+#endif + +#include <linux/types.h> +#include <stdint.h> +#include <stdbool.h> + +#include "../private.h" +#include "../ecc.h" +#include "../ecc-private.h" +#include "../random.h”
so I am not a big fan of these nested directory structures in the first place and especially not a big fan of the 3rdparty thing.
If we modify the source files to make them compile or use our internal definitions, then it is no longer external code. If it is code that purely external, we can do ell/ecc-external.[ch] or something like that. We can do the same as we do in ell/siphash.c where we take the code as ELL code and acknowledge the original code and its origin.
Lets go back one step and tell me what this is based on? Is this the old BlueZ code or is this the micro-ecc?
Quoted 60 lines
ell/ecc.h new file +54
-0@@ -0,0 +1,70 @@ +/* +* +* Embedded Linux library +* +* Copyright (C) 2018 Intel Corporation. All rights reserved. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +* +*/ + +#ifndef __ELL_ECC_H +#define __ELL_ECC_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define L_ECC_MAX_DIGITS 4 +#define L_ECC_CONSTANT_MAX_BYTES L_ECC_MAX_DIGITS * 8 +#define L_ECC_POINT_MAX_BYTES L_ECC_CONSTANT_MAX_BYTES * 2 + +struct l_ecc_curve; +struct l_ecc_point; +struct l_ecc_constant; + +enum l_ecc_point_type { + L_ECC_POINT_TYPE_COMPLIANT = 0x01, + L_ECC_POINT_TYPE_COMPRESSED_MINUS = 0x02, + L_ECC_POINT_TYPE_COMPRESSED_PLUS = 0x03, + L_ECC_POINT_TYPE_FULL = 0x04, +}; + +const struct l_ecc_curve *l_ecc_curve_get(unsigned int group); + +bool l_ecc_valid_point(const struct l_ecc_curve *curve, + struct l_ecc_point *point); +struct l_ecc_point *l_ecc_point_new(const struct l_ecc_curve *curve); +struct l_ecc_point *l_ecc_point_from_data(const struct l_ecc_curve *curve, + enum l_ecc_point_type type, + const void *data, size_t len); + +ssize_t l_ecc_point_get_x(const struct l_ecc_point *p, void *x, size_t xlen);
ell/ecc.h line 64
Quoted 10 lines
ell/ecc.h new file +10
-0+ssize_t l_ecc_point_get_data (const struct l_ecc_point *p,void *buf,size_t len); +void l_ecc_point_free (struct l_ecc_point *p); + +struct l_ecc_constant *l_ecc_constant_new (const struct l_ecc_curve *curve, +void *buf,size_t len); +struct l_ecc_constant *l_ecc_constant_new_random ( +const struct l_ecc_curve *curve); +ssize_t l_ecc_constant_get_data (const struct l_ecc_constant *c,void *buf, +size_t len); +void l_ecc_constant_free (struct l_ecc_constant *c);
Do we need such a rich API? Can we start with a smaller one for things we actually need from it.
Regards
Marcel
Re: [PATCH v4 3/5] ecdh: moved ECDH from IWD
In reply to James PrestwoodHi James,
Quoted 11 lines
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 | 3 +- ell/ecdh.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++ ell/ecdh.h | 51 +++++++++++++++++++++++++ ell/ell.h | 1 + 4 files changed, 160 insertions(+), 1 deletion(-)create mode 100644
ell/ecdh.c
create mode 100644ell/ecdh.h
you forgot to update ell/ell.sym with the new exported symbols.
Quoted 33 lines
Makefile.am +2
-1@@ -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.laell/ecdh.c new file +12
-0@@ -0,0 +1,106 @@ +/* +* +* Embedded Linux library +* +* Copyright (C) 2018 Intel Corporation. All rights reserved. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful,
ell/ecdh.c line 22
Quoted 10 lines
ell/ecdh.c new file +10
-0+* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +* +*/ +
The HAVE_CONFIG_H block is missing.
Quoted 109 lines
ell/ecdh.c new file +84
-0+#include <stdint.h> + +#include "private.h" +#include "ecc-private.h" +#include "ecc.h" +#include "ecdh.h" +#include "random.h" + +/* +* Some sane maximum for calculating the public key. This *shouldn't* ever be +* reached in normal conditions. +*/ +#define ECDH_MAX_ITERATIONS 20 + +/* +* IETF draft-jivsov-ecc-compact-00 Section 4.2.1 +* +* The following algorithm calculates a key pair {k, Q=k*G=(x,y)}, where k is +* the private key and Q=(x,y) is the public key. +* +* Black box generation: +* 1. Generate a key pair {k, Q=k*G=(x,y)} with KG +* 2. if( y != min(y,p-y) ) goto step 1 +* 3. output {k, Q=(x,y)} as a key pair +*/ +LIB_EXPORT bool l_ecdh_generate_key_pair(const struct l_ecc_curve *curve, +struct l_ecc_constant **out_private, +struct l_ecc_point **out_public) +{ +bool compliant = false; +int iter =0 ; +uint64_t p2[L_ECC_MAX_DIGITS ]; + +_ecc_calculate_p2 (curve, p2); + + *out_public =l_ecc_point_new (curve); + +while (!compliant && iter++ <ECDH_MAX_ITERATIONS ) { + *out_private =l_ecc_constant_new_random (curve); + +_ecc_point_mult (*out_public, &curve->g, (*out_private)->c, +NULL , curve->p); + +/* ensure public key is compliant */ +if (_vli_cmp ((*out_public)->y, p2, curve->ndigits) >=0 ) { + compliant = true; +break ; + } + +l_ecc_constant_free (*out_private); + } + +if (!compliant) { +l_ecc_point_free (*out_public); +return false; + } + +return true; +} + +LIB_EXPORT bool l_ecdh_generate_shared_secret(const struct l_ecc_curve *curve, +const struct l_ecc_constant *private_key, +const struct l_ecc_point *other_public, +struct l_ecc_constant **secret) +{ +struct l_ecc_constant *z; +struct l_ecc_point *product; + +if (unlikely (!curve)) +return false; + + z =l_ecc_constant_new_random (curve); + + product =l_ecc_point_new (curve); + +_ecc_point_mult (product, other_public, private_key->c, z->c, curve->p); + + *secret =_ecc_constant_new (curve, product->x, curve->ndigits *8 ); + +l_ecc_point_free (product); +l_ecc_constant_free (z); + +return true; +}ell/ecdh.h new file +19
-0@@ -0,0 +1,51 @@ +/* +* +* Embedded Linux library +* +* Copyright (C) 2018 Intel Corporation. All rights reserved. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
ell/ecdh.h line 29
Quoted 10 lines
ell/ecdh.h new file +10
-0+* +*/ +#ifndef __ELL_ECDH_H +#define __ELL_ECDH_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include “ecc.h"
We don’t include other header files. Forward define the structs if really needed.
Quoted 27 lines
ell/ecdh.h new file +22
-0+ +/* +* Generate a private/public key pair. private/public are out parameters and +* must be freed. +*/ +bool l_ecdh_generate_key_pair (const struct l_ecc_curve *curve, +struct l_ecc_constant **out_private, +struct l_ecc_point **out_public); +/* +* Generate a shared secret from a private/public key. secret is an out +* parameters and must be freed. +*/ +bool l_ecdh_generate_shared_secret (const struct l_ecc_curve *curve, +const struct l_ecc_constant *private_key, +const struct l_ecc_point *other_public, +struct l_ecc_constant **secret); + +#ifdef __cplusplus +} +#endif + +#endif /* __ELL_ECDH_H */ ell/ell.h +0
-0
ell/ell.h line 61
Quoted 4 lines
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>
Regards
Marcel
Re: [PATCH v4 5/5] gitignore: added ecc/ecdh unit tests
In reply to James PrestwoodHi James,
Quoted 14 lines
---
.gitignore | 2 ++1 file changed, 2 insertions(+).gitignore +0
-0@@ -56,6 +56,8 @@ unit/test-keyunit/test-pbkdf2
unit/test-dhcp
unit/test-dir-watch.gitignore +2
-0+unit/test-ecc +unit/test-ecdh
Quoted 3 lines
unit/cert-*.pem
unit/cert-*.csr
unit/cert-*.srl
have these with the patches that actually add the new binary.
Regards
Marcel
Hi Marcel,
Quoted 3 lines
so I am not a big fan of these nested directory structures in the first place and especially not a big fan of the 3rdparty thing.
If we modify the source files to make them compile or use our internal definitions, then it is no longer external code. If it is code that purely external, we can do ell/ecc-external.[ch] or something like that. We can do the same as we do in
ell/siphash.cwhere we take the code as ELL code and acknowledge the original code and its origin.
So I'd like to separate as much as possible the original 3rd party code from what we ended up adding (which was quite a bit) to it in order to support EAP-PWD/SAE/OWE. I want to make it easier to update this file from external sources if we need to (e.g. as vulnerabilities / bugs are potentially discovered and fixed.) In iwd we created this hodge-podge of the original 3rdparty code + our additions and I don't think that was a good idea.
If you want to keep it in ecc-external.c, that would be fine. 3rdparty subdirectory seems clearer, but whichever accomplishes the above is fine.
Quoted 2 lines
Lets go back one step and tell me what this is based on? Is this the old BlueZ code or is this the micro-ecc?
The code was from BlueZ's version of ecc with slight modifications. And that is another issue. The goal of this is to standardize this across the projects.
Quoted 3 lines
Do we need such a rich API? Can we start with a smaller one for things we actually need from it.
This is about as minimal as we can get for what iwd needs for SAE/OWE/PWD.
Regards,
-Denis
Hi Denis,
Quoted 6 lines
Quoted 2 lines
so I am not a big fan of these nested directory structures in the first place and especially not a big fan of the 3rdparty thing.
If we modify the source files to make them compile or use our internal definitions, then it is no longer external code. If it is code that purely external, we can do ell/ecc-external.[ch] or something like that. We can do the same as we do inell/siphash.cwhere we take the code as ELL code and acknowledge the original code and its origin.So I'd like to separate as much as possible the original 3rd party code from what we ended up adding (which was quite a bit) to it in order to support EAP-PWD/SAE/OWE. I want to make it easier to update this file from external sources if we need to (e.g. as vulnerabilities / bugs are potentially discovered and fixed.) In iwd we created this hodge-podge of the original 3rdparty code + our additions and I don't think that was a good idea.
If you want to keep it in
ecc-external.c, that would be fine. 3rdparty subdirectory seems clearer, but whichever accomplishes the above is fine.
so I have a test tree that uses the latest micro-ecc repository as base. If we want to have an easy path to pull in updates from upstream, then this needs to be uECC.[ch] and friends. However I need to send patches to micro-ecc since it will not build as simple as their README might indicate. Minor details, but they didn’t really test it enough.
Quoted 3 lines
Quoted 1 line
Lets go back one step and tell me what this is based on? Is this the old BlueZ code or is this the micro-ecc?
The code was from BlueZ's version of ecc with slight modifications. And that is another issue. The goal of this is to standardize this across the projects.
That is what I thought. And that code is an old snapshot with only P-256 curve in mind.
Quoted 3 lines
Quoted 1 line
Do we need such a rich API? Can we start with a smaller one for things we actually need from it.
This is about as minimal as we can get for what iwd needs for SAE/OWE/PWD.
Do we want the ECC curve really as struct? Or are we going to have an enum or have them as pre-defined exported symbols. It kind seems pointless have the curves allocated.
Regards
Marcel
Quoted 43 lines · Marcel Holtmann
Hi Denis,
Quoted 17 lines
Quoted 8 lines
so I am not a big fan of these nested directory structures in the first place and especially not a big fan of the 3rdparty thing. If we modify the source files to make them compile or use our internal definitions, then it is no longer external code. If it is code that purely external, we can do ell/ecc-external.[ch] or something like that. We can do the same as we do in
ell/siphash.cwhere we take the code as ELL code and acknowledge the original code and its origin.So I'd like to separate as much as possible the original 3rd party code from what we ended up adding (which was quite a bit) to it in order to support EAP-PWD/SAE/OWE. I want to make it easier to update this file from external sources if we need to (e.g. as vulnerabilities / bugs are potentially discovered and fixed.) In iwd we created this hodge-podge of the original 3rdparty code + our additions and I don't think that was a good idea.
Quoted 3 lines
If you want to keep it in
ecc-external.c, that would be fine. 3rdparty subdirectory seems clearer, but whichever accomplishes the above is fine.so I have a test tree that uses the latest micro-ecc repository as base. If we want to have an easy path to pull in updates from upstream, then this needs to be uECC.[ch] and friends. However I need to send patches to micro-ecc since it will not build as simple as their README might indicate. Minor details, but they didn’t really test it enough.
Quoted 6 lines
Quoted 2 lines
Lets go back one step and tell me what this is based on? Is this the old BlueZ code or is this the micro-ecc?
The code was from BlueZ's version of ecc with slight modifications. And that is another issue. The goal of this is to standardize this across the projects.
That is what I thought. And that code is an old snapshot with only P- 256 curve in mind.
Quoted 3 lines
Quoted 2 lines
Do we need such a rich API? Can we start with a smaller one for things we actually need from it.
Quoted 6 lines
Quoted 2 lines
This is about as minimal as we can get for what iwd needs for SAE/OWE/PWD.
Do we want the ECC curve really as struct? Or are we going to have an enum or have them as pre-defined exported symbols. It kind seems pointless have the curves allocated.
The curves aren't allocated, l_ecc_curve_get() just returns the static struct in the curve list. I did it this way so all the API's that take a curve had direct acccess to all the curve variables (rather than looking up by group number every time).
Quoted 5 lines
Regards
Marcel
Quoted 23 lines · Marcel Holtmann
Hi Denis,
Quoted 17 lines
Quoted 8 lines
so I am not a big fan of these nested directory structures in the first place and especially not a big fan of the 3rdparty thing. If we modify the source files to make them compile or use our internal definitions, then it is no longer external code. If it is code that purely external, we can do ell/ecc-external.[ch] or something like that. We can do the same as we do in
ell/siphash.cwhere we take the code as ELL code and acknowledge the original code and its origin.So I'd like to separate as much as possible the original 3rd party code from what we ended up adding (which was quite a bit) to it in order to support EAP-PWD/SAE/OWE. I want to make it easier to update this file from external sources if we need to (e.g. as vulnerabilities / bugs are potentially discovered and fixed.) In iwd we created this hodge-podge of the original 3rdparty code + our additions and I don't think that was a good idea.
Quoted 3 lines
If you want to keep it in
ecc-external.c, that would be fine. 3rdparty subdirectory seems clearer, but whichever accomplishes the above is fine.
Quoted 6 lines
so I have a test tree that uses the latest micro-ecc repository as base. If we want to have an easy path to pull in updates from upstream, then this needs to be uECC.[ch] and friends. However I need to send patches to micro-ecc since it will not build as simple as their README might indicate. Minor details, but they didn’t really test it enough.
Are you hinting that you would rather use uECC than this implementation? Just looking at a quick glance it would appear uECC does not support P384/P521. It also appears that it only supports ECC to the extent of supporting ECDH. Essentially missing point addition, integer exponentiation, legendre, (maybe more?). All of these operations I have added to the existing implementation in IWD.
Im not saying the same additions couldn't be done for uECC (assuming the maintainer is ok with it), just driving home that uECC will not be a "drop in" replacement for what we already have.
Quoted 25 lines
Quoted 7 lines
Quoted 3 lines
Lets go back one step and tell me what this is based on? Is this the old BlueZ code or is this the micro-ecc?
The code was from BlueZ's version of ecc with slight modifications. And that is another issue. The goal of this is to standardize this across the projects.
That is what I thought. And that code is an old snapshot with only P- 256 curve in mind.
Quoted 5 lines
Quoted 2 lines
Do we need such a rich API? Can we start with a smaller one for things we actually need from it.
This is about as minimal as we can get for what iwd needs for SAE/OWE/PWD.
Do we want the ECC curve really as struct? Or are we going to have an enum or have them as pre-defined exported symbols. It kind seems pointless have the curves allocated.
Regards
Marcel