diff options
author | Vinicius Costa Gomes <vinicius.gomes@openbossa.org> | 2011-07-07 17:59:40 -0400 |
---|---|---|
committer | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-07-08 16:37:12 -0400 |
commit | e7e62c8592484f79469312fc694d2995918aa152 (patch) | |
tree | c5474bd6a209d7024817e2ce5650424c03470b80 /net | |
parent | 16b908396fbf1be49d417ffdb4a8b41c8c8cb670 (diff) |
Bluetooth: Use the link key list to temporarily store the STK
With this we can use only one place to store all keys, without
need to use a field in the connection structure for this
purpose.
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@openbossa.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net')
-rw-r--r-- | net/bluetooth/smp.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index 600a70b95a00..6df51017df21 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c | |||
@@ -390,29 +390,36 @@ static u8 smp_cmd_pairing_random(struct l2cap_conn *conn, struct sk_buff *skb) | |||
390 | } | 390 | } |
391 | 391 | ||
392 | if (conn->hcon->out) { | 392 | if (conn->hcon->out) { |
393 | u8 stk[16], rand[8]; | ||
393 | __le16 ediv; | 394 | __le16 ediv; |
394 | u8 rand[8]; | 395 | |
396 | memset(rand, 0, sizeof(rand)); | ||
397 | ediv = 0; | ||
395 | 398 | ||
396 | smp_s1(tfm, conn->tk, random, conn->prnd, key); | 399 | smp_s1(tfm, conn->tk, random, conn->prnd, key); |
397 | swap128(key, hcon->ltk); | 400 | swap128(key, stk); |
398 | 401 | ||
399 | memset(hcon->ltk + conn->smp_key_size, 0, | 402 | memset(stk + conn->smp_key_size, 0, |
400 | SMP_MAX_ENC_KEY_SIZE - conn->smp_key_size); | 403 | SMP_MAX_ENC_KEY_SIZE - conn->smp_key_size); |
401 | 404 | ||
405 | hci_le_start_enc(hcon, ediv, rand, stk); | ||
406 | } else { | ||
407 | u8 stk[16], r[16], rand[8]; | ||
408 | __le16 ediv; | ||
409 | |||
402 | memset(rand, 0, sizeof(rand)); | 410 | memset(rand, 0, sizeof(rand)); |
403 | ediv = 0; | 411 | ediv = 0; |
404 | hci_le_start_enc(hcon, ediv, rand, hcon->ltk); | ||
405 | } else { | ||
406 | u8 r[16]; | ||
407 | 412 | ||
408 | swap128(conn->prnd, r); | 413 | swap128(conn->prnd, r); |
409 | smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, sizeof(r), r); | 414 | smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, sizeof(r), r); |
410 | 415 | ||
411 | smp_s1(tfm, conn->tk, conn->prnd, random, key); | 416 | smp_s1(tfm, conn->tk, conn->prnd, random, key); |
412 | swap128(key, hcon->ltk); | 417 | swap128(key, stk); |
413 | 418 | ||
414 | memset(hcon->ltk + conn->smp_key_size, 0, | 419 | memset(stk + conn->smp_key_size, 0, |
415 | SMP_MAX_ENC_KEY_SIZE - conn->smp_key_size); | 420 | SMP_MAX_ENC_KEY_SIZE - conn->smp_key_size); |
421 | |||
422 | hci_add_ltk(conn->hcon->hdev, 0, conn->dst, ediv, rand, stk); | ||
416 | } | 423 | } |
417 | 424 | ||
418 | return 0; | 425 | return 0; |