shared/ecc: Allow pre-composed Private Keys
PATCH 1/1 shared/ecc: Allow pre-composed Private Keys
If a non-Zero private_key is passed as input to ecc_make_key(), the incoming private_key is attempted, before falling back to an ephemeral key. We need to be able to use non-ephemeral keys in Mesh.
--- src/shared/ecc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
src/shared/ecc.c +6 -2
@@ -863,8 +863,12 @@ bool ecc_make_key(uint8_t public_key[64], uint8_t private_key[32])unsigned tries =0 ; do { - if (!get_random_number(priv) || (tries++ >= MAX_TRIES)) - return false; + if (tries++ == 0) + ecc_bytes2native(private_key, priv); + else { + if (!get_random_number(priv) || (tries >= MAX_TRIES)) + return false; + } if (vli_is_zero(priv)) continue;
Signature · 1 line
2.14.3