From d6894af7029b04cd326249261a6ad1206546fe3b Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Thu, 12 Nov 2015 13:38:11 +0100 Subject: [PATCH] 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 --- net/bluetooth/conn.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/conn.c b/net/bluetooth/conn.c index 81f3b29a76c..788903d0532 100644 --- a/net/bluetooth/conn.c +++ b/net/bluetooth/conn.c @@ -160,10 +160,16 @@ static int start_security(struct bt_conn *conn) case BT_HCI_ROLE_MASTER: { 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); } @@ -172,6 +178,7 @@ static int start_security(struct bt_conn *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, conn->keys->ltk.ediv, conn->keys->ltk.val,