1
0
mirror of https://github.com/mjg59/python-broadlink.git synced 2024-11-21 14:43:30 +01:00

Reset connection ID and AES key before sending Client Key Exchange packets (#549)

This commit is contained in:
Felipe Martins Diel 2021-03-11 01:25:57 -03:00 committed by GitHub
parent 20b9eed6bc
commit 90a43835e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -89,6 +89,9 @@ class device:
TYPE = "Unknown"
__INIT_KEY = "097628343fe99e23765c1513accf8b02"
__INIT_VECT = "562e17996d093d28ddb3ba695a2e6f58"
def __init__(
self,
host: Tuple[str, int],
@ -110,14 +113,13 @@ class device:
self.manufacturer = manufacturer
self.is_locked = is_locked
self.count = random.randint(0x8000, 0xFFFF)
self.iv = bytes.fromhex("562e17996d093d28ddb3ba695a2e6f58")
self.iv = bytes.fromhex(self.__INIT_VECT)
self.id = 0
self.type = self.TYPE # For backwards compatibility.
self.lock = threading.Lock()
self.aes = None
key = bytes.fromhex("097628343fe99e23765c1513accf8b02")
self.update_aes(key)
self.update_aes(bytes.fromhex(self.__INIT_KEY))
def __repr__(self):
return "<%s: %s %s (%s) at %s:%s | %s | %s | %s>" % (
@ -157,6 +159,9 @@ class device:
def auth(self) -> bool:
"""Authenticate to the device."""
self.id = 0
self.update_aes(bytes.fromhex(self.__INIT_KEY))
payload = bytearray(0x50)
payload[0x04:0x14] = [0x31]*16
payload[0x1E] = 0x01