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

Add functions/tool for gen/verifying BLE IRK/RPA #377

Merged
merged 1 commit into from
Dec 26, 2023

Conversation

benquike
Copy link
Contributor

No description provided.

@zxzxwu
Copy link
Collaborator

zxzxwu commented Dec 16, 2023

I am wondering whether this kind of use case should be in Bumble? You can implement the tool in your own codebase like AOSP, since it doesn't involve Bumble's internal lifecycle and functionality.

@zxzxwu
Copy link
Collaborator

zxzxwu commented Dec 16, 2023

But still Bumble has many "tools"? Maybe we need a guideline about what should be in Bumble, and what is not.

@benquike
Copy link
Contributor Author

I am wondering whether this kind of use case should be in Bumble? You can implement the tool in your own codebase like AOSP, since it doesn't involve Bumble's internal lifecycle and functionality.

Do you plan to add BLE privacy < 1.2 with random address resolution in host?

@zxzxwu
Copy link
Collaborator

zxzxwu commented Dec 16, 2023

Do you plan to add BLE privacy < 1.2 with random address resolution in host?

Yes, Bumble already supports Host-side resolution.
https://github.com/google/bumble/blob/main/bumble/device.py#L3228

But it doesn't handle advertising reports(only in connection), so that's something we can enhance Bumble.

@barbibulle
Copy link
Collaborator

But still Bumble has many "tools"? Maybe we need a guideline about what should be in Bumble, and what is not.

Since Bumble is a general purpose project for developers working on Bluetooth-related things, I think it's good to host a collection of tools that relate to that, including very narrow tools like this that are useful for people working on the internals of the stack(s).

@barbibulle
Copy link
Collaborator

Do you plan to add BLE privacy < 1.2 with random address resolution in host?

Yes, Bumble already supports Host-side resolution. https://github.com/google/bumble/blob/main/bumble/device.py#L3228

But it doesn't handle advertising reports(only in connection), so that's something we can enhance Bumble.

There is support for address resolution for advertising reports in some places, like the scan.py tool (ex: https://github.com/google/bumble/blob/main/apps/scan.py#L60 ).
But we could definitely make this easier by doing automatic address resolution in a shared way, so that apps that want to scan don't have to instantiate their own resolver. I'll add support for that in my WIP branch in which I'm adding better support for RPA.

return crypto.r()


def gen_rpa_with_irk(irk: bytes) -> bytes:
Copy link
Collaborator

Choose a reason for hiding this comment

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

suggest: naming this generare_rpa_with_irk to be consistent with generate_irk.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@click.argument("irk", type=str)
@click.argument("rpa", type=str)
def verify_rpa(irk: str, rpa: str) -> None:
rpa_bytes = addr_str_to_bytes(rpa)
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can use the Address class for this: bytes(hci.Address(rpa))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

def gen_rpa(irk: str) -> None:
irk_bytes = bytes.fromhex(irk)
rpa = gen_rpa_with_irk(irk_bytes)
print(addr_bytes_to_str(rpa))
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can use the hci.Address class for this: hci.Address(rpa).to_string(with_type_qualifier=False).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

return crypto.r()


def gen_rpa_with_irk(irk: bytes) -> bytes:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe this should return an hci.Address object.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@benquike
Copy link
Contributor Author

OK to merge?

@barbibulle
Copy link
Collaborator

OK to merge?

PR #379 was merged earlier, it includes functions for generating private addresses. Would be good to update this PR by removing gen_rpa_with_irk and using the new Address methods instead.

@benquike
Copy link
Contributor Author

OK to merge?

PR #379 was merged earlier, it includes functions for generating private addresses. Would be good to update this PR by removing gen_rpa_with_irk and using the new Address methods instead.

Done

@benquike benquike requested a review from barbibulle December 26, 2023 18:39
@barbibulle barbibulle merged commit 5393471 into google:main Dec 26, 2023
51 checks passed
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.

3 participants