about summary refs log tree commit diff
path: root/broadlink
diff options
context:
space:
mode:
authorDaniel Høyer Iversen <mail@dahoiv.net>2016-12-26T19·02+0100
committerGitHub <noreply@github.com>2016-12-26T19·02+0100
commit39e170c9e0dedd109f90aae2bafb3f0ee83fc8b1 (patch)
treef4e3ff7d0e718c64d2dfe8dde7ff38b7957a3f80 /broadlink
parentb30fc0d1c196320751d196d9b1d62843163b197d (diff)
validate the authorization
Diffstat (limited to 'broadlink')
-rw-r--r--broadlink/__init__.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/broadlink/__init__.py b/broadlink/__init__.py
index 12d8b30d518f..bfa30527a459 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