Skip to content

Commit 70157ef

Browse files
jhedbergholtmann
authored andcommitted
Bluetooth: Use debug keys for SMP when HCI_USE_DEBUG_KEYS is set
The HCI_USE_DEBUG_KEYS flag is intended to force our side to always use debug keys for pairing. This means both BR/EDR SSP as well as SMP with LE Secure Connections. This patch updates the SMP code to use the debug keys instead of generating a random local key pair when the flag is set. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
1 parent 1408bb6 commit 70157ef

1 file changed

Lines changed: 18 additions & 9 deletions

File tree

‎net/bluetooth/smp.c‎

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1585,18 +1585,27 @@ static u8 smp_cmd_pairing_req(struct l2cap_conn *conn, struct sk_buff *skb)
15851585

15861586
static u8 sc_send_public_key(struct smp_chan *smp)
15871587
{
1588+
struct hci_dev *hdev = smp->conn->hcon->hdev;
1589+
15881590
BT_DBG("");
15891591

1590-
while (true) {
1591-
/* Generate local key pair for Secure Connections */
1592-
if (!ecc_make_key(smp->local_pk, smp->local_sk))
1593-
return SMP_UNSPECIFIED;
1592+
if (test_bit(HCI_USE_DEBUG_KEYS, &hdev->dev_flags)) {
1593+
BT_DBG("Using debug keys");
1594+
memcpy(smp->local_pk, debug_pk, 64);
1595+
memcpy(smp->local_sk, debug_sk, 32);
1596+
set_bit(SMP_FLAG_DEBUG_KEY, &smp->flags);
1597+
} else {
1598+
while (true) {
1599+
/* Generate local key pair for Secure Connections */
1600+
if (!ecc_make_key(smp->local_pk, smp->local_sk))
1601+
return SMP_UNSPECIFIED;
15941602

1595-
/* This is unlikely, but we need to check that we didn't
1596-
* accidentially generate a debug key.
1597-
*/
1598-
if (memcmp(smp->local_sk, debug_sk, 32))
1599-
break;
1603+
/* This is unlikely, but we need to check that
1604+
* we didn't accidentially generate a debug key.
1605+
*/
1606+
if (memcmp(smp->local_sk, debug_sk, 32))
1607+
break;
1608+
}
16001609
}
16011610

16021611
BT_DBG("Local Public Key X: %32phN", smp->local_pk);

0 commit comments

Comments
 (0)