[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
1 changed files with 2 additions and 1 deletions

View File

@ -355,7 +355,8 @@ class FragmentFD(FileDownloader):
# 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