Skip to content

Commit 6339812

Browse files
joerchannashif
authored andcommitted
Bluetooth: host: Fail pairing with identical public key
Fail the pairing procedure when both devices have the same non-debug public key. Signed-off-by: Joakim Andersson <[email protected]>
1 parent 2426978 commit 6339812

File tree

1 file changed

+12
-0
lines changed
  • subsys/bluetooth/host

1 file changed

+12
-0
lines changed

subsys/bluetooth/host/smp.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3366,6 +3366,12 @@ static u8_t smp_public_key_slave(struct bt_smp *smp)
33663366
{
33673367
u8_t err;
33683368

3369+
if (!atomic_test_bit(smp->flags, SMP_FLAG_SC_DEBUG_KEY) &&
3370+
memcmp(smp->pkey, sc_public_key, 64) == 0) {
3371+
BT_WARN("Remote is using identical public key");
3372+
return BT_SMP_ERR_UNSPECIFIED;
3373+
}
3374+
33693375
err = sc_send_public_key(smp);
33703376
if (err) {
33713377
return err;
@@ -3428,6 +3434,12 @@ static u8_t smp_public_key(struct bt_smp *smp, struct net_buf *buf)
34283434

34293435
if (IS_ENABLED(CONFIG_BT_CENTRAL) &&
34303436
smp->chan.chan.conn->role == BT_HCI_ROLE_MASTER) {
3437+
if (!atomic_test_bit(smp->flags, SMP_FLAG_SC_DEBUG_KEY) &&
3438+
memcmp(smp->pkey, sc_public_key, 64) == 0) {
3439+
BT_WARN("Remote is using identical public key");
3440+
return BT_SMP_ERR_UNSPECIFIED;
3441+
}
3442+
34313443
switch (smp->method) {
34323444
case PASSKEY_CONFIRM:
34333445
case JUST_WORKS:

0 commit comments

Comments
 (0)