[fragments] Pad fragments before decrypting (#1298)

Closes #197, #1297, #1007
Authored by: shirt-dev
This commit is contained in:
shirt 2021-10-17 22:44:20 -04:00 committed by GitHub
parent 920134b2e5
commit 373475f035
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -355,7 +355,8 @@ def decrypt_fragment(fragment, frag_content):
# not what it decrypts to.
if self.params.get('test', False):
return frag_content
decrypted_data = aes_cbc_decrypt_bytes(frag_content, decrypt_info['KEY'], iv)
padding_len = 16 - (len(frag_content) % 16)
decrypted_data = aes_cbc_decrypt_bytes(frag_content + bytes([padding_len] * padding_len), decrypt_info['KEY'], iv)
return decrypted_data[:-decrypted_data[-1]]
return decrypt_fragment