Skip to contentSkip to conversation

shared/ecc: Allow pre-composed Private Keys

PATCH Superseded Brian Gix 1 participant 1 message Apr 23, 2018 Bluetooth drivers

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Brian Gix

author
#0 lore raw

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
index eb2cc005d..ee592b91b 100644
@@ -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