|
|
@ -1,8 +1,5 @@
|
|
|
|
import types
|
|
|
|
import types
|
|
|
|
|
|
|
|
|
|
|
|
from ..compat import functools
|
|
|
|
|
|
|
|
from ..compat.compat_utils import passthrough_module
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
import Cryptodome as _parent
|
|
|
|
import Cryptodome as _parent
|
|
|
|
except ImportError:
|
|
|
|
except ImportError:
|
|
|
@ -12,19 +9,36 @@ except ImportError:
|
|
|
|
_parent = types.ModuleType('no_Cryptodome')
|
|
|
|
_parent = types.ModuleType('no_Cryptodome')
|
|
|
|
__bool__ = lambda: False
|
|
|
|
__bool__ = lambda: False
|
|
|
|
|
|
|
|
|
|
|
|
passthrough_module(__name__, _parent, (..., '__version__'))
|
|
|
|
__version__ = ''
|
|
|
|
del passthrough_module
|
|
|
|
AES = PKCS1_v1_5 = Blowfish = PKCS1_OAEP = SHA1 = CMAC = RSA = None
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
if _parent.__name__ == 'Cryptodome':
|
|
|
|
|
|
|
|
from Cryptodome import __version__
|
|
|
|
|
|
|
|
from Cryptodome.Cipher import AES
|
|
|
|
|
|
|
|
from Cryptodome.Cipher import PKCS1_v1_5
|
|
|
|
|
|
|
|
from Cryptodome.Cipher import Blowfish
|
|
|
|
|
|
|
|
from Cryptodome.Cipher import PKCS1_OAEP
|
|
|
|
|
|
|
|
from Cryptodome.Hash import SHA1
|
|
|
|
|
|
|
|
from Cryptodome.Hash import CMAC
|
|
|
|
|
|
|
|
from Cryptodome.PublicKey import RSA
|
|
|
|
|
|
|
|
elif _parent.__name__ == 'Crypto':
|
|
|
|
|
|
|
|
from Crypto import __version__
|
|
|
|
|
|
|
|
from Crypto.Cipher import AES
|
|
|
|
|
|
|
|
from Crypto.Cipher import PKCS1_v1_5
|
|
|
|
|
|
|
|
from Crypto.Cipher import Blowfish
|
|
|
|
|
|
|
|
from Crypto.Cipher import PKCS1_OAEP
|
|
|
|
|
|
|
|
from Crypto.Hash import SHA1
|
|
|
|
|
|
|
|
from Crypto.Hash import CMAC
|
|
|
|
|
|
|
|
from Crypto.PublicKey import RSA
|
|
|
|
|
|
|
|
except ImportError:
|
|
|
|
|
|
|
|
__version__ = f'broken {__version__}'.strip()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
_yt_dlp__identifier = _parent.__name__
|
|
|
|
@functools.cache
|
|
|
|
if AES and _yt_dlp__identifier == 'Crypto':
|
|
|
|
def _yt_dlp__identifier():
|
|
|
|
try:
|
|
|
|
if _parent.__name__ == 'Crypto':
|
|
|
|
# In pycrypto, mode defaults to ECB. See:
|
|
|
|
from Crypto.Cipher import AES
|
|
|
|
# https://www.pycryptodome.org/en/latest/src/vs_pycrypto.html#:~:text=not%20have%20ECB%20as%20default%20mode
|
|
|
|
try:
|
|
|
|
AES.new(b'abcdefghijklmnop')
|
|
|
|
# In pycrypto, mode defaults to ECB. See:
|
|
|
|
except TypeError:
|
|
|
|
# https://www.pycryptodome.org/en/latest/src/vs_pycrypto.html#:~:text=not%20have%20ECB%20as%20default%20mode
|
|
|
|
_yt_dlp__identifier = 'pycrypto'
|
|
|
|
AES.new(b'abcdefghijklmnop')
|
|
|
|
|
|
|
|
except TypeError:
|
|
|
|
|
|
|
|
return 'pycrypto'
|
|
|
|
|
|
|
|
return _parent.__name__
|
|
|
|
|
|
|
|