From d39fbf5e9cbe71bc95d5bf989e82a01c8fd166b8 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 25 Jun 2019 14:43:15 +0300 Subject: [PATCH] Bluetooth: Mesh: Fix Public Key mismatch error handling Mismatch in Public Key type will cause device to send Invalid Format error, and treat any further PDU's as unexpected. This affects MESH/NODE/PROV/BI-03-C test case. Signed-off-by: Johan Hedberg --- subsys/bluetooth/host/mesh/prov.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/subsys/bluetooth/host/mesh/prov.c b/subsys/bluetooth/host/mesh/prov.c index 0c0a7c134bc..3ad8406facf 100644 --- a/subsys/bluetooth/host/mesh/prov.c +++ b/subsys/bluetooth/host/mesh/prov.c @@ -53,6 +53,9 @@ #define INPUT_OOB_NUMBER 0x02 #define INPUT_OOB_STRING 0x03 +#define PUB_KEY_NO_OOB 0x00 +#define PUB_KEY_OOB 0x01 + #define PROV_ERR_NONE 0x00 #define PROV_ERR_NVAL_PDU 0x01 #define PROV_ERR_NVAL_FMT 0x02 @@ -529,8 +532,8 @@ static void prov_invite(const u8_t *data) /* Supported algorithms - FIPS P-256 Eliptic Curve */ net_buf_simple_add_be16(&buf, BIT(PROV_ALG_P256)); - /* Public Key Type */ - net_buf_simple_add_u8(&buf, 0x00); + /* Public Key Type, Only "No OOB" Public Key is supported */ + net_buf_simple_add_u8(&buf, PUB_KEY_NO_OOB); /* Static OOB Type */ net_buf_simple_add_u8(&buf, prov->static_val ? BIT(0) : 0x00); @@ -729,8 +732,8 @@ static void prov_start(const u8_t *data) return; } - if (data[1] > 0x01) { - BT_ERR("Invalid public key value: 0x%02x", data[1]); + if (data[1] != PUB_KEY_NO_OOB) { + BT_ERR("Invalid public key type: 0x%02x", data[1]); prov_send_fail_msg(PROV_ERR_NVAL_FMT); return; }