Skip to content

Commit af86a35

Browse files
lylezhu2012kartben
authored andcommitted
Bluetooth: SMP_BR: Avoid to derive LTK from invalid BR LK
The LTK should not be generated from BR link key if there is a LTK exists and BR LK is weaker. Do not drive LTK from BR LK in the case. Signed-off-by: Lyle Zhu <[email protected]>
1 parent 705491e commit af86a35

File tree

1 file changed

+33
-3
lines changed
  • subsys/bluetooth/host

1 file changed

+33
-3
lines changed

subsys/bluetooth/host/smp.c

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,12 +1133,42 @@ static void smp_br_distribute_keys(struct bt_smp_br *smp)
11331133

11341134
static bool smp_br_pairing_allowed(struct bt_smp_br *smp)
11351135
{
1136-
if (smp->chan.chan.conn->encrypt == 0x02) {
1136+
bt_addr_le_t addr;
1137+
struct bt_conn *conn;
1138+
struct bt_keys_link_key *key;
1139+
bool le_bonded;
1140+
1141+
if (!smp->chan.chan.conn) {
1142+
return false;
1143+
}
1144+
1145+
conn = smp->chan.chan.conn;
1146+
1147+
addr.type = BT_ADDR_LE_PUBLIC;
1148+
bt_addr_copy(&addr.a, &conn->br.dst);
1149+
le_bonded = bt_le_bond_exists(BT_ID_DEFAULT, &addr);
1150+
1151+
key = bt_keys_find_link_key(&conn->br.dst);
1152+
if (!key) {
1153+
return false;
1154+
}
1155+
1156+
/**
1157+
* Core v6.0, Vol 3, Part C, 14.1 Cross-transport key derivation
1158+
*
1159+
* If an LE LTK already exists and the BR/EDR link key is weaker in either strength
1160+
* or MITM protection, then neither device shall generate an LE LTK using cross-transport
1161+
* key derivation from a BR/EDR link key.
1162+
*/
1163+
if (le_bonded && !(key->flags & BT_LINK_KEY_AUTHENTICATED)) {
1164+
return false;
1165+
}
1166+
1167+
if (conn->encrypt == 0x02) {
11371168
return true;
11381169
}
11391170

1140-
if (IS_ENABLED(CONFIG_BT_SMP_FORCE_BREDR) &&
1141-
smp->chan.chan.conn->encrypt == 0x01) {
1171+
if (IS_ENABLED(CONFIG_BT_SMP_FORCE_BREDR) && conn->encrypt == 0x01) {
11421172
LOG_WRN("Allowing BR/EDR SMP with P-192 key");
11431173
return true;
11441174
}

0 commit comments

Comments
 (0)