Skip to content

Commit 9fb22af

Browse files
Johan Hedbergnashif
authored andcommitted
Bluetooth: Mesh: Generate new public key for each provisioning session
Mesh Profile Spec v1.0.1 Section 5.4.2.3: "If the public key was not available using an OOB technology, then the public keys are exchanged between the Provisioner and the unprovisioned device. For each exchange, a new key pair shall be generated by the Provisioner and the unprovisioned device." This allows passing MESH/NODE/PROV/BV-12-C. Signed-off-by: Johan Hedberg <[email protected]>
1 parent f35dc9c commit 9fb22af

File tree

1 file changed

+18
-18
lines changed
  • subsys/bluetooth/host/mesh

1 file changed

+18
-18
lines changed

subsys/bluetooth/host/mesh/prov.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,15 @@ static struct prov_link link;
193193

194194
static const struct bt_mesh_prov *prov;
195195

196-
static void reset_state(void)
196+
static void pub_key_ready(const u8_t *pkey);
197+
198+
static int reset_state(void)
197199
{
200+
static struct bt_pub_key_cb pub_key_cb = {
201+
.func = pub_key_ready,
202+
};
203+
int err;
204+
198205
k_delayed_work_cancel(&link.prot_timer);
199206

200207
/* Disable Attention Timer if it was set */
@@ -226,6 +233,14 @@ static void reset_state(void)
226233
/* Clear everything except the protocol timer (k_delayed_work) */
227234
(void)memset(&link, 0, offsetof(struct prov_link, prot_timer));
228235
#endif /* PB_ADV */
236+
237+
err = bt_pub_key_gen(&pub_key_cb);
238+
if (err) {
239+
BT_ERR("Failed to generate public key (%d)", err);
240+
return err;
241+
}
242+
243+
return 0;
229244
}
230245

231246
#if defined(CONFIG_BT_MESH_PB_ADV)
@@ -1541,9 +1556,7 @@ int bt_mesh_pb_gatt_close(struct bt_conn *conn)
15411556
prov->link_close(BT_MESH_PROV_GATT);
15421557
}
15431558

1544-
reset_state();
1545-
1546-
return 0;
1559+
return reset_state();
15471560
}
15481561
#endif /* CONFIG_BT_MESH_PB_GATT */
15491562

@@ -1580,33 +1593,20 @@ static void protocol_timeout(struct k_work *work)
15801593

15811594
int bt_mesh_prov_init(const struct bt_mesh_prov *prov_info)
15821595
{
1583-
static struct bt_pub_key_cb pub_key_cb = {
1584-
.func = pub_key_ready,
1585-
};
1586-
int err;
1587-
15881596
if (!prov_info) {
15891597
BT_ERR("No provisioning context provided");
15901598
return -EINVAL;
15911599
}
15921600

15931601
k_delayed_work_init(&link.prot_timer, protocol_timeout);
15941602

1595-
err = bt_pub_key_gen(&pub_key_cb);
1596-
if (err) {
1597-
BT_ERR("Failed to generate public key (%d)", err);
1598-
return err;
1599-
}
1600-
16011603
prov = prov_info;
16021604

16031605
#if defined(CONFIG_BT_MESH_PB_ADV)
16041606
k_delayed_work_init(&link.tx.retransmit, prov_retransmit);
16051607
#endif
16061608

1607-
reset_state();
1608-
1609-
return 0;
1609+
return reset_state();
16101610
}
16111611

16121612
void bt_mesh_prov_complete(u16_t net_idx, u16_t addr)

0 commit comments

Comments
 (0)