aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/smp.c
diff options
context:
space:
mode:
authorVinicius Costa Gomes <vinicius.gomes@openbossa.org>2011-06-09 17:50:43 -0400
committerGustavo F. Padovan <padovan@profusion.mobi>2011-06-13 14:48:22 -0400
commit3a0259bb80cec7595a2d085a150412d23ba28c81 (patch)
treeeec4da988424125848d09261a015f8930a3b96c6 /net/bluetooth/smp.c
parent88ba43b662b6b944c6278ad81a114fa559807776 (diff)
Bluetooth: Add support for using the crypto subsystem
This will allow using the crypto subsystem for encrypting data. As SMP (Security Manager Protocol) is implemented almost entirely on the host side and the crypto module already implements the needed methods (AES-128), it makes sense to use it. There's now a new module option to enable/disable SMP support. Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@openbossa.org> Signed-off-by: Anderson Briglia <anderson.briglia@openbossa.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net/bluetooth/smp.c')
-rw-r--r--net/bluetooth/smp.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index 2240e96552f1..aa20bee97501 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -154,9 +154,13 @@ static void smp_cmd_security_req(struct l2cap_conn *conn, struct sk_buff *skb)
154 154
155int smp_conn_security(struct l2cap_conn *conn, __u8 sec_level) 155int smp_conn_security(struct l2cap_conn *conn, __u8 sec_level)
156{ 156{
157 struct hci_conn *hcon = conn->hcon;
157 __u8 authreq; 158 __u8 authreq;
158 159
159 BT_DBG("conn %p hcon %p level 0x%2.2x", conn, conn->hcon, sec_level); 160 BT_DBG("conn %p hcon %p level 0x%2.2x", conn, hcon, sec_level);
161
162 if (IS_ERR(hcon->hdev->tfm))
163 return 1;
160 164
161 switch (sec_level) { 165 switch (sec_level) {
162 case BT_SECURITY_MEDIUM: 166 case BT_SECURITY_MEDIUM:
@@ -174,7 +178,7 @@ int smp_conn_security(struct l2cap_conn *conn, __u8 sec_level)
174 return 1; 178 return 1;
175 } 179 }
176 180
177 if (conn->hcon->link_mode & HCI_LM_MASTER) { 181 if (hcon->link_mode & HCI_LM_MASTER) {
178 struct smp_cmd_pairing cp; 182 struct smp_cmd_pairing cp;
179 cp.io_capability = 0x00; 183 cp.io_capability = 0x00;
180 cp.oob_flag = 0x00; 184 cp.oob_flag = 0x00;
@@ -198,6 +202,12 @@ int smp_sig_channel(struct l2cap_conn *conn, struct sk_buff *skb)
198 __u8 reason; 202 __u8 reason;
199 int err = 0; 203 int err = 0;
200 204
205 if (IS_ERR(conn->hcon->hdev->tfm)) {
206 err = PTR_ERR(conn->hcon->hdev->tfm);
207 reason = SMP_PAIRING_NOTSUPP;
208 goto done;
209 }
210
201 skb_pull(skb, sizeof(code)); 211 skb_pull(skb, sizeof(code));
202 212
203 switch (code) { 213 switch (code) {
@@ -233,11 +243,15 @@ int smp_sig_channel(struct l2cap_conn *conn, struct sk_buff *skb)
233 BT_DBG("Unknown command code 0x%2.2x", code); 243 BT_DBG("Unknown command code 0x%2.2x", code);
234 244
235 reason = SMP_CMD_NOTSUPP; 245 reason = SMP_CMD_NOTSUPP;
236 smp_send_cmd(conn, SMP_CMD_PAIRING_FAIL, sizeof(reason),
237 &reason);
238 err = -EOPNOTSUPP; 246 err = -EOPNOTSUPP;
247 goto done;
239 } 248 }
240 249
250done:
251 if (reason)
252 smp_send_cmd(conn, SMP_CMD_PAIRING_FAIL, sizeof(reason),
253 &reason);
254
241 kfree_skb(skb); 255 kfree_skb(skb);
242 return err; 256 return err;
243} 257}