From: Michael Brudevold <puffy.taco@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Michael Brudevold <michael.brudevold@veranexsolutions.com>
Subject: [PATCH v2 1/3] eir: parse data types for LE OOB pairing
Date: Fri, 10 Jun 2022 17:11:22 -0500 [thread overview]
Message-ID: <20220610221124.18591-2-puffy.taco@gmail.com> (raw)
In-Reply-To: <20220610221124.18591-1-puffy.taco@gmail.com>
From: Michael Brudevold <michael.brudevold@veranexsolutions.com>
LE support added for P-256 and split out from existing BREDR support for
P-192
Also attempt to free any existing values before setting new values
---
plugins/neard.c | 8 ++++----
src/eir.c | 41 +++++++++++++++++++++++++++++++++++------
src/eir.h | 10 ++++++++--
3 files changed, 47 insertions(+), 12 deletions(-)
diff --git a/plugins/neard.c b/plugins/neard.c
index 99762482c..11d9e91c4 100644
--- a/plugins/neard.c
+++ b/plugins/neard.c
@@ -352,11 +352,11 @@ static int process_eir(uint8_t *eir, size_t size, struct oob_params *remote)
remote->services = eir_data.services;
eir_data.services = NULL;
- remote->hash = eir_data.hash;
- eir_data.hash = NULL;
+ remote->hash = eir_data.hash192;
+ eir_data.hash192 = NULL;
- remote->randomizer = eir_data.randomizer;
- eir_data.randomizer = NULL;
+ remote->randomizer = eir_data.randomizer192;
+ eir_data.randomizer192 = NULL;
eir_data_free(&eir_data);
diff --git a/src/eir.c b/src/eir.c
index 2f9ee036f..79d423074 100644
--- a/src/eir.c
+++ b/src/eir.c
@@ -53,10 +53,14 @@ void eir_data_free(struct eir_data *eir)
eir->services = NULL;
g_free(eir->name);
eir->name = NULL;
- free(eir->hash);
- eir->hash = NULL;
- free(eir->randomizer);
- eir->randomizer = NULL;
+ free(eir->hash192);
+ eir->hash192 = NULL;
+ free(eir->randomizer192);
+ eir->randomizer192 = NULL;
+ free(eir->hash256);
+ eir->hash256 = NULL;
+ free(eir->randomizer256);
+ eir->randomizer256 = NULL;
g_slist_free_full(eir->msd_list, g_free);
eir->msd_list = NULL;
g_slist_free_full(eir->sd_list, sd_free);
@@ -323,13 +327,15 @@ void eir_parse(struct eir_data *eir, const uint8_t *eir_data, uint8_t eir_len)
case EIR_SSP_HASH:
if (data_len < 16)
break;
- eir->hash = util_memdup(data, 16);
+ free(eir->hash192);
+ eir->hash192 = util_memdup(data, 16);
break;
case EIR_SSP_RANDOMIZER:
if (data_len < 16)
break;
- eir->randomizer = util_memdup(data, 16);
+ free(eir->randomizer192);
+ eir->randomizer192 = util_memdup(data, 16);
break;
case EIR_DEVICE_ID:
@@ -342,6 +348,15 @@ void eir_parse(struct eir_data *eir, const uint8_t *eir_data, uint8_t eir_len)
eir->did_version = data[6] | (data[7] << 8);
break;
+ case EIR_LE_DEVICE_ADDRESS:
+ if (data_len < sizeof(bdaddr_t) + 1)
+ break;
+
+ memcpy(&eir->addr, data, sizeof(bdaddr_t));
+ eir->addr_type = data[sizeof(bdaddr_t)] & 0x1 ?
+ BDADDR_LE_RANDOM : BDADDR_LE_PUBLIC;
+ break;
+
case EIR_SVC_DATA16:
eir_parse_uuid16_data(eir, data, data_len);
break;
@@ -354,6 +369,20 @@ void eir_parse(struct eir_data *eir, const uint8_t *eir_data, uint8_t eir_len)
eir_parse_uuid128_data(eir, data, data_len);
break;
+ case EIR_LE_SC_CONF:
+ if (data_len < 16)
+ break;
+ free(eir->hash256);
+ eir->hash256 = util_memdup(data, 16);
+ break;
+
+ case EIR_LE_SC_RAND:
+ if (data_len < 16)
+ break;
+ free(eir->randomizer256);
+ eir->randomizer256 = util_memdup(data, 16);
+ break;
+
case EIR_MANUFACTURER_DATA:
eir_parse_msd(eir, data, data_len);
break;
diff --git a/src/eir.h b/src/eir.h
index 6154e23ec..b2cf00f37 100644
--- a/src/eir.h
+++ b/src/eir.h
@@ -33,9 +33,12 @@
#define EIR_PUB_TRGT_ADDR 0x17 /* LE: Public Target Address */
#define EIR_RND_TRGT_ADDR 0x18 /* LE: Random Target Address */
#define EIR_GAP_APPEARANCE 0x19 /* GAP appearance */
+#define EIR_LE_DEVICE_ADDRESS 0x1B /* LE: Bluetooth Device Address */
#define EIR_SOLICIT32 0x1F /* LE: Solicit UUIDs, 32-bit */
#define EIR_SVC_DATA32 0x20 /* LE: Service data, 32-bit UUID */
#define EIR_SVC_DATA128 0x21 /* LE: Service data, 128-bit UUID */
+#define EIR_LE_SC_CONF 0x22 /* LE: Secure Connections Confirmation Value */
+#define EIR_LE_SC_RAND 0x23 /* LE: Secure Connections Random Value */
#define EIR_TRANSPORT_DISCOVERY 0x26 /* Transport Discovery Service */
#define EIR_MANUFACTURER_DATA 0xFF /* Manufacturer Specific Data */
@@ -77,9 +80,12 @@ struct eir_data {
uint16_t appearance;
bool name_complete;
int8_t tx_power;
- uint8_t *hash;
- uint8_t *randomizer;
+ uint8_t *hash192;
+ uint8_t *randomizer192;
+ uint8_t *hash256;
+ uint8_t *randomizer256;
bdaddr_t addr;
+ uint8_t addr_type;
uint16_t did_vendor;
uint16_t did_product;
uint16_t did_version;
--
2.25.1
next prev parent reply other threads:[~2022-06-10 22:12 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-10 22:11 [PATCH v2 0/3] LE OOB pairing support Michael Brudevold
2022-06-10 22:11 ` Michael Brudevold [this message]
2022-06-11 0:37 ` bluez.test.bot
2022-06-11 20:27 ` [PATCH v2 1/3] eir: parse data types for LE OOB pairing Luiz Augusto von Dentz
2022-06-13 21:42 ` Mike Brudevold
2022-06-13 21:55 ` Luiz Augusto von Dentz
2022-06-13 22:28 ` Mike Brudevold
2022-06-21 18:57 ` Luiz Augusto von Dentz
2022-06-21 19:50 ` Mike Brudevold
2022-06-10 22:11 ` [PATCH v2 2/3] Accept LE formatted EIR data with neard plugin Michael Brudevold
2022-06-10 22:11 ` [PATCH v2 3/3] neard: Update D-Bus path and interface Michael Brudevold
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=20220610221124.18591-2-puffy.taco@gmail.com \
--to=puffy.taco@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=michael.brudevold@veranexsolutions.com \
/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).