Bluetooth: host: Fix fixed passkey for legacy pairing

Fix fixed passkey for legacy pairing. The pairing procedure fails
because the temporary key (TK) has not been set for this pairing
procedure.

Fix this by always requesting the legacy TK.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit is contained in:
Joakim Andersson 2020-12-10 10:55:19 +01:00 committed by Anas Nashif
commit 971404eee9

View file

@ -2381,6 +2381,11 @@ static uint8_t legacy_pairing_req(struct bt_smp *smp)
BT_DBG(""); BT_DBG("");
ret = legacy_request_tk(smp);
if (ret) {
return ret;
}
/* ask for consent if pairing is not due to sending SecReq*/ /* ask for consent if pairing is not due to sending SecReq*/
if ((DISPLAY_FIXED(smp) || smp->method == JUST_WORKS) && if ((DISPLAY_FIXED(smp) || smp->method == JUST_WORKS) &&
!atomic_test_bit(smp->flags, SMP_FLAG_SEC_REQ) && !atomic_test_bit(smp->flags, SMP_FLAG_SEC_REQ) &&
@ -2391,13 +2396,7 @@ static uint8_t legacy_pairing_req(struct bt_smp *smp)
} }
atomic_set_bit(&smp->allowed_cmds, BT_SMP_CMD_PAIRING_CONFIRM); atomic_set_bit(&smp->allowed_cmds, BT_SMP_CMD_PAIRING_CONFIRM);
ret = send_pairing_rsp(smp); return send_pairing_rsp(smp);
if (ret) {
return ret;
}
return legacy_request_tk(smp);
} }
#endif /* CONFIG_BT_PERIPHERAL */ #endif /* CONFIG_BT_PERIPHERAL */
@ -2609,6 +2608,11 @@ static uint8_t legacy_pairing_rsp(struct bt_smp *smp)
BT_DBG(""); BT_DBG("");
ret = legacy_request_tk(smp);
if (ret) {
return ret;
}
/* ask for consent if this is due to received SecReq */ /* ask for consent if this is due to received SecReq */
if ((DISPLAY_FIXED(smp) || smp->method == JUST_WORKS) && if ((DISPLAY_FIXED(smp) || smp->method == JUST_WORKS) &&
atomic_test_bit(smp->flags, SMP_FLAG_SEC_REQ) && atomic_test_bit(smp->flags, SMP_FLAG_SEC_REQ) &&
@ -2618,11 +2622,6 @@ static uint8_t legacy_pairing_rsp(struct bt_smp *smp)
return 0; return 0;
} }
ret = legacy_request_tk(smp);
if (ret) {
return ret;
}
if (!atomic_test_bit(smp->flags, SMP_FLAG_USER)) { if (!atomic_test_bit(smp->flags, SMP_FLAG_USER)) {
atomic_set_bit(&smp->allowed_cmds, BT_SMP_CMD_PAIRING_CONFIRM); atomic_set_bit(&smp->allowed_cmds, BT_SMP_CMD_PAIRING_CONFIRM);
atomic_set_bit(&smp->allowed_cmds, BT_SMP_KEYPRESS_NOTIFICATION); atomic_set_bit(&smp->allowed_cmds, BT_SMP_KEYPRESS_NOTIFICATION);