aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'net/bluetooth/smp.c')
-rw-r--r--net/bluetooth/smp.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index 4b175df35184..906f88550cd8 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -23,6 +23,7 @@
23#include <linux/debugfs.h> 23#include <linux/debugfs.h>
24#include <linux/crypto.h> 24#include <linux/crypto.h>
25#include <linux/scatterlist.h> 25#include <linux/scatterlist.h>
26#include <crypto/algapi.h>
26#include <crypto/b128ops.h> 27#include <crypto/b128ops.h>
27 28
28#include <net/bluetooth/bluetooth.h> 29#include <net/bluetooth/bluetooth.h>
@@ -524,7 +525,7 @@ bool smp_irk_matches(struct hci_dev *hdev, const u8 irk[16],
524 if (err) 525 if (err)
525 return false; 526 return false;
526 527
527 return !memcmp(bdaddr->b, hash, 3); 528 return !crypto_memneq(bdaddr->b, hash, 3);
528} 529}
529 530
530int smp_generate_rpa(struct hci_dev *hdev, const u8 irk[16], bdaddr_t *rpa) 531int smp_generate_rpa(struct hci_dev *hdev, const u8 irk[16], bdaddr_t *rpa)
@@ -577,7 +578,7 @@ int smp_generate_oob(struct hci_dev *hdev, u8 hash[16], u8 rand[16])
577 /* This is unlikely, but we need to check that 578 /* This is unlikely, but we need to check that
578 * we didn't accidentially generate a debug key. 579 * we didn't accidentially generate a debug key.
579 */ 580 */
580 if (memcmp(smp->local_sk, debug_sk, 32)) 581 if (crypto_memneq(smp->local_sk, debug_sk, 32))
581 break; 582 break;
582 } 583 }
583 smp->debug_key = false; 584 smp->debug_key = false;
@@ -991,7 +992,7 @@ static u8 smp_random(struct smp_chan *smp)
991 if (ret) 992 if (ret)
992 return SMP_UNSPECIFIED; 993 return SMP_UNSPECIFIED;
993 994
994 if (memcmp(smp->pcnf, confirm, sizeof(smp->pcnf)) != 0) { 995 if (crypto_memneq(smp->pcnf, confirm, sizeof(smp->pcnf))) {
995 BT_ERR("Pairing failed (confirmation values mismatch)"); 996 BT_ERR("Pairing failed (confirmation values mismatch)");
996 return SMP_CONFIRM_FAILED; 997 return SMP_CONFIRM_FAILED;
997 } 998 }
@@ -1491,7 +1492,7 @@ static u8 sc_passkey_round(struct smp_chan *smp, u8 smp_op)
1491 smp->rrnd, r, cfm)) 1492 smp->rrnd, r, cfm))
1492 return SMP_UNSPECIFIED; 1493 return SMP_UNSPECIFIED;
1493 1494
1494 if (memcmp(smp->pcnf, cfm, 16)) 1495 if (crypto_memneq(smp->pcnf, cfm, 16))
1495 return SMP_CONFIRM_FAILED; 1496 return SMP_CONFIRM_FAILED;
1496 1497
1497 smp->passkey_round++; 1498 smp->passkey_round++;
@@ -1875,7 +1876,7 @@ static u8 sc_send_public_key(struct smp_chan *smp)
1875 /* This is unlikely, but we need to check that 1876 /* This is unlikely, but we need to check that
1876 * we didn't accidentially generate a debug key. 1877 * we didn't accidentially generate a debug key.
1877 */ 1878 */
1878 if (memcmp(smp->local_sk, debug_sk, 32)) 1879 if (crypto_memneq(smp->local_sk, debug_sk, 32))
1879 break; 1880 break;
1880 } 1881 }
1881 } 1882 }
@@ -2140,7 +2141,7 @@ static u8 smp_cmd_pairing_random(struct l2cap_conn *conn, struct sk_buff *skb)
2140 if (err) 2141 if (err)
2141 return SMP_UNSPECIFIED; 2142 return SMP_UNSPECIFIED;
2142 2143
2143 if (memcmp(smp->pcnf, cfm, 16)) 2144 if (crypto_memneq(smp->pcnf, cfm, 16))
2144 return SMP_CONFIRM_FAILED; 2145 return SMP_CONFIRM_FAILED;
2145 } else { 2146 } else {
2146 smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, sizeof(smp->prnd), 2147 smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, sizeof(smp->prnd),
@@ -2621,7 +2622,7 @@ static int smp_cmd_public_key(struct l2cap_conn *conn, struct sk_buff *skb)
2621 if (err) 2622 if (err)
2622 return SMP_UNSPECIFIED; 2623 return SMP_UNSPECIFIED;
2623 2624
2624 if (memcmp(cfm.confirm_val, smp->pcnf, 16)) 2625 if (crypto_memneq(cfm.confirm_val, smp->pcnf, 16))
2625 return SMP_CONFIRM_FAILED; 2626 return SMP_CONFIRM_FAILED;
2626 } 2627 }
2627 2628
@@ -2654,7 +2655,7 @@ static int smp_cmd_public_key(struct l2cap_conn *conn, struct sk_buff *skb)
2654 else 2655 else
2655 hcon->pending_sec_level = BT_SECURITY_FIPS; 2656 hcon->pending_sec_level = BT_SECURITY_FIPS;
2656 2657
2657 if (!memcmp(debug_pk, smp->remote_pk, 64)) 2658 if (!crypto_memneq(debug_pk, smp->remote_pk, 64))
2658 set_bit(SMP_FLAG_DEBUG_KEY, &smp->flags); 2659 set_bit(SMP_FLAG_DEBUG_KEY, &smp->flags);
2659 2660
2660 if (smp->method == DSP_PASSKEY) { 2661 if (smp->method == DSP_PASSKEY) {
@@ -2753,7 +2754,7 @@ static int smp_cmd_dhkey_check(struct l2cap_conn *conn, struct sk_buff *skb)
2753 if (err) 2754 if (err)
2754 return SMP_UNSPECIFIED; 2755 return SMP_UNSPECIFIED;
2755 2756
2756 if (memcmp(check->e, e, 16)) 2757 if (crypto_memneq(check->e, e, 16))
2757 return SMP_DHKEY_CHECK_FAILED; 2758 return SMP_DHKEY_CHECK_FAILED;
2758 2759
2759 if (!hcon->out) { 2760 if (!hcon->out) {
@@ -3463,7 +3464,7 @@ static int __init test_ah(struct crypto_blkcipher *tfm_aes)
3463 if (err) 3464 if (err)
3464 return err; 3465 return err;
3465 3466
3466 if (memcmp(res, exp, 3)) 3467 if (crypto_memneq(res, exp, 3))
3467 return -EINVAL; 3468 return -EINVAL;
3468 3469
3469 return 0; 3470 return 0;
@@ -3493,7 +3494,7 @@ static int __init test_c1(struct crypto_blkcipher *tfm_aes)
3493 if (err) 3494 if (err)
3494 return err; 3495 return err;
3495 3496
3496 if (memcmp(res, exp, 16)) 3497 if (crypto_memneq(res, exp, 16))
3497 return -EINVAL; 3498 return -EINVAL;
3498 3499
3499 return 0; 3500 return 0;
@@ -3518,7 +3519,7 @@ static int __init test_s1(struct crypto_blkcipher *tfm_aes)
3518 if (err) 3519 if (err)
3519 return err; 3520 return err;
3520 3521
3521 if (memcmp(res, exp, 16)) 3522 if (crypto_memneq(res, exp, 16))
3522 return -EINVAL; 3523 return -EINVAL;
3523 3524
3524 return 0; 3525 return 0;
@@ -3550,7 +3551,7 @@ static int __init test_f4(struct crypto_hash *tfm_cmac)
3550 if (err) 3551 if (err)
3551 return err; 3552 return err;
3552 3553
3553 if (memcmp(res, exp, 16)) 3554 if (crypto_memneq(res, exp, 16))
3554 return -EINVAL; 3555 return -EINVAL;
3555 3556
3556 return 0; 3557 return 0;
@@ -3584,10 +3585,10 @@ static int __init test_f5(struct crypto_hash *tfm_cmac)
3584 if (err) 3585 if (err)
3585 return err; 3586 return err;
3586 3587
3587 if (memcmp(mackey, exp_mackey, 16)) 3588 if (crypto_memneq(mackey, exp_mackey, 16))
3588 return -EINVAL; 3589 return -EINVAL;
3589 3590
3590 if (memcmp(ltk, exp_ltk, 16)) 3591 if (crypto_memneq(ltk, exp_ltk, 16))
3591 return -EINVAL; 3592 return -EINVAL;
3592 3593
3593 return 0; 3594 return 0;
@@ -3620,7 +3621,7 @@ static int __init test_f6(struct crypto_hash *tfm_cmac)
3620 if (err) 3621 if (err)
3621 return err; 3622 return err;
3622 3623
3623 if (memcmp(res, exp, 16)) 3624 if (crypto_memneq(res, exp, 16))
3624 return -EINVAL; 3625 return -EINVAL;
3625 3626
3626 return 0; 3627 return 0;
@@ -3674,7 +3675,7 @@ static int __init test_h6(struct crypto_hash *tfm_cmac)
3674 if (err) 3675 if (err)
3675 return err; 3676 return err;
3676 3677
3677 if (memcmp(res, exp, 16)) 3678 if (crypto_memneq(res, exp, 16))
3678 return -EINVAL; 3679 return -EINVAL;
3679 3680
3680 return 0; 3681 return 0;