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

nimble/ll: Add vs hci to set local IRK #1630

Merged
merged 1 commit into from
Oct 26, 2023

Conversation

andrzej-kaczmarek
Copy link
Contributor

@andrzej-kaczmarek andrzej-kaczmarek commented Oct 3, 2023

This adds vendor-specific HCI command to set local IRK in controller.

Local IRK, if set, is used to generate local RPA in use cases where own address type was set to 0x02 or 0x03 but peer address is not added to resolving list. This for example allows to handle initiating connection to a new peer using RPA as our local address entirely in LL. Without that command it would be required for host to generate an RPA, set it as random address and connect using random address. This however doesn't work well with NimBLE host.

If no IRK is set (or set to all-zero), the controller behaves as usual which makes it safe to enable as it won't break anything.

@andrzej-kaczmarek andrzej-kaczmarek force-pushed the ll-rpa0-hack branch 2 times, most recently from a3a4fbe to c3190d8 Compare October 3, 2023 22:30
@andrzej-kaczmarek andrzej-kaczmarek changed the title nimble/ll: Add hack for generating RPA on init nimble/ll: Add vs hci to set local IRK Oct 3, 2023
@andrzej-kaczmarek andrzej-kaczmarek marked this pull request as draft October 3, 2023 22:34
@andrzej-kaczmarek andrzej-kaczmarek force-pushed the ll-rpa0-hack branch 4 times, most recently from fe5dfea to 5007196 Compare October 4, 2023 00:48
@andrzej-kaczmarek andrzej-kaczmarek marked this pull request as ready for review October 4, 2023 08:00
Copy link
Contributor

@sjanc sjanc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea:)

if (cmdlen != sizeof(*cmd)) {
return BLE_ERR_INV_HCI_CMD_PARMS;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably disallow this when initiating and advertising (?) (connectable, undirected)

#if MYNEWT_VAL(BLE_LL_HCI_VS_LOCAL_IRK)
int
ble_ll_resolv_local_irk_set(const uint8_t *irk)
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use ble_ll_resolv_irk_nonzero()

#if MYNEWT_VAL(BLE_LL_HCI_VS_LOCAL_IRK)
OS_ENTER_CRITICAL(sr);
if (g_local_irk.is_set) {
generate_rpa(g_local_irk.irk, g_local_irk.rpa);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RPA could be generated before critical section, and critical section could be only under if (as it may be cleared only from same task)


#define BLE_HCI_OCF_VS_SET_LOCAL_IRK (MYNEWT_VAL(BLE_HCI_VS_OCF_OFFSET) + (0x000A))
struct ble_hci_vs_set_local_irk_cp {
uint8_t irk[16];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a loose thought, maybe this could also have address type? public vs static_random

This adds vendor-specific HCI command to set local IRK in controller.
IRK can be set for both public and static random addresses separately.

Local IRK, if set, is used to generate local RPA in use cases where own
address type was set to 0x02 or 0x03 but peer address is not added to
resolving list. This for example allows to handle initiating connection
to a new peer using RPA as our local address entirely in LL. Without
that command it would be required for host to generate an RPA, set it as
random address and connect using random address. This however doesn't
work well with NimBLE host.

If no IRK is set (or set to all-zero), the controller behaves as usual
which makes it safe to enable as it won't break anything.
@andrzej-kaczmarek andrzej-kaczmarek merged commit 8e1bc72 into apache:master Oct 26, 2023
14 checks passed
@andrzej-kaczmarek andrzej-kaczmarek deleted the ll-rpa0-hack branch October 26, 2023 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants