aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/smp.c
diff options
context:
space:
mode:
authorVinicius Costa Gomes <vinicius.gomes@openbossa.org>2011-07-08 17:31:45 -0400
committerGustavo F. Padovan <padovan@profusion.mobi>2011-07-08 17:39:19 -0400
commit726b4ffcaa450d9593b9b6ac8605967ce9f3e506 (patch)
tree5d274067ab8946d081f01c9b160bff495aca857c /net/bluetooth/smp.c
parent5a0a8b49746771fba79866fb9185ffa051a6a183 (diff)
Bluetooth: Add support for storing the key size
In some cases it will be useful having the key size used for encrypting the link. For example, some profiles may restrict some operations depending on the key length. The key size is stored in the key that is passed to userspace using the pin_length field in the key structure. For now this field is only valid for LE controllers. 3.0+HS controllers define the Read Encryption Key Size command, this field is intended for storing the value returned by that command. Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@openbossa.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net/bluetooth/smp.c')
-rw-r--r--net/bluetooth/smp.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index a8b971b75a67..391888b88a92 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -401,6 +401,7 @@ static u8 smp_cmd_pairing_random(struct l2cap_conn *conn, struct sk_buff *skb)
401 SMP_MAX_ENC_KEY_SIZE - conn->smp_key_size); 401 SMP_MAX_ENC_KEY_SIZE - conn->smp_key_size);
402 402
403 hci_le_start_enc(hcon, ediv, rand, stk); 403 hci_le_start_enc(hcon, ediv, rand, stk);
404 hcon->enc_key_size = conn->smp_key_size;
404 } else { 405 } else {
405 u8 stk[16], r[16], rand[8]; 406 u8 stk[16], r[16], rand[8];
406 __le16 ediv; 407 __le16 ediv;
@@ -417,7 +418,8 @@ static u8 smp_cmd_pairing_random(struct l2cap_conn *conn, struct sk_buff *skb)
417 memset(stk + conn->smp_key_size, 0, 418 memset(stk + conn->smp_key_size, 0,
418 SMP_MAX_ENC_KEY_SIZE - conn->smp_key_size); 419 SMP_MAX_ENC_KEY_SIZE - conn->smp_key_size);
419 420
420 hci_add_ltk(conn->hcon->hdev, 0, conn->dst, ediv, rand, stk); 421 hci_add_ltk(conn->hcon->hdev, 0, conn->dst, conn->smp_key_size,
422 ediv, rand, stk);
421 } 423 }
422 424
423 return 0; 425 return 0;
@@ -487,6 +489,8 @@ int smp_conn_security(struct l2cap_conn *conn, __u8 sec_level)
487 489
488 hci_le_start_enc(hcon, master->ediv, master->rand, 490 hci_le_start_enc(hcon, master->ediv, master->rand,
489 key->val); 491 key->val);
492 hcon->enc_key_size = key->pin_len;
493
490 goto done; 494 goto done;
491 } 495 }
492 496
@@ -528,8 +532,8 @@ static int smp_cmd_master_ident(struct l2cap_conn *conn, struct sk_buff *skb)
528 532
529 skb_pull(skb, sizeof(*rp)); 533 skb_pull(skb, sizeof(*rp));
530 534
531 hci_add_ltk(conn->hcon->hdev, 1, conn->src, rp->ediv, 535 hci_add_ltk(conn->hcon->hdev, 1, conn->src, conn->smp_key_size,
532 rp->rand, conn->tk); 536 rp->ediv, rp->rand, conn->tk);
533 537
534 smp_distribute_keys(conn, 1); 538 smp_distribute_keys(conn, 1);
535 539
@@ -654,8 +658,8 @@ int smp_distribute_keys(struct l2cap_conn *conn, __u8 force)
654 658
655 smp_send_cmd(conn, SMP_CMD_ENCRYPT_INFO, sizeof(enc), &enc); 659 smp_send_cmd(conn, SMP_CMD_ENCRYPT_INFO, sizeof(enc), &enc);
656 660
657 hci_add_ltk(conn->hcon->hdev, 1, conn->dst, ediv, 661 hci_add_ltk(conn->hcon->hdev, 1, conn->dst, conn->smp_key_size,
658 ident.rand, enc.ltk); 662 ediv, ident.rand, enc.ltk);
659 663
660 ident.ediv = cpu_to_le16(ediv); 664 ident.ediv = cpu_to_le16(ediv);
661 665