Fix padding algorithm for CBC mode

Due to the lack of a parenthesis, the packets were getting 16 bytes larger than necessary.
This commit is contained in:
Felipe Martins Diel 2020-04-13 17:42:51 -03:00 committed by GitHub
parent 3a6d89aff2
commit a5925063f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -265,7 +265,7 @@ class device:
# pad the payload for AES encryption # pad the payload for AES encryption
if payload: if payload:
payload += bytearray(16 - len(payload)%16) payload += bytearray((16 - len(payload)) % 16)
checksum = adler32(payload, 0xbeaf) & 0xffff checksum = adler32(payload, 0xbeaf) & 0xffff
packet[0x34] = checksum & 0xff packet[0x34] = checksum & 0xff