Skip to content

Commit 2a8118c

Browse files
HaavardReidkalowsk
authored andcommitted
Bluetooth: Host: Update LE legacy pairing check
Updates the LE legacy pairing procedure as a result of errata ES-24491. New part: If the initiating device receives an LP_CONFIRM_R value that is equal to the LP_CONFIRM_I value, the pairing process shall be aborted and fail with "Confirm Value Failed" as reason. Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
1 parent 3c93678 commit 2a8118c

File tree

1 file changed

+17
-4
lines changed
  • subsys/bluetooth/host

1 file changed

+17
-4
lines changed

subsys/bluetooth/host/smp.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2555,22 +2555,35 @@ static uint8_t legacy_pairing_req(struct bt_smp *smp)
25552555
static uint8_t legacy_pairing_random(struct bt_smp *smp)
25562556
{
25572557
struct bt_conn *conn = smp->chan.chan.conn;
2558-
uint8_t tmp[16];
2558+
uint8_t tmp[16], cfm_i[16];
25592559
int err;
25602560

25612561
LOG_DBG("");
25622562

2563-
/* calculate confirmation */
2563+
/* calculate LP_CONFIRM_R */
25642564
err = smp_c1(smp->tk, smp->rrnd, smp->preq, smp->prsp,
25652565
&conn->le.init_addr, &conn->le.resp_addr, tmp);
25662566
if (err) {
25672567
return BT_SMP_ERR_UNSPECIFIED;
25682568
}
25692569

2570+
/* calculate LP_CONFIRM_I */
2571+
err = smp_c1(smp->tk, smp->prnd, smp->preq, smp->prsp,
2572+
&conn->le.init_addr, &conn->le.resp_addr, cfm_i);
2573+
if (err) {
2574+
return BT_SMP_ERR_UNSPECIFIED;
2575+
}
2576+
25702577
LOG_DBG("pcnf %s", bt_hex(smp->pcnf, 16));
2571-
LOG_DBG("cfm %s", bt_hex(tmp, 16));
2578+
LOG_DBG("cfm (remote) %s", bt_hex(tmp, 16));
2579+
LOG_DBG("cfm (local) %s", bt_hex(cfm_i, 16));
25722580

2573-
if (memcmp(smp->pcnf, tmp, sizeof(smp->pcnf))) {
2581+
/* Core Specification, Vol 3, Part H, section 2.3.5.5 (Errata ES-24491): If the computed
2582+
* LP_CONFIRM_R value is not equal to the received LP_CONFIRM_R value, or the received
2583+
* LP_CONFIRM_R value is equal to the LP_CONFIRM_I value, fail pairing.
2584+
*/
2585+
if (memcmp(smp->pcnf, tmp, sizeof(smp->pcnf)) ||
2586+
!memcmp(smp->pcnf, cfm_i, sizeof(smp->pcnf))) {
25742587
return BT_SMP_ERR_CONFIRM_FAILED;
25752588
}
25762589

0 commit comments

Comments
 (0)