summaryrefslogtreecommitdiffstats
path: root/net/bluetooth/smp.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2015-03-16 12:12:57 -0400
committerMarcel Holtmann <marcel@holtmann.org>2015-03-16 12:17:38 -0400
commita8ca617c1356cafa669dc467a386787cc1d83809 (patch)
tree00b6783816e50b091bb6144525ee1f77a60be0ed /net/bluetooth/smp.c
parent94ea7257ef24a007cb0e26476ed8871f179a749f (diff)
Bluetooth: Don't send public key if OOB data verification fails
When we receive the remote public key, if we have remote OOB data there's no point in sending our public key to the remote if the OOB data doesn't match. This patch moves the test for this higher up in the smp_cmd_public_key() function. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/smp.c')
-rw-r--r--net/bluetooth/smp.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index de53ba1905fe..82824213d0fb 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -2515,6 +2515,16 @@ static int smp_cmd_public_key(struct l2cap_conn *conn, struct sk_buff *skb)
2515 2515
2516 memcpy(smp->remote_pk, key, 64); 2516 memcpy(smp->remote_pk, key, 64);
2517 2517
2518 if (test_bit(SMP_FLAG_REMOTE_OOB, &smp->flags)) {
2519 err = smp_f4(smp->tfm_cmac, smp->remote_pk, smp->remote_pk,
2520 smp->rr, 0, cfm.confirm_val);
2521 if (err)
2522 return SMP_UNSPECIFIED;
2523
2524 if (memcmp(cfm.confirm_val, smp->pcnf, 16))
2525 return SMP_CONFIRM_FAILED;
2526 }
2527
2518 /* Non-initiating device sends its public key after receiving 2528 /* Non-initiating device sends its public key after receiving
2519 * the key from the initiating device. 2529 * the key from the initiating device.
2520 */ 2530 */
@@ -2562,16 +2572,6 @@ static int smp_cmd_public_key(struct l2cap_conn *conn, struct sk_buff *skb)
2562 return sc_passkey_round(smp, SMP_CMD_PUBLIC_KEY); 2572 return sc_passkey_round(smp, SMP_CMD_PUBLIC_KEY);
2563 } 2573 }
2564 2574
2565 if (test_bit(SMP_FLAG_REMOTE_OOB, &smp->flags)) {
2566 err = smp_f4(smp->tfm_cmac, smp->remote_pk, smp->remote_pk,
2567 smp->rr, 0, cfm.confirm_val);
2568 if (err)
2569 return SMP_UNSPECIFIED;
2570
2571 if (memcmp(cfm.confirm_val, smp->pcnf, 16))
2572 return SMP_CONFIRM_FAILED;
2573 }
2574
2575 if (smp->method == REQ_OOB) { 2575 if (smp->method == REQ_OOB) {
2576 if (hcon->out) 2576 if (hcon->out)
2577 smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, 2577 smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM,