nimble/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.
This commit is contained in:
Szymon Czapracki
2019-06-25 12:14:37 +02:00
committed by Michał Narajowski
parent bc67ee3966
commit 71191a5c94
+6 -3
View File
@@ -47,6 +47,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
@@ -517,8 +520,8 @@ static void prov_invite(const u8_t *data)
net_buf_simple_add_be16(buf, BIT(PROV_ALG_P256));
/* Public Key Type */
/*PTS OOB*/
net_buf_simple_add_u8(buf, 0x00);
/* 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);
@@ -720,7 +723,7 @@ static void prov_start(const u8_t *data)
return;
}
if (data[1] > 0x01) {
if (data[1] != PUB_KEY_NO_OOB) {
BT_ERR("Invalid public key value: 0x%02x", data[1]);
prov_send_fail_msg(PROV_ERR_NVAL_FMT);
atomic_set_bit(link.flags, LINK_INVALID);