linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Brian Gix <brian.gix@intel.com>
To: linux-bluetooth@vger.kernel.org
Cc: Brian Gix <brian.gix@intel.com>
Subject: [PATCH 1/1] shared/ecc: Allow pre-composed Private Keys
Date: Mon, 23 Apr 2018 15:20:08 -0700	[thread overview]
Message-ID: <20180423222008.19990-1-brian.gix@intel.com> (raw)

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(-)

diff --git a/src/shared/ecc.c b/src/shared/ecc.c
index eb2cc005d..ee592b91b 100644
--- a/src/shared/ecc.c
+++ b/src/shared/ecc.c
@@ -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;
-- 
2.14.3


                 reply	other threads:[~2018-04-23 22:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180423222008.19990-1-brian.gix@intel.com \
    --to=brian.gix@intel.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).