Bluetooth: Allow to re-encrypt link with LE SC key

If P256 key is present use it to start encryption instead of starting
new pairing.

Change-Id: I7c8541359a785e6e22e63cdab5a92a402db83db3
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
This commit is contained in:
Szymon Janc 2015-11-12 13:38:11 +01:00 committed by Anas Nashif
commit d6894af702

View file

@ -160,10 +160,16 @@ static int start_security(struct bt_conn *conn)
case BT_HCI_ROLE_MASTER: case BT_HCI_ROLE_MASTER:
{ {
if (!conn->keys) { if (!conn->keys) {
conn->keys = bt_keys_find(BT_KEYS_LTK, &conn->le.dst); conn->keys = bt_keys_find(BT_KEYS_LTK_P256,
&conn->le.dst);
if (!conn->keys) {
conn->keys = bt_keys_find(BT_KEYS_LTK,
&conn->le.dst);
}
} }
if (!conn->keys || !(conn->keys->keys & BT_KEYS_LTK)) { if (!conn->keys ||
!(conn->keys->keys & (BT_KEYS_LTK | BT_KEYS_LTK_P256))) {
return bt_smp_send_pairing_req(conn); return bt_smp_send_pairing_req(conn);
} }
@ -172,6 +178,7 @@ static int start_security(struct bt_conn *conn)
return bt_smp_send_pairing_req(conn); return bt_smp_send_pairing_req(conn);
} }
/* LE SC LTK and legacy master LTK are stored in same place */
return bt_conn_le_start_encryption(conn, conn->keys->ltk.rand, return bt_conn_le_start_encryption(conn, conn->keys->ltk.rand,
conn->keys->ltk.ediv, conn->keys->ltk.ediv,
conn->keys->ltk.val, conn->keys->ltk.val,