diff options
author | Vinicius Costa Gomes <vinicius.gomes@openbossa.org> | 2011-07-07 17:59:39 -0400 |
---|---|---|
committer | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-07-08 16:37:07 -0400 |
commit | 16b908396fbf1be49d417ffdb4a8b41c8c8cb670 (patch) | |
tree | db945f3115be52ff245da72c23834fff441bf056 /net/bluetooth/smp.c | |
parent | 54790f73a3ec87c181e4d6e5eb6963de3d50ebd7 (diff) |
Bluetooth: Add support for storing the LTK
Now when the LTK is received from the remote or generated it is stored,
so it can later be used.
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.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index ffbfdd9e5738..600a70b95a00 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c | |||
@@ -496,18 +496,23 @@ int smp_conn_security(struct l2cap_conn *conn, __u8 sec_level) | |||
496 | 496 | ||
497 | static int smp_cmd_encrypt_info(struct l2cap_conn *conn, struct sk_buff *skb) | 497 | static int smp_cmd_encrypt_info(struct l2cap_conn *conn, struct sk_buff *skb) |
498 | { | 498 | { |
499 | BT_DBG("conn %p", conn); | 499 | struct smp_cmd_encrypt_info *rp = (void *) skb->data; |
500 | /* FIXME: store the ltk */ | 500 | |
501 | skb_pull(skb, sizeof(*rp)); | ||
502 | |||
503 | memcpy(conn->tk, rp->ltk, sizeof(conn->tk)); | ||
504 | |||
501 | return 0; | 505 | return 0; |
502 | } | 506 | } |
503 | 507 | ||
504 | static int smp_cmd_master_ident(struct l2cap_conn *conn, struct sk_buff *skb) | 508 | static int smp_cmd_master_ident(struct l2cap_conn *conn, struct sk_buff *skb) |
505 | { | 509 | { |
506 | struct smp_cmd_pairing *paircmd = (void *) &conn->prsp[1]; | 510 | struct smp_cmd_master_ident *rp = (void *) skb->data; |
507 | u8 keydist = paircmd->init_key_dist; | 511 | |
512 | skb_pull(skb, sizeof(*rp)); | ||
508 | 513 | ||
509 | BT_DBG("keydist 0x%x", keydist); | 514 | hci_add_ltk(conn->hcon->hdev, 1, conn->src, rp->ediv, |
510 | /* FIXME: store ediv and rand */ | 515 | rp->rand, conn->tk); |
511 | 516 | ||
512 | smp_distribute_keys(conn, 1); | 517 | smp_distribute_keys(conn, 1); |
513 | 518 | ||
@@ -632,6 +637,9 @@ int smp_distribute_keys(struct l2cap_conn *conn, __u8 force) | |||
632 | 637 | ||
633 | smp_send_cmd(conn, SMP_CMD_ENCRYPT_INFO, sizeof(enc), &enc); | 638 | smp_send_cmd(conn, SMP_CMD_ENCRYPT_INFO, sizeof(enc), &enc); |
634 | 639 | ||
640 | hci_add_ltk(conn->hcon->hdev, 1, conn->dst, ediv, | ||
641 | ident.rand, enc.ltk); | ||
642 | |||
635 | ident.ediv = cpu_to_le16(ediv); | 643 | ident.ediv = cpu_to_le16(ediv); |
636 | 644 | ||
637 | smp_send_cmd(conn, SMP_CMD_MASTER_IDENT, sizeof(ident), &ident); | 645 | smp_send_cmd(conn, SMP_CMD_MASTER_IDENT, sizeof(ident), &ident); |