aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/smp.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2014-02-19 07:57:46 -0500
committerMarcel Holtmann <marcel@holtmann.org>2014-02-19 11:04:24 -0500
commit23d0e128e38049734c7ecc0987de02486d1ded3e (patch)
tree636b06843ff7642d7072d13d4014a492f4284625 /net/bluetooth/smp.c
parentba74b666b5e581ef3d4912af73774fab48c03198 (diff)
Bluetooth: Track SMP keys in the SMP context
As preparation to do mgmt notification in a single place at the end of the key distribution, store the keys that need to be notified within the SMP context. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/smp.c')
-rw-r--r--net/bluetooth/smp.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index 27eebca260fa..eaac54be91b1 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -915,6 +915,7 @@ static int smp_cmd_master_ident(struct l2cap_conn *conn, struct sk_buff *skb)
915 struct smp_chan *smp = conn->smp_chan; 915 struct smp_chan *smp = conn->smp_chan;
916 struct hci_dev *hdev = conn->hcon->hdev; 916 struct hci_dev *hdev = conn->hcon->hdev;
917 struct hci_conn *hcon = conn->hcon; 917 struct hci_conn *hcon = conn->hcon;
918 struct smp_ltk *ltk;
918 u8 authenticated; 919 u8 authenticated;
919 920
920 BT_DBG("conn %p", conn); 921 BT_DBG("conn %p", conn);
@@ -930,9 +931,10 @@ static int smp_cmd_master_ident(struct l2cap_conn *conn, struct sk_buff *skb)
930 931
931 hci_dev_lock(hdev); 932 hci_dev_lock(hdev);
932 authenticated = (hcon->sec_level == BT_SECURITY_HIGH); 933 authenticated = (hcon->sec_level == BT_SECURITY_HIGH);
933 hci_add_ltk(hdev, &hcon->dst, hcon->dst_type, HCI_SMP_LTK, 1, 934 ltk = hci_add_ltk(hdev, &hcon->dst, hcon->dst_type, HCI_SMP_LTK, 1,
934 authenticated, smp->tk, smp->enc_key_size, 935 authenticated, smp->tk, smp->enc_key_size,
935 rp->ediv, rp->rand); 936 rp->ediv, rp->rand);
937 smp->ltk = ltk;
936 if (!(smp->remote_key_dist & SMP_DIST_ID_KEY)) 938 if (!(smp->remote_key_dist & SMP_DIST_ID_KEY))
937 smp_distribute_keys(conn, 1); 939 smp_distribute_keys(conn, 1);
938 hci_dev_unlock(hdev); 940 hci_dev_unlock(hdev);
@@ -988,8 +990,8 @@ static int smp_cmd_ident_addr_info(struct l2cap_conn *conn,
988 else 990 else
989 bacpy(&rpa, BDADDR_ANY); 991 bacpy(&rpa, BDADDR_ANY);
990 992
991 hci_add_irk(conn->hcon->hdev, &smp->id_addr, smp->id_addr_type, 993 smp->remote_irk = hci_add_irk(conn->hcon->hdev, &smp->id_addr,
992 smp->irk, &rpa); 994 smp->id_addr_type, smp->irk, &rpa);
993 995
994 /* Track the connection based on the Identity Address from now on */ 996 /* Track the connection based on the Identity Address from now on */
995 bacpy(&hcon->dst, &smp->id_addr); 997 bacpy(&hcon->dst, &smp->id_addr);
@@ -1137,6 +1139,7 @@ int smp_distribute_keys(struct l2cap_conn *conn, __u8 force)
1137 struct smp_cmd_encrypt_info enc; 1139 struct smp_cmd_encrypt_info enc;
1138 struct smp_cmd_master_ident ident; 1140 struct smp_cmd_master_ident ident;
1139 struct hci_conn *hcon = conn->hcon; 1141 struct hci_conn *hcon = conn->hcon;
1142 struct smp_ltk *ltk;
1140 u8 authenticated; 1143 u8 authenticated;
1141 __le16 ediv; 1144 __le16 ediv;
1142 1145
@@ -1147,9 +1150,11 @@ int smp_distribute_keys(struct l2cap_conn *conn, __u8 force)
1147 smp_send_cmd(conn, SMP_CMD_ENCRYPT_INFO, sizeof(enc), &enc); 1150 smp_send_cmd(conn, SMP_CMD_ENCRYPT_INFO, sizeof(enc), &enc);
1148 1151
1149 authenticated = hcon->sec_level == BT_SECURITY_HIGH; 1152 authenticated = hcon->sec_level == BT_SECURITY_HIGH;
1150 hci_add_ltk(hcon->hdev, &hcon->dst, hcon->dst_type, 1153 ltk = hci_add_ltk(hcon->hdev, &hcon->dst, hcon->dst_type,
1151 HCI_SMP_LTK_SLAVE, 1, authenticated, 1154 HCI_SMP_LTK_SLAVE, 1, authenticated,
1152 enc.ltk, smp->enc_key_size, ediv, ident.rand); 1155 enc.ltk, smp->enc_key_size, ediv,
1156 ident.rand);
1157 smp->slave_ltk = ltk;
1153 1158
1154 ident.ediv = ediv; 1159 ident.ediv = ediv;
1155 1160