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

fix: no check of encryption counter when bindkey has not been verified #97

Merged
merged 1 commit into from
Dec 15, 2023
Merged
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
6 changes: 5 additions & 1 deletion src/bthome_ble/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@ def _decrypt_bthome(
self.last_service_info
and new_encryption_counter == last_encryption_counter
and service_info.service_data == self.last_service_info.service_data
and self.bindkey_verified is True
):
# the counter and service data are exactly the same as the previous, skipping the adv.
_LOGGER.debug(
Expand All @@ -595,7 +596,10 @@ def _decrypt_bthome(
last_encryption_counter,
)
raise ValueError
elif new_encryption_counter <= last_encryption_counter:
elif (
new_encryption_counter <= last_encryption_counter
and self.bindkey_verified is True
):
# the counter is lower than the previous counter or equal, but with different service
# data.
if new_encryption_counter < 100 and last_encryption_counter >= 4294967195:
Expand Down