Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions bumble/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -4836,11 +4836,21 @@ async def get_long_term_key(
if keys.ltk:
return keys.ltk.value

if connection.role == hci.Role.CENTRAL and keys.ltk_central:
return keys.ltk_central.value
# Check both ltk_central and ltk_peripheral by matching EDIV+Rand
if (
keys.ltk_central
and keys.ltk_central.ediv == ediv
and keys.ltk_central.rand == rand
):
return keys.ltk_central.value

if (
keys.ltk_peripheral
and keys.ltk_peripheral.ediv == ediv
and keys.ltk_peripheral.rand == rand
):
return keys.ltk_peripheral.value

if connection.role == hci.Role.PERIPHERAL and keys.ltk_peripheral:
return keys.ltk_peripheral.value
return None

async def get_link_key(self, address: hci.Address) -> bytes | None:
Expand Down