diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2014-02-27 19:00:28 -0500 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2014-02-28 05:36:04 -0500 |
commit | fe39c7b2dacf7fd4dcddc26704d01315ab92b7cb (patch) | |
tree | 9eb0ab5c8daa3432201c6e0219468cd851669b06 /net/bluetooth/smp.c | |
parent | a3172b7eb4a2719711187cfca12097d2326e85a7 (diff) |
Bluetooth: Use __le64 type for LE random numbers
The random numbers in Bluetooth Low Energy are 64-bit numbers and should
also be little endian since the HCI specification is little endian.
Change the whole Low Energy pairing to use __le64 instead of a byte
array.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Diffstat (limited to 'net/bluetooth/smp.c')
-rw-r--r-- | net/bluetooth/smp.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index 0de98fe23330..99abffcaf16b 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c | |||
@@ -517,11 +517,9 @@ static void random_work(struct work_struct *work) | |||
517 | } | 517 | } |
518 | 518 | ||
519 | if (hcon->out) { | 519 | if (hcon->out) { |
520 | u8 stk[16], rand[8]; | 520 | u8 stk[16]; |
521 | __le16 ediv; | 521 | __le64 rand = 0; |
522 | 522 | __le16 ediv = 0; | |
523 | memset(rand, 0, sizeof(rand)); | ||
524 | ediv = 0; | ||
525 | 523 | ||
526 | smp_s1(tfm, smp->tk, smp->rrnd, smp->prnd, key); | 524 | smp_s1(tfm, smp->tk, smp->rrnd, smp->prnd, key); |
527 | swap128(key, stk); | 525 | swap128(key, stk); |
@@ -537,11 +535,9 @@ static void random_work(struct work_struct *work) | |||
537 | hci_le_start_enc(hcon, ediv, rand, stk); | 535 | hci_le_start_enc(hcon, ediv, rand, stk); |
538 | hcon->enc_key_size = smp->enc_key_size; | 536 | hcon->enc_key_size = smp->enc_key_size; |
539 | } else { | 537 | } else { |
540 | u8 stk[16], r[16], rand[8]; | 538 | u8 stk[16], r[16]; |
541 | __le16 ediv; | 539 | __le64 rand = 0; |
542 | 540 | __le16 ediv = 0; | |
543 | memset(rand, 0, sizeof(rand)); | ||
544 | ediv = 0; | ||
545 | 541 | ||
546 | swap128(smp->prnd, r); | 542 | swap128(smp->prnd, r); |
547 | smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, sizeof(r), r); | 543 | smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, sizeof(r), r); |
@@ -1205,20 +1201,22 @@ int smp_distribute_keys(struct l2cap_conn *conn) | |||
1205 | struct smp_ltk *ltk; | 1201 | struct smp_ltk *ltk; |
1206 | u8 authenticated; | 1202 | u8 authenticated; |
1207 | __le16 ediv; | 1203 | __le16 ediv; |
1204 | __le64 rand; | ||
1208 | 1205 | ||
1209 | get_random_bytes(enc.ltk, sizeof(enc.ltk)); | 1206 | get_random_bytes(enc.ltk, sizeof(enc.ltk)); |
1210 | get_random_bytes(&ediv, sizeof(ediv)); | 1207 | get_random_bytes(&ediv, sizeof(ediv)); |
1211 | get_random_bytes(ident.rand, sizeof(ident.rand)); | 1208 | get_random_bytes(&rand, sizeof(rand)); |
1212 | 1209 | ||
1213 | smp_send_cmd(conn, SMP_CMD_ENCRYPT_INFO, sizeof(enc), &enc); | 1210 | smp_send_cmd(conn, SMP_CMD_ENCRYPT_INFO, sizeof(enc), &enc); |
1214 | 1211 | ||
1215 | authenticated = hcon->sec_level == BT_SECURITY_HIGH; | 1212 | authenticated = hcon->sec_level == BT_SECURITY_HIGH; |
1216 | ltk = hci_add_ltk(hdev, &hcon->dst, hcon->dst_type, | 1213 | ltk = hci_add_ltk(hdev, &hcon->dst, hcon->dst_type, |
1217 | HCI_SMP_LTK_SLAVE, authenticated, enc.ltk, | 1214 | HCI_SMP_LTK_SLAVE, authenticated, enc.ltk, |
1218 | smp->enc_key_size, ediv, ident.rand); | 1215 | smp->enc_key_size, ediv, rand); |
1219 | smp->slave_ltk = ltk; | 1216 | smp->slave_ltk = ltk; |
1220 | 1217 | ||
1221 | ident.ediv = ediv; | 1218 | ident.ediv = ediv; |
1219 | ident.rand = rand; | ||
1222 | 1220 | ||
1223 | smp_send_cmd(conn, SMP_CMD_MASTER_IDENT, sizeof(ident), &ident); | 1221 | smp_send_cmd(conn, SMP_CMD_MASTER_IDENT, sizeof(ident), &ident); |
1224 | 1222 | ||