]>
Commit | Line | Data |
---|---|---|
768a0017 | 1 | import types |
2 | ||
f6a765ce | 3 | try: |
4 | import Cryptodome as _parent | |
5 | except ImportError: | |
6 | try: | |
7 | import Crypto as _parent | |
8 | except (ImportError, SyntaxError): # Old Crypto gives SyntaxError in newer Python | |
768a0017 | 9 | _parent = types.ModuleType('no_Cryptodome') |
f6a765ce | 10 | __bool__ = lambda: False |
11 | ||
65f6e807 | 12 | __version__ = '' |
13 | AES = PKCS1_v1_5 = Blowfish = PKCS1_OAEP = SHA1 = CMAC = RSA = None | |
14 | try: | |
15 | if _parent.__name__ == 'Cryptodome': | |
16 | from Cryptodome import __version__ | |
17 | from Cryptodome.Cipher import AES | |
18 | from Cryptodome.Cipher import PKCS1_v1_5 | |
19 | from Cryptodome.Cipher import Blowfish | |
20 | from Cryptodome.Cipher import PKCS1_OAEP | |
21 | from Cryptodome.Hash import SHA1 | |
22 | from Cryptodome.Hash import CMAC | |
23 | from Cryptodome.PublicKey import RSA | |
24 | elif _parent.__name__ == 'Crypto': | |
25 | from Crypto import __version__ | |
26 | from Crypto.Cipher import AES | |
27 | from Crypto.Cipher import PKCS1_v1_5 | |
28 | from Crypto.Cipher import Blowfish | |
29 | from Crypto.Cipher import PKCS1_OAEP | |
30 | from Crypto.Hash import SHA1 | |
31 | from Crypto.Hash import CMAC | |
32 | from Crypto.PublicKey import RSA | |
33 | except ImportError: | |
34 | __version__ = f'broken {__version__}'.strip() | |
f6a765ce | 35 | |
36 | ||
65f6e807 | 37 | _yt_dlp__identifier = _parent.__name__ |
38 | if AES and _yt_dlp__identifier == 'Crypto': | |
39 | try: | |
40 | # In pycrypto, mode defaults to ECB. See: | |
41 | # https://www.pycryptodome.org/en/latest/src/vs_pycrypto.html#:~:text=not%20have%20ECB%20as%20default%20mode | |
42 | AES.new(b'abcdefghijklmnop') | |
43 | except TypeError: | |
44 | _yt_dlp__identifier = 'pycrypto' |