aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2014-06-24 08:22:59 -0400
committerMarcel Holtmann <marcel@holtmann.org>2014-12-03 10:51:19 -0500
commit70157ef5391819a55bb4186c901ac873231fb6ea (patch)
treede6873ee8ad998062d63b1f9d05fb2a0eb0fed39 /net/bluetooth
parent1408bb6efb04da3efdc998df1bc032c1d86d1842 (diff)
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>
Diffstat (limited to 'net/bluetooth')
-rw-r--r--net/bluetooth/smp.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index 918ce036cb91..779160485a50 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -1585,18 +1585,27 @@ static u8 smp_cmd_pairing_req(struct l2cap_conn *conn, struct sk_buff *skb)
1585 1585
1586static u8 sc_send_public_key(struct smp_chan *smp) 1586static u8 sc_send_public_key(struct smp_chan *smp)
1587{ 1587{
1588 struct hci_dev *hdev = smp->conn->hcon->hdev;
1589
1588 BT_DBG(""); 1590 BT_DBG("");
1589 1591
1590 while (true) { 1592 if (test_bit(HCI_USE_DEBUG_KEYS, &hdev->dev_flags)) {
1591 /* Generate local key pair for Secure Connections */ 1593 BT_DBG("Using debug keys");
1592 if (!ecc_make_key(smp->local_pk, smp->local_sk)) 1594 memcpy(smp->local_pk, debug_pk, 64);
1593 return SMP_UNSPECIFIED; 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;
1594 1602
1595 /* This is unlikely, but we need to check that we didn't 1603 /* This is unlikely, but we need to check that
1596 * accidentially generate a debug key. 1604 * we didn't accidentially generate a debug key.
1597 */ 1605 */
1598 if (memcmp(smp->local_sk, debug_sk, 32)) 1606 if (memcmp(smp->local_sk, debug_sk, 32))
1599 break; 1607 break;
1608 }
1600 } 1609 }
1601 1610
1602 BT_DBG("Local Public Key X: %32phN", smp->local_pk); 1611 BT_DBG("Local Public Key X: %32phN", smp->local_pk);