From bf4560e454081ecd4c4960427e7df9dd56ff09b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Kopy=C5=9Bci=C5=84ski?= Date: Fri, 6 Nov 2020 11:10:17 +0100 Subject: [PATCH] mesh: Provisioning: Reject identical random Adds check for provisioning random values that are identical to our own, and terminates the provisioning procedure. this is port of fc4fe09966059e79182279da5d8dd4348f5b513d --- nimble/host/mesh/src/prov.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nimble/host/mesh/src/prov.c b/nimble/host/mesh/src/prov.c index a75ba7f26..2d2b15fa4 100644 --- a/nimble/host/mesh/src/prov.c +++ b/nimble/host/mesh/src/prov.c @@ -919,6 +919,12 @@ static void prov_random(const uint8_t *data) BT_DBG("Remote Random: %s", bt_hex(data, 16)); + if (!memcmp(data, link.rand, 16)) { + BT_ERR("Random value is identical to ours, rejecting."); + prov_fail(PROV_ERR_CFM_FAILED); + return; + } + if (bt_mesh_prov_conf(link.conf_key, data, link.auth, conf_verify)) { BT_ERR("Unable to calculate confirmation verification"); prov_fail(PROV_ERR_UNEXP_ERR);