Skip to content

Commit

Permalink
Merge pull request #150 from msmarks/fix_request_count_overflow
Browse files Browse the repository at this point in the history
fix self._request_count overflow
  • Loading branch information
georgezhao2010 authored Dec 22, 2022
2 parents 7680f9a + 22061b3 commit 06fc4b5
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions custom_components/midea_ac_lan/midea/core/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ def encode_8370(self, data, msgtype):
header += bytearray([0x20, padding << 4 | msgtype])
data = self._request_count.to_bytes(2, "big") + data
self._request_count += 1
if self._request_count > 0xFFFF:
self._request_count = 0
if msgtype in (MSGTYPE_ENCRYPTED_RESPONSE, MSGTYPE_ENCRYPTED_REQUEST):
sign = sha256(header + data).digest()
data = self.aes_cbc_encrypt(raw=data, key=self._tcp_key) + sign
Expand Down

0 comments on commit 06fc4b5

Please sign in to comment.