From b4ebd1326d0cda62bd89dc048e7b019438a6975d Mon Sep 17 00:00:00 2001 From: Brian Maloney Date: Fri, 7 Jun 2024 14:01:40 -0500 Subject: [PATCH] Update odl.py Removed cipher_text_orig --- odl.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/odl.py b/odl.py index 82b8de9..acada79 100644 --- a/odl.py +++ b/odl.py @@ -140,44 +140,42 @@ def decrypt(cipher_text): '''cipher_text is expected to be base64 encoded''' global key global utf_type - - cipher_text_orig = cipher_text if key == '': - return cipher_text_orig + return '' if len(cipher_text) < 22: - return cipher_text_orig # invalid or it was not encrypted! + return '' # invalid or it was not encrypted! # add proper base64 padding remainder = len(cipher_text) % 4 if remainder == 1: - return cipher_text_orig # invalid b64 or it was not encrypted! + return '' # invalid b64 or it was not encrypted! elif remainder in (2, 3): cipher_text += "="* (4 - remainder) try: cipher_text = cipher_text.replace('_', '/').replace('-', '+') cipher_text = base64.b64decode(cipher_text) except: - return cipher_text_orig + return '' if len(cipher_text) % 16 != 0: - return cipher_text_orig + return '' try: cipher = AES.new(key, AES.MODE_CBC, iv=b'\0'*16) raw = cipher.decrypt(cipher_text) except ValueError as ex: print('Exception while decrypting data', str(ex)) - return cipher_text_orig + return '' try: plain_text = unpad(raw, 16) except ValueError as ex: #print("Error in unpad!", str(ex), raw) - return cipher_text_orig + return '' try: plain_text = plain_text.decode(utf_type)#, 'ignore') except ValueError as ex: #print(f"Error decoding {utf_type}", str(ex)) - return cipher_text_orig + return '' return plain_text def read_keystore(keystore_path):