From: Brian Gix <brian.gix@intel.com>
To: linux-bluetooth@vger.kernel.org
Cc: inga.stotland@intel.com, brian.gix@intel.com
Subject: [PATCH BlueZ v2 2/5] nesh: Normalize endian of public/private ECC keys
Date: Wed, 19 May 2021 11:21:47 -0700 [thread overview]
Message-ID: <20210519182150.1680987-3-brian.gix@intel.com> (raw)
In-Reply-To: <20210519182150.1680987-1-brian.gix@intel.com>
The Mesh profile specification defines a Mesh byte order of Big Endian
for Public keys used to calculate shared secrets. Further the
specification sample data also show this same byte order for Private
keys. However, our internal ECDH shared secret calculation requires
Little Endian byte ordering. This fixes our DBus interface, and
debugging output to use Mesh Byte Ordering (Big Endian) for all human
readable input/output.
---
mesh/prov-acceptor.c | 8 +++++++-
mesh/prov-initiator.c | 3 +++
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/mesh/prov-acceptor.c b/mesh/prov-acceptor.c
index e806b12ef..0dbb84f50 100644
--- a/mesh/prov-acceptor.c
+++ b/mesh/prov-acceptor.c
@@ -223,7 +223,11 @@ static bool acp_credentials(struct mesh_prov_acceptor *prov)
print_packet("PublicKeyProv", prov->conf_inputs.prv_pub_key, 64);
print_packet("PublicKeyDev", prov->conf_inputs.dev_pub_key, 64);
+
+ /* Normalize for debug out -- No longer needed for calculations */
+ swap_u256_bytes(prov->private_key);
print_packet("PrivateKeyLocal", prov->private_key, 32);
+
print_packet("ConfirmationInputs", &prov->conf_inputs,
sizeof(prov->conf_inputs));
print_packet("ECDHSecret", prov->secret, 32);
@@ -307,11 +311,13 @@ static void priv_key_cb(void *user_data, int err, uint8_t *key, uint32_t len)
return;
}
+ /* API delivers Mesh byte order, switch to little endian */
+ swap_u256_bytes(key);
memcpy(prov->private_key, key, 32);
ecc_make_public_key(prov->private_key,
prov->conf_inputs.dev_pub_key);
- /* Convert to Mesh byte order */
+ /* Convert Public key to Mesh byte order */
swap_u256_bytes(prov->conf_inputs.dev_pub_key);
swap_u256_bytes(prov->conf_inputs.dev_pub_key + 32);
diff --git a/mesh/prov-initiator.c b/mesh/prov-initiator.c
index ae9c646de..c62577523 100644
--- a/mesh/prov-initiator.c
+++ b/mesh/prov-initiator.c
@@ -222,6 +222,9 @@ static bool int_credentials(struct mesh_prov_initiator *prov)
print_packet("PublicKeyProv", prov->conf_inputs.prv_pub_key, 64);
print_packet("PublicKeyDev", prov->conf_inputs.dev_pub_key, 64);
+
+ /* Print DBG out in Mesh order */
+ swap_u256_bytes(prov->private_key);
print_packet("PrivateKeyLocal", prov->private_key, 32);
print_packet("ConfirmationInputs", &prov->conf_inputs,
sizeof(prov->conf_inputs));
--
2.25.4
next prev parent reply other threads:[~2021-05-19 18:22 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-19 18:21 [PATCH BlueZ v2 0/5] OOB Authentication improvements Brian Gix
2021-05-19 18:21 ` [PATCH BlueZ v2 1/5] mesh: Fix delivery of PB-ACK to acceptors Brian Gix
2021-05-19 18:30 ` Tedd Ho-Jeong An
2021-05-19 18:33 ` Gix, Brian
2021-05-19 19:01 ` OOB Authentication improvements bluez.test.bot
2021-05-19 18:21 ` Brian Gix [this message]
2021-05-19 18:21 ` [PATCH BlueZ v2 3/5] tools/mesh: Add all supported OOB methods to cfgclient Brian Gix
2021-05-19 18:21 ` [PATCH BlueZ v2 4/5] test/mesh: Add support for testing more OOB auth Brian Gix
2021-05-19 18:21 ` [PATCH BlueZ v2 5/5] mesh: Add single threading to prov-acp ob messaging Brian Gix
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=20210519182150.1680987-3-brian.gix@intel.com \
--to=brian.gix@intel.com \
--cc=inga.stotland@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).