From 39e170c9e0dedd109f90aae2bafb3f0ee83fc8b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20H=C3=B8yer=20Iversen?= Date: Mon, 26 Dec 2016 20:02:04 +0100 Subject: [PATCH] validate the authorization --- broadlink/__init__.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/broadlink/__init__.py b/broadlink/__init__.py index 12d8b30..bfa3052 100644 --- a/broadlink/__init__.py +++ b/broadlink/__init__.py @@ -179,8 +179,16 @@ class device: aes = AES.new(bytes(self.key), AES.MODE_CBC, bytes(self.iv)) payload = aes.decrypt(bytes(enc_payload)) + if not payload: + return False + + key = payload[0x04:0x14] + if len(key) % 16 != 0: + return False + self.id = payload[0x00:0x04] - self.key = payload[0x04:0x14] + self.key = key + return True def get_type(self): return self.type