Merge pull request #46 from Danielhiversen/patch-10
validate the authorization
This commit is contained in:
		
						commit
						a4465a7515
					
				
					 1 changed files with 9 additions and 1 deletions
				
			
		| 
						 | 
					@ -179,8 +179,16 @@ class device:
 | 
				
			||||||
    aes = AES.new(bytes(self.key), AES.MODE_CBC, bytes(self.iv))
 | 
					    aes = AES.new(bytes(self.key), AES.MODE_CBC, bytes(self.iv))
 | 
				
			||||||
    payload = aes.decrypt(bytes(enc_payload))
 | 
					    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.id = payload[0x00:0x04]
 | 
				
			||||||
    self.key = payload[0x04:0x14]
 | 
					    self.key = key
 | 
				
			||||||
 | 
					    return True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def get_type(self):
 | 
					  def get_type(self):
 | 
				
			||||||
    return self.type
 | 
					    return self.type
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue