Skip to content

Commit

Permalink
fix: no check of encryption counter when bindkey has not been verified (
Browse files Browse the repository at this point in the history
#97)

fix: no check of encryption counter when bindkey has not been verified yet
  • Loading branch information
Ernst79 authored Dec 15, 2023
1 parent 4f25ac6 commit 43f1412
Showing 1 changed file with 5 additions and 1 deletion.
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

0 comments on commit 43f1412

Please sign in to comment.