Commit 6339812d authored by Joakim Andersson's avatar Joakim Andersson Committed by Anas Nashif
Browse files

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: default avatarJoakim Andersson <joakim.andersson@nordicsemi.no>
parent 24269781
Loading
Loading
Loading
Loading
+12 −0
Changes for subsys/bluetooth/host/smp.c: 12 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -3366,6 +3366,12 @@ static u8_t smp_public_key_slave(struct bt_smp *smp)
{
	u8_t err;

	if (!atomic_test_bit(smp->flags, SMP_FLAG_SC_DEBUG_KEY) &&
	    memcmp(smp->pkey, sc_public_key, 64) == 0) {
		BT_WARN("Remote is using identical public key");
		return BT_SMP_ERR_UNSPECIFIED;
	}

	err = sc_send_public_key(smp);
	if (err) {
		return err;
@@ -3428,6 +3434,12 @@ static u8_t smp_public_key(struct bt_smp *smp, struct net_buf *buf)

	if (IS_ENABLED(CONFIG_BT_CENTRAL) &&
	    smp->chan.chan.conn->role == BT_HCI_ROLE_MASTER) {
		if (!atomic_test_bit(smp->flags, SMP_FLAG_SC_DEBUG_KEY) &&
		    memcmp(smp->pkey, sc_public_key, 64) == 0) {
			BT_WARN("Remote is using identical public key");
			return BT_SMP_ERR_UNSPECIFIED;
		}

		switch (smp->method) {
		case PASSKEY_CONFIRM:
		case JUST_WORKS: