mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-11-04 11:32:47 +00:00
mesh: Fix send input_complete before public key
According Mesh Profile Spec 5.4.2.4 Authentication, if device use Input OOB Authentication method, should send input complete pub after local public key has been acked. `bt_mesh_input_string` or `bt_mesh_input_number` directly send `input_complete`, however does not check whether the pub key has been sent. Mesh Provisioning timeout set to `60` seconds, so even this probability is extremely low, it does not mean that there is no such probability. this is port of 4cc8cb1c1513033e8aa6d9c1086456a062c9bc57
This commit is contained in:
committed by
Łukasz Rymanowski
parent
97023e6b89
commit
f0a80d06e8
@@ -63,12 +63,14 @@
|
||||
#define PROV_ALG_P256 0x00
|
||||
|
||||
enum {
|
||||
WAIT_PUB_KEY, /* Waiting for local PubKey to be generated */
|
||||
LINK_ACTIVE, /* Link has been opened */
|
||||
WAIT_NUMBER, /* Waiting for number input from user */
|
||||
WAIT_STRING, /* Waiting for string input from user */
|
||||
NOTIFY_INPUT_COMPLETE, /* Notify that input has been completed. */
|
||||
PROVISIONER, /* The link was opened as provisioner */
|
||||
WAIT_PUB_KEY, /* Waiting for local PubKey to be generated */
|
||||
LINK_ACTIVE, /* Link has been opened */
|
||||
WAIT_NUMBER, /* Waiting for number input from user */
|
||||
WAIT_STRING, /* Waiting for string input from user */
|
||||
NOTIFY_INPUT_COMPLETE, /* Notify that input has been completed. */
|
||||
PROVISIONER, /* The link was opened as provisioner */
|
||||
PUB_KEY_SENT, /* Public key has been sent */
|
||||
INPUT_COMPLETE, /* Device input completed */
|
||||
|
||||
NUM_FLAGS,
|
||||
};
|
||||
@@ -589,6 +591,15 @@ static void send_input_complete(void)
|
||||
os_mbuf_free_chain(buf);
|
||||
}
|
||||
|
||||
static void input_complete(void)
|
||||
{
|
||||
if (atomic_test_bit(link.flags, PUB_KEY_SENT)) {
|
||||
send_input_complete();
|
||||
} else {
|
||||
atomic_set_bit(link.flags, INPUT_COMPLETE);
|
||||
}
|
||||
}
|
||||
|
||||
int bt_mesh_input_number(uint32_t num)
|
||||
{
|
||||
BT_DBG("%u", (unsigned) num);
|
||||
@@ -599,11 +610,21 @@ int bt_mesh_input_number(uint32_t num)
|
||||
|
||||
sys_put_be32(num, &link.auth[12]);
|
||||
|
||||
send_input_complete();
|
||||
input_complete();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void public_key_sent(int err, void *cb_data)
|
||||
{
|
||||
atomic_set_bit(link.flags, PUB_KEY_SENT);
|
||||
|
||||
if (atomic_test_bit(link.flags, INPUT_COMPLETE)) {
|
||||
send_input_complete();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int bt_mesh_input_string(const char *str)
|
||||
{
|
||||
BT_DBG("%s", str);
|
||||
@@ -647,7 +668,7 @@ static void send_pub_key(void)
|
||||
memcpy(&link.conf_inputs[81], &buf->om_data[1], 64);
|
||||
}
|
||||
|
||||
if (prov_send(buf, NULL)) {
|
||||
if (prov_send(buf, public_key_sent)) {
|
||||
BT_ERR("Failed to send Public Key");
|
||||
goto done;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user