From bc6e973ae473039c79b7dcd5bbed07f683a5a76d Mon Sep 17 00:00:00 2001 From: Fachry Maulana Muhsinin Date: Tue, 30 Nov 2021 21:39:41 +0700 Subject: [PATCH] fix decrypt aes --- Gurux.DLMS.python/gurux_dlms/GXDLMSChipperingStream.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Gurux.DLMS.python/gurux_dlms/GXDLMSChipperingStream.py b/Gurux.DLMS.python/gurux_dlms/GXDLMSChipperingStream.py index 2a9a77d..e9c9028 100644 --- a/Gurux.DLMS.python/gurux_dlms/GXDLMSChipperingStream.py +++ b/Gurux.DLMS.python/gurux_dlms/GXDLMSChipperingStream.py @@ -841,7 +841,7 @@ def encryptAes(self, data): return block def decryptAes(self, input_): - n = len(input_) / 8 + n = int(len(input_) / 8) if (n * 8) != len(input_): raise ValueError("Invalid data.") iv = bytearray([0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6]) @@ -870,11 +870,11 @@ def decryptAes(self, input_): t = int((int(t) >> 8)) k += 1 self.processBlock(buf, 0, buf, 0) - a[0:] = buf[0:8] - block[8:16] = buf[8 * (i - 1):8*i] + a[0:] = buf[0:len(iv)] + block[8 * int(i - 1):8 * int(i)] = buf[len(iv):8 + len(iv)] i -= 1 j -= 1 - if a != self.IV: + if a[0:8] != bytearray(self.IV): raise ValueError("Invalid data") return block