diff options
Diffstat (limited to 'yt_dlp/aes.py')
-rw-r--r-- | yt_dlp/aes.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/yt_dlp/aes.py b/yt_dlp/aes.py index 461bb6d41..57caae069 100644 --- a/yt_dlp/aes.py +++ b/yt_dlp/aes.py @@ -2,9 +2,21 @@ from __future__ import unicode_literals from math import ceil -from .compat import compat_b64decode +from .compat import compat_b64decode, compat_pycrypto_AES from .utils import bytes_to_intlist, intlist_to_bytes + +if compat_pycrypto_AES: + def aes_cbc_decrypt_bytes(data, key, iv): + """ Decrypt bytes with AES-CBC using pycryptodome """ + return compat_pycrypto_AES.new(key, compat_pycrypto_AES.MODE_CBC, iv).decrypt(data) + +else: + def aes_cbc_decrypt_bytes(data, key, iv): + """ Decrypt bytes with AES-CBC using native implementation since pycryptodome is unavailable """ + return intlist_to_bytes(aes_cbc_decrypt(*map(bytes_to_intlist, (data, key, iv)))) + + BLOCK_SIZE_BYTES = 16 |