Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bluetooth: host: bt_conn_auth_cb callbacks are not called when pairing to BLE 4.1 central in BT_SECURITY_L4 mode. #31607

Closed
Xeenych opened this issue Jan 26, 2021 · 1 comment · Fixed by #32120
Assignees
Labels
area: Bluetooth Host Bluetooth Host (excluding BR/EDR) area: Bluetooth bug The issue is a bug, or the PR is fixing a bug priority: medium Medium impact/importance bug
Milestone

Comments

@Xeenych
Copy link
Contributor

Xeenych commented Jan 26, 2021

I'n using peripheral_lbs from Nordic nRF Connect SDK on nRF52840dk board.
I have Android phone Samsung Galaxy J1. It has BLE 4.1 only.

I've set secuirity level to BT_SECUIRITY_L4

static void connected(struct bt_conn *conn, uint8_t err)
{
    if (err) {
	printk("Connection failed (err %u)\n", err);
	return;
    }

    printk("Connected\n");

    int sec_result = bt_conn_set_security(conn, BT_SECURITY_L4);
    printk("Security level, err %d\n", sec_result);
          
    dk_set_led_on(CON_STATUS_LED);
}

On a smartphone I run nRFConnect app and try to pair with DK board.
Pairing fails because BLE 4.1 doesn't support LESC pairing (BT_SECURITY_L4) but

Board shows that the "secuirity_changed" callback called and then immediately "disconnected" callback.

Passkey for d0:1d:c1:85:77:9b (random): 786779
[00:00:12.933,227] [1;31m<err> bt_hci_core: Failed to set required security level
[00:00:12.941,314] [1;31m<err> bt_conn: not connected
[00:00:12.946,960] [1;31m<err> bt_conn: not connected
Security changed: d0:1d:c1:85:77:9b (random) level 3
Disconnected (reason 22)

Expected behavior
I expect bt_conn_auth callbacks like "cancel" or "pairing_failed" to be called but they are not.

Workaround:
Handle in-progress pairing as failed in disconnected callback if pairing_failed has not been called yet

@Xeenych Xeenych added the bug The issue is a bug, or the PR is fixing a bug label Jan 26, 2021
@nashif nashif added area: Bluetooth area: Bluetooth Host Bluetooth Host (excluding BR/EDR) priority: medium Medium impact/importance bug labels Jan 26, 2021
@carlescufi carlescufi added this to the v2.5.0 milestone Jan 28, 2021
@joerchan joerchan changed the title BLE: bt_conn_auth_cb callbacks are not called when pairing to BLE 4.1 central in BT_SECURITY_L4 mode. Bluetooth: host: bt_conn_auth_cb callbacks are not called when pairing to BLE 4.1 central in BT_SECURITY_L4 mode. Feb 9, 2021
@joerchan
Copy link
Contributor

joerchan commented Feb 9, 2021

Same issue exists also when required BT_SECURITY_L3 and peer does not have MITM flag set.
Can be reproduced with two shell instances when peer side has not set any authentication callbacks that makes it MITM capable

Remote:

bt init
bt advertise on identity

Local:

bt init
bt auth all
bt connect <addr>
bt security 3

Original issue can be reproduced with two shell instances, remote with BT_TINYCRYPT_ECC=n

Remote:

bt init
bt auth all
bt advertise on identity

Local:

bt init
bt auth all
bt connect <addr>
bt security 4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Bluetooth Host Bluetooth Host (excluding BR/EDR) area: Bluetooth bug The issue is a bug, or the PR is fixing a bug priority: medium Medium impact/importance bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants