diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f2a752..71138fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -583,6 +583,7 @@ ExternalProject_Add(pycryptodome -DCMAKE_INSTALL_PREFIX:PATH=${INSTALL_PREFIX} -DCMAKE_PREFIX_PATH:PATH=${PREFIX}/${KODI_PATH}%3B%3B${PREFIX}/python/${KODI_PATH} -DBUILD_SHARED_LIBS:BOOL=ON + -DSEPARATE_NAMESPACE:BOOL=ON ) ExternalProject_Add(shairplay diff --git a/patches/pycryptodome.diff b/patches/pycryptodome.diff index 62ad343..fe30982 100644 --- a/patches/pycryptodome.diff +++ b/patches/pycryptodome.diff @@ -1,10 +1,17 @@ --- /dev/null +++ b/CMakeLists.txt -@@ -0,0 +1,257 @@ +@@ -0,0 +1,276 @@ +cmake_minimum_required(VERSION 3.3) + +project(pycryptodome VERSION 3.4.6 LANGUAGES C) + ++option(SEPARATE_NAMESPACE "Install as Cryptodome instead of Crypto" OFF) ++ ++set(NAMESPACE Crypto) ++if(SEPARATE_NAMESPACE) ++ set(NAMESPACE Cryptodome) ++endif() ++ +if(MSVC) + set(CMAKE_DEBUG_POSTFIX "d") +endif() @@ -233,13 +240,13 @@ + set_target_properties(${CRYPTO_LIB} PROPERTIES SUFFIX ".pyd") + + if(${CRYPTO_LIB} IN_LIST CRYPTO_HASH) -+ set(CRYPTO_INSTALL bin/Python/Lib/site-packages/Cryptodome/Hash/) ++ set(CRYPTO_INSTALL bin/Python/Lib/site-packages/${NAMESPACE}/Hash/) + elseif(${CRYPTO_LIB} IN_LIST CRYPTO_CIPHER) -+ set(CRYPTO_INSTALL bin/Python/Lib/site-packages/Cryptodome/Cipher/) ++ set(CRYPTO_INSTALL bin/Python/Lib/site-packages/${NAMESPACE}/Cipher/) + elseif(${CRYPTO_LIB} IN_LIST CRYPTO_UTIL) -+ set(CRYPTO_INSTALL bin/Python/Lib/site-packages/Cryptodome/Util/) ++ set(CRYPTO_INSTALL bin/Python/Lib/site-packages/${NAMESPACE}/Util/) + else() -+ set(CRYPTO_INSTALL bin/Python/Lib/site-packages/Cryptodome/Protocol/) ++ set(CRYPTO_INSTALL bin/Python/Lib/site-packages/${NAMESPACE}/Protocol/) + endif() + + install(TARGETS ${CRYPTO_LIB} @@ -255,1674 +262,25 @@ + +install(DIRECTORY + ${CMAKE_CURRENT_SOURCE_DIR}/lib/Crypto/ -+ DESTINATION bin/Python/Lib/site-packages/Cryptodome ++ DESTINATION bin/Python/Lib/site-packages/${NAMESPACE} + PATTERN SelfTest EXCLUDE +) ++ ++if(SEPARATE_NAMESPACE) ++ install(CODE "file(GLOB_RECURSE PYMODULES ${CMAKE_INSTALL_PREFIX}/bin/Python/Lib/site-packages/${NAMESPACE}/*.py)") ++ install(CODE "foreach(PYMODULE \${PYMODULES}) ++ file(READ \${PYMODULE} content) ++ string(REPLACE \"Crypto.\" \"Cryptodome.\" content \"\${content}\") ++ string(REPLACE \"Crypto \" \"Cryptodome \" content \"\${content}\") ++ string(REPLACE \"'Crypto'\" \"'Cryptodome'\" content \"\${content}\") ++ string(REPLACE \"\\\"Crypto\\\"\" \"\\\"Cryptodome\\\"\" content \"\${content}\") ++ file(WRITE \${PYMODULE} \"\${content}\") ++ endforeach()") ++endif() --- /dev/null +++ b/cmake/pycryptodome-config.cmake @@ -0,0 +1 @@ +include(${CMAKE_CURRENT_LIST_DIR}/pycryptodome.cmake) ---- a/lib/Crypto/Cipher/AES.py -+++ b/lib/Crypto/Cipher/AES.py -@@ -79,13 +79,13 @@ - - import sys - --from Crypto.Cipher import _create_cipher --from Crypto.Util._raw_api import (load_pycryptodome_raw_lib, -+from Cryptodome.Cipher import _create_cipher -+from Cryptodome.Util._raw_api import (load_pycryptodome_raw_lib, - VoidPointer, SmartPointer, - c_size_t, expect_byte_string) - - --_raw_cpuid_lib = load_pycryptodome_raw_lib("Crypto.Util._cpuid", -+_raw_cpuid_lib = load_pycryptodome_raw_lib("Cryptodome.Util._cpuid", - "int have_aes_ni(void);") - - _cproto = """ -@@ -104,13 +104,13 @@ - """ - - --_raw_aes_lib = load_pycryptodome_raw_lib("Crypto.Cipher._raw_aes", -+_raw_aes_lib = load_pycryptodome_raw_lib("Cryptodome.Cipher._raw_aes", - _cproto) - - _raw_aesni_lib = None - try: - if _raw_cpuid_lib.have_aes_ni() == 1: -- _raw_aesni_lib = load_pycryptodome_raw_lib("Crypto.Cipher._raw_aesni", -+ _raw_aesni_lib = load_pycryptodome_raw_lib("Cryptodome.Cipher._raw_aesni", - _cproto.replace("AES", - "AESNI")) - except OSError: ---- a/lib/Crypto/Cipher/ARC2.py -+++ b/lib/Crypto/Cipher/ARC2.py -@@ -56,9 +56,9 @@ - - import sys - --from Crypto.Cipher import _create_cipher --from Crypto.Util.py3compat import byte_string --from Crypto.Util._raw_api import (load_pycryptodome_raw_lib, -+from Cryptodome.Cipher import _create_cipher -+from Cryptodome.Util.py3compat import byte_string -+from Cryptodome.Util._raw_api import (load_pycryptodome_raw_lib, - VoidPointer, SmartPointer, - c_size_t, expect_byte_string) - ---- a/lib/Crypto/Cipher/ARC4.py -+++ b/lib/Crypto/Cipher/ARC4.py -@@ -60,14 +60,14 @@ - :undocumented: __package__ - """ - --from Crypto.Util.py3compat import b -+from Cryptodome.Util.py3compat import b - --from Crypto.Util._raw_api import (load_pycryptodome_raw_lib, VoidPointer, -+from Cryptodome.Util._raw_api import (load_pycryptodome_raw_lib, VoidPointer, - create_string_buffer, get_raw_buffer, - SmartPointer, c_size_t, expect_byte_string) - - --_raw_arc4_lib = load_pycryptodome_raw_lib("Crypto.Cipher._ARC4", """ -+_raw_arc4_lib = load_pycryptodome_raw_lib("Cryptodome.Cipher._ARC4", """ - int ARC4_stream_encrypt(void *rc4State, const uint8_t in[], - uint8_t out[], size_t len); - int ARC4_stream_init(uint8_t *key, size_t keylen, ---- a/lib/Crypto/Cipher/Blowfish.py -+++ b/lib/Crypto/Cipher/Blowfish.py -@@ -52,8 +52,8 @@ - - import sys - --from Crypto.Cipher import _create_cipher --from Crypto.Util._raw_api import (load_pycryptodome_raw_lib, -+from Cryptodome.Cipher import _create_cipher -+from Cryptodome.Util._raw_api import (load_pycryptodome_raw_lib, - VoidPointer, SmartPointer, c_size_t, - expect_byte_string) - ---- a/lib/Crypto/Cipher/CAST.py -+++ b/lib/Crypto/Cipher/CAST.py -@@ -55,9 +55,9 @@ - - import sys - --from Crypto.Cipher import _create_cipher --from Crypto.Util.py3compat import byte_string --from Crypto.Util._raw_api import (load_pycryptodome_raw_lib, -+from Cryptodome.Cipher import _create_cipher -+from Cryptodome.Util.py3compat import byte_string -+from Cryptodome.Util._raw_api import (load_pycryptodome_raw_lib, - VoidPointer, SmartPointer, - c_size_t, expect_byte_string) - ---- a/lib/Crypto/Cipher/ChaCha20.py -+++ b/lib/Crypto/Cipher/ChaCha20.py -@@ -47,15 +47,15 @@ - .. _ChaCha20: http://http://cr.yp.to/chacha.html - """ - --from Crypto.Random import get_random_bytes -+from Cryptodome.Random import get_random_bytes - --from Crypto.Util._raw_api import (load_pycryptodome_raw_lib, -+from Cryptodome.Util._raw_api import (load_pycryptodome_raw_lib, - create_string_buffer, - get_raw_buffer, VoidPointer, - SmartPointer, c_size_t, - expect_byte_string, c_ulong) - --_raw_chacha20_lib = load_pycryptodome_raw_lib("Crypto.Cipher._chacha20", -+_raw_chacha20_lib = load_pycryptodome_raw_lib("Cryptodome.Cipher._chacha20", - """ - int chacha20_init(void **pState, - const uint8_t *key, ---- a/lib/Crypto/Cipher/DES.py -+++ b/lib/Crypto/Cipher/DES.py -@@ -49,9 +49,9 @@ - - import sys - --from Crypto.Cipher import _create_cipher --from Crypto.Util.py3compat import byte_string --from Crypto.Util._raw_api import (load_pycryptodome_raw_lib, -+from Cryptodome.Cipher import _create_cipher -+from Cryptodome.Util.py3compat import byte_string -+from Cryptodome.Util._raw_api import (load_pycryptodome_raw_lib, - VoidPointer, SmartPointer, - c_size_t, expect_byte_string) - ---- a/lib/Crypto/Cipher/DES3.py -+++ b/lib/Crypto/Cipher/DES3.py -@@ -69,9 +69,9 @@ - - import sys - --from Crypto.Cipher import _create_cipher --from Crypto.Util.py3compat import byte_string, b, bchr, bord --from Crypto.Util._raw_api import (load_pycryptodome_raw_lib, -+from Cryptodome.Cipher import _create_cipher -+from Cryptodome.Util.py3compat import byte_string, b, bchr, bord -+from Cryptodome.Util._raw_api import (load_pycryptodome_raw_lib, - VoidPointer, SmartPointer, - c_size_t, expect_byte_string) - ---- a/lib/Crypto/Cipher/PKCS1_OAEP.py -+++ b/lib/Crypto/Cipher/PKCS1_OAEP.py -@@ -49,14 +49,14 @@ - - __all__ = [ 'new', 'PKCS1OAEP_Cipher' ] - --from Crypto.Signature.pss import MGF1 --import Crypto.Hash.SHA1 -+from Cryptodome.Signature.pss import MGF1 -+import Cryptodome.Hash.SHA1 - --from Crypto.Util.py3compat import * --import Crypto.Util.number --from Crypto.Util.number import ceil_div, bytes_to_long, long_to_bytes --from Crypto.Util.strxor import strxor --from Crypto import Random -+from Cryptodome.Util.py3compat import * -+import Cryptodome.Util.number -+from Cryptodome.Util.number import ceil_div, bytes_to_long, long_to_bytes -+from Cryptodome.Util.strxor import strxor -+from Cryptodome import Random - - class PKCS1OAEP_Cipher: - """This cipher can perform PKCS#1 v1.5 OAEP encryption or decryption.""" -@@ -91,7 +91,7 @@ - if hashAlgo: - self._hashObj = hashAlgo - else: -- self._hashObj = Crypto.Hash.SHA1 -+ self._hashObj = Cryptodome.Hash.SHA1 - - if mgfunc: - self._mgf = mgfunc -@@ -130,7 +130,7 @@ - # TODO: Verify the key is RSA - - # See 7.1.1 in RFC3447 -- modBits = Crypto.Util.number.size(self._key.n) -+ modBits = Cryptodome.Util.number.size(self._key.n) - k = ceil_div(modBits,8) # Convert from bits to bytes - hLen = self._hashObj.digest_size - mLen = len(message) -@@ -184,7 +184,7 @@ - """ - - # See 7.1.2 in RFC3447 -- modBits = Crypto.Util.number.size(self._key.n) -+ modBits = Cryptodome.Util.number.size(self._key.n) - k = ceil_div(modBits,8) # Convert from bits to bytes - hLen = self._hashObj.digest_size - ---- a/lib/Crypto/Cipher/PKCS1_v1_5.py -+++ b/lib/Crypto/Cipher/PKCS1_v1_5.py -@@ -69,10 +69,10 @@ - - __all__ = [ 'new', 'PKCS115_Cipher' ] - --from Crypto.Util.number import ceil_div, bytes_to_long, long_to_bytes --from Crypto.Util.py3compat import * --import Crypto.Util.number --from Crypto import Random -+from Cryptodome.Util.number import ceil_div, bytes_to_long, long_to_bytes -+from Cryptodome.Util.py3compat import * -+import Cryptodome.Util.number -+from Cryptodome import Random - - class PKCS115_Cipher: - """This cipher can perform PKCS#1 v1.5 RSA encryption or decryption.""" ---- a/lib/Crypto/Cipher/Salsa20.py -+++ b/lib/Crypto/Cipher/Salsa20.py -@@ -41,15 +41,15 @@ - :undocumented: __package__ - """ - --from Crypto.Util._raw_api import (load_pycryptodome_raw_lib, -+from Cryptodome.Util._raw_api import (load_pycryptodome_raw_lib, - create_string_buffer, - get_raw_buffer, VoidPointer, - SmartPointer, c_size_t, - expect_byte_string) - --from Crypto.Random import get_random_bytes -+from Cryptodome.Random import get_random_bytes - --_raw_salsa20_lib = load_pycryptodome_raw_lib("Crypto.Cipher._Salsa20", -+_raw_salsa20_lib = load_pycryptodome_raw_lib("Cryptodome.Cipher._Salsa20", - """ - int Salsa20_stream_init(uint8_t *key, size_t keylen, - uint8_t *nonce, size_t nonce_len, ---- a/lib/Crypto/Cipher/__init__.py -+++ b/lib/Crypto/Cipher/__init__.py -@@ -39,17 +39,17 @@ - ======================== ======= ======================== - Module name Type Description - ======================== ======= ======================== --`Crypto.Cipher.AES` Block Advanced Encryption Standard --`Crypto.Cipher.ARC2` Block Alleged RC2 --`Crypto.Cipher.ARC4` Stream Alleged RC4 --`Crypto.Cipher.Blowfish` Block Blowfish --`Crypto.Cipher.CAST` Block CAST --`Crypto.Cipher.DES` Block The Data Encryption Standard. -+`Cryptodome.Cipher.AES` Block Advanced Encryption Standard -+`Cryptodome.Cipher.ARC2` Block Alleged RC2 -+`Cryptodome.Cipher.ARC4` Stream Alleged RC4 -+`Cryptodome.Cipher.Blowfish` Block Blowfish -+`Cryptodome.Cipher.CAST` Block CAST -+`Cryptodome.Cipher.DES` Block The Data Encryption Standard. - Very commonly used in the past, - but today its 56-bit keys are too small. --`Crypto.Cipher.DES3` Block Triple DES --`Crypto.Cipher.Salsa20` Stream Salsa20 --`Crypto.Cipher.ChaCha20` Stream ChaCha20 -+`Cryptodome.Cipher.DES3` Block Triple DES -+`Cryptodome.Cipher.Salsa20` Stream Salsa20 -+`Cryptodome.Cipher.ChaCha20` Stream ChaCha20 - ======================== ======= ======================== - - -@@ -65,8 +65,8 @@ - ========================== ======================= - Module name Description - ========================== ======================= --`Crypto.Cipher.PKCS1_v1_5` PKCS#1 v1.5 encryption, based on RSA key pairs --`Crypto.Cipher.PKCS1_OAEP` PKCS#1 OAEP encryption, based on RSA key pairs -+`Cryptodome.Cipher.PKCS1_v1_5` PKCS#1 v1.5 encryption, based on RSA key pairs -+`Cryptodome.Cipher.PKCS1_OAEP` PKCS#1 OAEP encryption, based on RSA key pairs - ========================== ======================= - - :undocumented: __package__, _AES, _ARC2, _ARC4, _Blowfish -@@ -75,17 +75,17 @@ - - import os - --from Crypto.Cipher._mode_ecb import _create_ecb_cipher --from Crypto.Cipher._mode_cbc import _create_cbc_cipher --from Crypto.Cipher._mode_cfb import _create_cfb_cipher --from Crypto.Cipher._mode_ofb import _create_ofb_cipher --from Crypto.Cipher._mode_ctr import _create_ctr_cipher --from Crypto.Cipher._mode_openpgp import _create_openpgp_cipher --from Crypto.Cipher._mode_ccm import _create_ccm_cipher --from Crypto.Cipher._mode_eax import _create_eax_cipher --from Crypto.Cipher._mode_siv import _create_siv_cipher --from Crypto.Cipher._mode_gcm import _create_gcm_cipher --from Crypto.Cipher._mode_ocb import _create_ocb_cipher -+from Cryptodome.Cipher._mode_ecb import _create_ecb_cipher -+from Cryptodome.Cipher._mode_cbc import _create_cbc_cipher -+from Cryptodome.Cipher._mode_cfb import _create_cfb_cipher -+from Cryptodome.Cipher._mode_ofb import _create_ofb_cipher -+from Cryptodome.Cipher._mode_ctr import _create_ctr_cipher -+from Cryptodome.Cipher._mode_openpgp import _create_openpgp_cipher -+from Cryptodome.Cipher._mode_ccm import _create_ccm_cipher -+from Cryptodome.Cipher._mode_eax import _create_eax_cipher -+from Cryptodome.Cipher._mode_siv import _create_siv_cipher -+from Cryptodome.Cipher._mode_gcm import _create_gcm_cipher -+from Cryptodome.Cipher._mode_ocb import _create_ocb_cipher - - _modes = { 1:_create_ecb_cipher, - 2:_create_cbc_cipher, ---- a/lib/Crypto/Cipher/_mode_cbc.py -+++ b/lib/Crypto/Cipher/_mode_cbc.py -@@ -34,13 +34,13 @@ - - __all__ = ['CbcMode'] - --from Crypto.Util._raw_api import (load_pycryptodome_raw_lib, VoidPointer, -+from Cryptodome.Util._raw_api import (load_pycryptodome_raw_lib, VoidPointer, - create_string_buffer, get_raw_buffer, - SmartPointer, c_size_t, expect_byte_string) - --from Crypto.Random import get_random_bytes -+from Cryptodome.Random import get_random_bytes - --raw_cbc_lib = load_pycryptodome_raw_lib("Crypto.Cipher._raw_cbc", """ -+raw_cbc_lib = load_pycryptodome_raw_lib("Cryptodome.Cipher._raw_cbc", """ - int CBC_start_operation(void *cipher, - const uint8_t iv[], - size_t iv_len, ---- a/lib/Crypto/Cipher/_mode_ccm.py -+++ b/lib/Crypto/Cipher/_mode_ccm.py -@@ -34,13 +34,13 @@ - - __all__ = ['CcmMode'] - --from Crypto.Util.py3compat import byte_string, b, bchr, bord, unhexlify -+from Cryptodome.Util.py3compat import byte_string, b, bchr, bord, unhexlify - --from Crypto.Util.strxor import strxor --from Crypto.Util.number import long_to_bytes -+from Cryptodome.Util.strxor import strxor -+from Cryptodome.Util.number import long_to_bytes - --from Crypto.Hash import BLAKE2s --from Crypto.Random import get_random_bytes -+from Cryptodome.Hash import BLAKE2s -+from Cryptodome.Random import get_random_bytes - - - def enum(**enums): ---- a/lib/Crypto/Cipher/_mode_cfb.py -+++ b/lib/Crypto/Cipher/_mode_cfb.py -@@ -26,13 +26,13 @@ - - __all__ = ['CfbMode'] - --from Crypto.Util._raw_api import (load_pycryptodome_raw_lib, VoidPointer, -+from Cryptodome.Util._raw_api import (load_pycryptodome_raw_lib, VoidPointer, - create_string_buffer, get_raw_buffer, - SmartPointer, c_size_t, expect_byte_string) - --from Crypto.Random import get_random_bytes -+from Cryptodome.Random import get_random_bytes - --raw_cfb_lib = load_pycryptodome_raw_lib("Crypto.Cipher._raw_cfb",""" -+raw_cfb_lib = load_pycryptodome_raw_lib("Cryptodome.Cipher._raw_cfb",""" - int CFB_start_operation(void *cipher, - const uint8_t iv[], - size_t iv_len, ---- a/lib/Crypto/Cipher/_mode_ctr.py -+++ b/lib/Crypto/Cipher/_mode_ctr.py -@@ -26,15 +26,15 @@ - - __all__ = ['CtrMode'] - --from Crypto.Util._raw_api import (load_pycryptodome_raw_lib, VoidPointer, -+from Cryptodome.Util._raw_api import (load_pycryptodome_raw_lib, VoidPointer, - create_string_buffer, get_raw_buffer, - SmartPointer, c_size_t, expect_byte_string) - --from Crypto.Random import get_random_bytes --from Crypto.Util.py3compat import b, bchr --from Crypto.Util.number import long_to_bytes -+from Cryptodome.Random import get_random_bytes -+from Cryptodome.Util.py3compat import b, bchr -+from Cryptodome.Util.number import long_to_bytes - --raw_ctr_lib = load_pycryptodome_raw_lib("Crypto.Cipher._raw_ctr", """ -+raw_ctr_lib = load_pycryptodome_raw_lib("Cryptodome.Cipher._raw_ctr", """ - int CTR_start_operation(void *cipher, - uint8_t initialCounterBlock[], - size_t initialCounterBlock_len, -@@ -325,7 +325,7 @@ - little_endian = _counter.pop("little_endian") - except KeyError: - raise TypeError("Incorrect counter object" -- " (use Crypto.Util.Counter.new)") -+ " (use Cryptodome.Util.Counter.new)") - - # Compute initial counter block - words = [] ---- a/lib/Crypto/Cipher/_mode_eax.py -+++ b/lib/Crypto/Cipher/_mode_eax.py -@@ -34,13 +34,13 @@ - - __all__ = ['EaxMode'] - --from Crypto.Util.py3compat import byte_string, bchr, bord, unhexlify, b -+from Cryptodome.Util.py3compat import byte_string, bchr, bord, unhexlify, b - --from Crypto.Util.strxor import strxor --from Crypto.Util.number import long_to_bytes, bytes_to_long -+from Cryptodome.Util.strxor import strxor -+from Cryptodome.Util.number import long_to_bytes, bytes_to_long - --from Crypto.Hash import CMAC, BLAKE2s --from Crypto.Random import get_random_bytes -+from Cryptodome.Hash import CMAC, BLAKE2s -+from Cryptodome.Random import get_random_bytes - - - class EaxMode(object): ---- a/lib/Crypto/Cipher/_mode_ecb.py -+++ b/lib/Crypto/Cipher/_mode_ecb.py -@@ -26,12 +26,12 @@ - - __all__ = [ 'EcbMode' ] - --from Crypto.Util._raw_api import (load_pycryptodome_raw_lib, -+from Cryptodome.Util._raw_api import (load_pycryptodome_raw_lib, - VoidPointer, create_string_buffer, - get_raw_buffer, SmartPointer, - c_size_t, expect_byte_string) - --raw_ecb_lib = load_pycryptodome_raw_lib("Crypto.Cipher._raw_ecb", """ -+raw_ecb_lib = load_pycryptodome_raw_lib("Cryptodome.Cipher._raw_ecb", """ - int ECB_start_operation(void *cipher, - void **pResult); - int ECB_encrypt(void *ecbState, ---- a/lib/Crypto/Cipher/_mode_gcm.py -+++ b/lib/Crypto/Cipher/_mode_gcm.py -@@ -34,17 +34,17 @@ - - __all__ = ['GcmMode'] - --from Crypto.Util.py3compat import b, bchr, byte_string, bord, unhexlify -+from Cryptodome.Util.py3compat import b, bchr, byte_string, bord, unhexlify - --from Crypto.Util.number import long_to_bytes, bytes_to_long --from Crypto.Hash import BLAKE2s --from Crypto.Random import get_random_bytes -+from Cryptodome.Util.number import long_to_bytes, bytes_to_long -+from Cryptodome.Hash import BLAKE2s -+from Cryptodome.Random import get_random_bytes - --from Crypto.Util._raw_api import (load_pycryptodome_raw_lib, VoidPointer, -+from Cryptodome.Util._raw_api import (load_pycryptodome_raw_lib, VoidPointer, - create_string_buffer, get_raw_buffer, - SmartPointer, c_size_t, expect_byte_string) - --_raw_galois_lib = load_pycryptodome_raw_lib("Crypto.Util._galois", -+_raw_galois_lib = load_pycryptodome_raw_lib("Cryptodome.Util._galois", - """ - int ghash( uint8_t y_out[16], - const uint8_t block_data[], ---- a/lib/Crypto/Cipher/_mode_ocb.py -+++ b/lib/Crypto/Cipher/_mode_ocb.py -@@ -45,8 +45,8 @@ - meant for non-military purposes. - - Example: -- >>> from Crypto.Cipher import AES -- >>> from Crypto.Random import get_random_bytes -+ >>> from Cryptodome.Cipher import AES -+ >>> from Cryptodome.Random import get_random_bytes - >>> - >>> key = get_random_bytes(32) - >>> cipher = AES.new(key, AES.MODE_OCB) -@@ -68,19 +68,19 @@ - .. _free licenses: http://web.cs.ucdavis.edu/~rogaway/ocb/license.htm - """ - --from Crypto.Util.py3compat import b, bord, bchr, unhexlify --from Crypto.Util.number import long_to_bytes, bytes_to_long --from Crypto.Util.strxor import strxor -+from Cryptodome.Util.py3compat import b, bord, bchr, unhexlify -+from Cryptodome.Util.number import long_to_bytes, bytes_to_long -+from Cryptodome.Util.strxor import strxor - --from Crypto.Hash import BLAKE2s --from Crypto.Random import get_random_bytes -+from Cryptodome.Hash import BLAKE2s -+from Cryptodome.Random import get_random_bytes - --from Crypto.Util._raw_api import (load_pycryptodome_raw_lib, VoidPointer, -+from Cryptodome.Util._raw_api import (load_pycryptodome_raw_lib, VoidPointer, - create_string_buffer, get_raw_buffer, - SmartPointer, c_size_t, expect_byte_string, - ) - --_raw_ocb_lib = load_pycryptodome_raw_lib("Crypto.Cipher._raw_ocb", """ -+_raw_ocb_lib = load_pycryptodome_raw_lib("Cryptodome.Cipher._raw_ocb", """ - int OCB_start_operation(void *cipher, - const uint8_t *offset_0, - size_t offset_0_len, ---- a/lib/Crypto/Cipher/_mode_ofb.py -+++ b/lib/Crypto/Cipher/_mode_ofb.py -@@ -26,13 +26,13 @@ - - __all__ = ['OfbMode'] - --from Crypto.Util._raw_api import (load_pycryptodome_raw_lib, VoidPointer, -+from Cryptodome.Util._raw_api import (load_pycryptodome_raw_lib, VoidPointer, - create_string_buffer, get_raw_buffer, - SmartPointer, c_size_t, expect_byte_string) - --from Crypto.Random import get_random_bytes -+from Cryptodome.Random import get_random_bytes - --raw_ofb_lib = load_pycryptodome_raw_lib("Crypto.Cipher._raw_ofb", """ -+raw_ofb_lib = load_pycryptodome_raw_lib("Cryptodome.Cipher._raw_ofb", """ - int OFB_start_operation(void *cipher, - const uint8_t iv[], - size_t iv_len, ---- a/lib/Crypto/Cipher/_mode_openpgp.py -+++ b/lib/Crypto/Cipher/_mode_openpgp.py -@@ -34,8 +34,8 @@ - - __all__ = ['OpenPgpMode'] - --from Crypto.Util.py3compat import bchr --from Crypto.Random import get_random_bytes -+from Cryptodome.Util.py3compat import bchr -+from Cryptodome.Random import get_random_bytes - - class OpenPgpMode(object): - """OpenPGP mode. ---- a/lib/Crypto/Cipher/_mode_siv.py -+++ b/lib/Crypto/Cipher/_mode_siv.py -@@ -36,12 +36,12 @@ - - from binascii import hexlify - --from Crypto.Util.py3compat import byte_string, bord, unhexlify, b -+from Cryptodome.Util.py3compat import byte_string, bord, unhexlify, b - --from Crypto.Util.number import long_to_bytes, bytes_to_long --from Crypto.Protocol.KDF import _S2V --from Crypto.Hash import BLAKE2s --from Crypto.Random import get_random_bytes -+from Cryptodome.Util.number import long_to_bytes, bytes_to_long -+from Cryptodome.Protocol.KDF import _S2V -+from Cryptodome.Hash import BLAKE2s -+from Cryptodome.Random import get_random_bytes - - - class SivMode(object): ---- a/lib/Crypto/Hash/BLAKE2b.py -+++ b/lib/Crypto/Hash/BLAKE2b.py -@@ -58,16 +58,16 @@ - - from binascii import unhexlify - --from Crypto.Util.py3compat import b, bord, tobytes -+from Cryptodome.Util.py3compat import b, bord, tobytes - --from Crypto.Random import get_random_bytes --from Crypto.Util._raw_api import (load_pycryptodome_raw_lib, -+from Cryptodome.Random import get_random_bytes -+from Cryptodome.Util._raw_api import (load_pycryptodome_raw_lib, - VoidPointer, SmartPointer, - create_string_buffer, - get_raw_buffer, c_size_t, - expect_byte_string) - --_raw_blake2b_lib = load_pycryptodome_raw_lib("Crypto.Hash._BLAKE2b", -+_raw_blake2b_lib = load_pycryptodome_raw_lib("Cryptodome.Hash._BLAKE2b", - """ - int blake2b_init(void **state, - const uint8_t *key, ---- a/lib/Crypto/Hash/BLAKE2s.py -+++ b/lib/Crypto/Hash/BLAKE2s.py -@@ -58,16 +58,16 @@ - - from binascii import unhexlify - --from Crypto.Util.py3compat import b, bord, tobytes -+from Cryptodome.Util.py3compat import b, bord, tobytes - --from Crypto.Random import get_random_bytes --from Crypto.Util._raw_api import (load_pycryptodome_raw_lib, -+from Cryptodome.Random import get_random_bytes -+from Cryptodome.Util._raw_api import (load_pycryptodome_raw_lib, - VoidPointer, SmartPointer, - create_string_buffer, - get_raw_buffer, c_size_t, - expect_byte_string) - --_raw_blake2s_lib = load_pycryptodome_raw_lib("Crypto.Hash._BLAKE2s", -+_raw_blake2s_lib = load_pycryptodome_raw_lib("Cryptodome.Hash._BLAKE2s", - """ - int blake2s_init(void **state, - const uint8_t *key, ---- a/lib/Crypto/Hash/CMAC.py -+++ b/lib/Crypto/Hash/CMAC.py -@@ -69,14 +69,14 @@ - .. _OMAC1: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html - """ - --from Crypto.Util.py3compat import b, bchr, bord, tobytes -+from Cryptodome.Util.py3compat import b, bchr, bord, tobytes - - from binascii import unhexlify - --from Crypto.Hash import BLAKE2s --from Crypto.Util.strxor import strxor --from Crypto.Util.number import long_to_bytes, bytes_to_long --from Crypto.Random import get_random_bytes -+from Cryptodome.Hash import BLAKE2s -+from Cryptodome.Util.strxor import strxor -+from Cryptodome.Util.number import long_to_bytes, bytes_to_long -+from Cryptodome.Random import get_random_bytes - - #: The size of the authentication tag produced by the MAC. - digest_size = None ---- a/lib/Crypto/Hash/HMAC.py -+++ b/lib/Crypto/Hash/HMAC.py -@@ -74,13 +74,13 @@ - - __all__ = ['new', 'HMAC'] - --from Crypto.Util.py3compat import b, bchr, bord, tobytes -+from Cryptodome.Util.py3compat import b, bchr, bord, tobytes - - from binascii import unhexlify - - import MD5, BLAKE2s --from Crypto.Util.strxor import strxor --from Crypto.Random import get_random_bytes -+from Cryptodome.Util.strxor import strxor -+from Cryptodome.Random import get_random_bytes - - - class HMAC: ---- a/lib/Crypto/Hash/MD2.py -+++ b/lib/Crypto/Hash/MD2.py -@@ -45,16 +45,16 @@ - .. _RFC1319: http://tools.ietf.org/html/rfc1319 - """ - --from Crypto.Util.py3compat import bord -+from Cryptodome.Util.py3compat import bord - --from Crypto.Util._raw_api import (load_pycryptodome_raw_lib, -+from Cryptodome.Util._raw_api import (load_pycryptodome_raw_lib, - VoidPointer, SmartPointer, - create_string_buffer, - get_raw_buffer, c_size_t, - expect_byte_string) - - _raw_md2_lib = load_pycryptodome_raw_lib( -- "Crypto.Hash._MD2", -+ "Cryptodome.Hash._MD2", - """ - int md2_init(void **shaState); - int md2_destroy(void *shaState); ---- a/lib/Crypto/Hash/MD4.py -+++ b/lib/Crypto/Hash/MD4.py -@@ -43,16 +43,16 @@ - .. _RFC1320: http://tools.ietf.org/html/rfc1320 - """ - --from Crypto.Util.py3compat import bord -+from Cryptodome.Util.py3compat import bord - --from Crypto.Util._raw_api import (load_pycryptodome_raw_lib, -+from Cryptodome.Util._raw_api import (load_pycryptodome_raw_lib, - VoidPointer, SmartPointer, - create_string_buffer, - get_raw_buffer, c_size_t, - expect_byte_string) - - _raw_md4_lib = load_pycryptodome_raw_lib( -- "Crypto.Hash._MD4", -+ "Cryptodome.Hash._MD4", - """ - int md4_init(void **shaState); - int md4_destroy(void *shaState); ---- a/lib/Crypto/Hash/MD5.py -+++ b/lib/Crypto/Hash/MD5.py -@@ -37,7 +37,7 @@ - - __all__ = ['new', 'block_size', 'digest_size'] - --from Crypto.Util.py3compat import * -+from Cryptodome.Util.py3compat import * - - def __make_constructor(): - try: ---- a/lib/Crypto/Hash/RIPEMD.py -+++ b/lib/Crypto/Hash/RIPEMD.py -@@ -23,4 +23,4 @@ - - """Deprecated alias for `Crypto.Hash.RIPEMD160`""" - --from Crypto.Hash.RIPEMD160 import new, block_size, digest_size -+from Cryptodome.Hash.RIPEMD160 import new, block_size, digest_size ---- a/lib/Crypto/Hash/RIPEMD160.py -+++ b/lib/Crypto/Hash/RIPEMD160.py -@@ -48,16 +48,16 @@ - .. _RIPEMD-160: http://homes.esat.kuleuven.be/~bosselae/ripemd160.html - """ - --from Crypto.Util.py3compat import bord -+from Cryptodome.Util.py3compat import bord - --from Crypto.Util._raw_api import (load_pycryptodome_raw_lib, -+from Cryptodome.Util._raw_api import (load_pycryptodome_raw_lib, - VoidPointer, SmartPointer, - create_string_buffer, - get_raw_buffer, c_size_t, - expect_byte_string) - - _raw_ripemd160_lib = load_pycryptodome_raw_lib( -- "Crypto.Hash._RIPEMD160", -+ "Cryptodome.Hash._RIPEMD160", - """ - int ripemd160_init(void **shaState); - int ripemd160_destroy(void *shaState); ---- a/lib/Crypto/Hash/SHA.py -+++ b/lib/Crypto/Hash/SHA.py -@@ -21,4 +21,4 @@ - # This file exists for backward compatibility with old code that refers to - # Crypto.Hash.SHA - --from Crypto.Hash.SHA1 import __doc__, new, block_size, digest_size -+from Cryptodome.Hash.SHA1 import __doc__, new, block_size, digest_size ---- a/lib/Crypto/Hash/SHA1.py -+++ b/lib/Crypto/Hash/SHA1.py -@@ -37,7 +37,7 @@ - - __all__ = ['new', 'block_size', 'digest_size'] - --from Crypto.Util.py3compat import * -+from Cryptodome.Util.py3compat import * - - def __make_constructor(): - try: ---- a/lib/Crypto/Hash/SHA224.py -+++ b/lib/Crypto/Hash/SHA224.py -@@ -34,15 +34,15 @@ - .. _SHA-2: http://csrc.nist.gov/publications/fips/fips180-2/fips180-4.pdf - """ - --from Crypto.Util.py3compat import * -+from Cryptodome.Util.py3compat import * - --from Crypto.Util._raw_api import (load_pycryptodome_raw_lib, -+from Cryptodome.Util._raw_api import (load_pycryptodome_raw_lib, - VoidPointer, SmartPointer, - create_string_buffer, - get_raw_buffer, c_size_t, - expect_byte_string) - --_raw_sha224_lib = load_pycryptodome_raw_lib("Crypto.Hash._SHA224", -+_raw_sha224_lib = load_pycryptodome_raw_lib("Cryptodome.Hash._SHA224", - """ - int SHA224_init(void **shaState); - int SHA224_destroy(void *shaState); ---- a/lib/Crypto/Hash/SHA256.py -+++ b/lib/Crypto/Hash/SHA256.py -@@ -34,15 +34,15 @@ - .. _SHA-2: http://csrc.nist.gov/publications/fips/fips180-2/fips180-4.pdf - """ - --from Crypto.Util.py3compat import * -+from Cryptodome.Util.py3compat import * - --from Crypto.Util._raw_api import (load_pycryptodome_raw_lib, -+from Cryptodome.Util._raw_api import (load_pycryptodome_raw_lib, - VoidPointer, SmartPointer, - create_string_buffer, - get_raw_buffer, c_size_t, - expect_byte_string) - --_raw_sha256_lib = load_pycryptodome_raw_lib("Crypto.Hash._SHA256", -+_raw_sha256_lib = load_pycryptodome_raw_lib("Cryptodome.Hash._SHA256", - """ - int SHA256_init(void **shaState); - int SHA256_destroy(void *shaState); ---- a/lib/Crypto/Hash/SHA384.py -+++ b/lib/Crypto/Hash/SHA384.py -@@ -34,15 +34,15 @@ - .. _SHA-2: http://csrc.nist.gov/publications/fips/fips180-2/fips180-4.pdf - """ - --from Crypto.Util.py3compat import * -+from Cryptodome.Util.py3compat import * - --from Crypto.Util._raw_api import (load_pycryptodome_raw_lib, -+from Cryptodome.Util._raw_api import (load_pycryptodome_raw_lib, - VoidPointer, SmartPointer, - create_string_buffer, - get_raw_buffer, c_size_t, - expect_byte_string) - --_raw_sha384_lib = load_pycryptodome_raw_lib("Crypto.Hash._SHA384", -+_raw_sha384_lib = load_pycryptodome_raw_lib("Cryptodome.Hash._SHA384", - """ - int SHA384_init(void **shaState); - int SHA384_destroy(void *shaState); ---- a/lib/Crypto/Hash/SHA3_224.py -+++ b/lib/Crypto/Hash/SHA3_224.py -@@ -34,15 +34,15 @@ - .. __: http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf - """ - --from Crypto.Util.py3compat import bord -+from Cryptodome.Util.py3compat import bord - --from Crypto.Util._raw_api import (load_pycryptodome_raw_lib, -+from Cryptodome.Util._raw_api import (load_pycryptodome_raw_lib, - VoidPointer, SmartPointer, - create_string_buffer, - get_raw_buffer, c_size_t, - expect_byte_string) - --from Crypto.Hash.keccak import _raw_keccak_lib -+from Cryptodome.Hash.keccak import _raw_keccak_lib - - class SHA3_224_Hash(object): - """Class that implements a SHA-3/224 hash ---- a/lib/Crypto/Hash/SHA3_256.py -+++ b/lib/Crypto/Hash/SHA3_256.py -@@ -34,15 +34,15 @@ - .. __: http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf - """ - --from Crypto.Util.py3compat import bord -+from Cryptodome.Util.py3compat import bord - --from Crypto.Util._raw_api import (load_pycryptodome_raw_lib, -+from Cryptodome.Util._raw_api import (load_pycryptodome_raw_lib, - VoidPointer, SmartPointer, - create_string_buffer, - get_raw_buffer, c_size_t, - expect_byte_string) - --from Crypto.Hash.keccak import _raw_keccak_lib -+from Cryptodome.Hash.keccak import _raw_keccak_lib - - class SHA3_256_Hash(object): - """Class that implements a SHA-3/256 hash ---- a/lib/Crypto/Hash/SHA3_384.py -+++ b/lib/Crypto/Hash/SHA3_384.py -@@ -34,15 +34,15 @@ - .. __: http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf - """ - --from Crypto.Util.py3compat import bord -+from Cryptodome.Util.py3compat import bord - --from Crypto.Util._raw_api import (load_pycryptodome_raw_lib, -+from Cryptodome.Util._raw_api import (load_pycryptodome_raw_lib, - VoidPointer, SmartPointer, - create_string_buffer, - get_raw_buffer, c_size_t, - expect_byte_string) - --from Crypto.Hash.keccak import _raw_keccak_lib -+from Cryptodome.Hash.keccak import _raw_keccak_lib - - class SHA3_384_Hash(object): - """Class that implements a SHA-3/384 hash ---- a/lib/Crypto/Hash/SHA3_512.py -+++ b/lib/Crypto/Hash/SHA3_512.py -@@ -34,15 +34,15 @@ - .. __: http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf - """ - --from Crypto.Util.py3compat import bord -+from Cryptodome.Util.py3compat import bord - --from Crypto.Util._raw_api import (load_pycryptodome_raw_lib, -+from Cryptodome.Util._raw_api import (load_pycryptodome_raw_lib, - VoidPointer, SmartPointer, - create_string_buffer, - get_raw_buffer, c_size_t, - expect_byte_string) - --from Crypto.Hash.keccak import _raw_keccak_lib -+from Cryptodome.Hash.keccak import _raw_keccak_lib - - class SHA3_512_Hash(object): - """Class that implements a SHA-3/512 hash ---- a/lib/Crypto/Hash/SHA512.py -+++ b/lib/Crypto/Hash/SHA512.py -@@ -34,15 +34,15 @@ - .. _SHA-2: http://csrc.nist.gov/publications/fips/fips180-2/fips180-4.pdf - """ - --from Crypto.Util.py3compat import * -+from Cryptodome.Util.py3compat import * - --from Crypto.Util._raw_api import (load_pycryptodome_raw_lib, -+from Cryptodome.Util._raw_api import (load_pycryptodome_raw_lib, - VoidPointer, SmartPointer, - create_string_buffer, - get_raw_buffer, c_size_t, - expect_byte_string) - --_raw_sha512_lib = load_pycryptodome_raw_lib("Crypto.Hash._SHA512", -+_raw_sha512_lib = load_pycryptodome_raw_lib("Cryptodome.Hash._SHA512", - """ - int SHA512_init(void **shaState); - int SHA512_destroy(void *shaState); ---- a/lib/Crypto/Hash/SHAKE128.py -+++ b/lib/Crypto/Hash/SHAKE128.py -@@ -51,15 +51,15 @@ - .. _FIPS 202: http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf - """ - --from Crypto.Util.py3compat import bord -+from Cryptodome.Util.py3compat import bord - --from Crypto.Util._raw_api import (load_pycryptodome_raw_lib, -+from Cryptodome.Util._raw_api import (load_pycryptodome_raw_lib, - VoidPointer, SmartPointer, - create_string_buffer, - get_raw_buffer, c_size_t, - expect_byte_string) - --from Crypto.Hash.keccak import _raw_keccak_lib -+from Cryptodome.Hash.keccak import _raw_keccak_lib - - class SHAKE128_XOF(object): - """Class that implements a SHAKE128 XOF ---- a/lib/Crypto/Hash/SHAKE256.py -+++ b/lib/Crypto/Hash/SHAKE256.py -@@ -51,15 +51,15 @@ - .. _FIPS 202: http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf - """ - --from Crypto.Util.py3compat import bord -+from Cryptodome.Util.py3compat import bord - --from Crypto.Util._raw_api import (load_pycryptodome_raw_lib, -+from Cryptodome.Util._raw_api import (load_pycryptodome_raw_lib, - VoidPointer, SmartPointer, - create_string_buffer, - get_raw_buffer, c_size_t, - expect_byte_string) - --from Crypto.Hash.keccak import _raw_keccak_lib -+from Cryptodome.Hash.keccak import _raw_keccak_lib - - class SHAKE256_XOF(object): - """Class that implements a SHAKE256 XOF ---- a/lib/Crypto/Hash/keccak.py -+++ b/lib/Crypto/Hash/keccak.py -@@ -49,15 +49,15 @@ - .. _Keccak: http://www.keccak.noekeon.org/Keccak-specifications.pdf - """ - --from Crypto.Util.py3compat import bord -+from Cryptodome.Util.py3compat import bord - --from Crypto.Util._raw_api import (load_pycryptodome_raw_lib, -+from Cryptodome.Util._raw_api import (load_pycryptodome_raw_lib, - VoidPointer, SmartPointer, - create_string_buffer, - get_raw_buffer, c_size_t, - expect_byte_string) - --_raw_keccak_lib = load_pycryptodome_raw_lib("Crypto.Hash._keccak", -+_raw_keccak_lib = load_pycryptodome_raw_lib("Cryptodome.Hash._keccak", - """ - int keccak_init(void **state, - size_t capacity_bytes, ---- a/lib/Crypto/IO/PEM.py -+++ b/lib/Crypto/IO/PEM.py -@@ -43,16 +43,16 @@ - - __all__ = ['encode', 'decode'] - --from Crypto.Util.py3compat import b, hexlify, unhexlify, tobytes, tostr -+from Cryptodome.Util.py3compat import b, hexlify, unhexlify, tobytes, tostr - - import re - from binascii import a2b_base64, b2a_base64 - --from Crypto.Hash import MD5 --from Crypto.Util.Padding import pad, unpad --from Crypto.Cipher import DES, DES3, AES --from Crypto.Protocol.KDF import PBKDF1 --from Crypto.Random import get_random_bytes -+from Cryptodome.Hash import MD5 -+from Cryptodome.Util.Padding import pad, unpad -+from Cryptodome.Cipher import DES, DES3, AES -+from Cryptodome.Protocol.KDF import PBKDF1 -+from Cryptodome.Random import get_random_bytes - - - def encode(data, marker, passphrase=None, randfunc=None): ---- a/lib/Crypto/IO/PKCS8.py -+++ b/lib/Crypto/IO/PKCS8.py -@@ -61,16 +61,16 @@ - - """ - --from Crypto.Util.py3compat import * -+from Cryptodome.Util.py3compat import * - --from Crypto.Util.asn1 import ( -+from Cryptodome.Util.asn1 import ( - DerNull, - DerSequence, - DerObjectId, - DerOctetString, - ) - --from Crypto.IO._PBES import PBES1, PBES2, PbesError -+from Cryptodome.IO._PBES import PBES1, PBES2, PbesError - - - __all__ = ['wrap', 'unwrap'] ---- a/lib/Crypto/IO/_PBES.py -+++ b/lib/Crypto/IO/_PBES.py -@@ -31,18 +31,18 @@ - # POSSIBILITY OF SUCH DAMAGE. - # =================================================================== - --from Crypto.Util.py3compat import * -+from Cryptodome.Util.py3compat import * - --from Crypto import Random --from Crypto.Util.asn1 import ( -+from Cryptodome import Random -+from Cryptodome.Util.asn1 import ( - DerSequence, DerOctetString, - DerObjectId, DerInteger, - ) - --from Crypto.Util.Padding import pad, unpad --from Crypto.Hash import MD5, SHA1 --from Crypto.Cipher import DES, ARC2, DES3, AES --from Crypto.Protocol.KDF import PBKDF1, PBKDF2, scrypt -+from Cryptodome.Util.Padding import pad, unpad -+from Cryptodome.Hash import MD5, SHA1 -+from Cryptodome.Cipher import DES, ARC2, DES3, AES -+from Cryptodome.Protocol.KDF import PBKDF1, PBKDF2, scrypt - - class PbesError(ValueError): - pass ---- a/lib/Crypto/IO/__init__.py -+++ b/lib/Crypto/IO/__init__.py -@@ -34,8 +34,8 @@ - ======================== ============================================= - Module Description - ======================== ============================================= --Crypto.Util.PEM Set of functions for encapsulating data according to the PEM format. --Crypto.Util.PKCS8 Set of functions for wrapping/unwrapping private keys. -+Cryptodome.Util.PEM Set of functions for encapsulating data according to the PEM format. -+Cryptodome.Util.PKCS8 Set of functions for wrapping/unwrapping private keys. - ======================== ============================================= - - :undocumented: _PBES ---- a/lib/Crypto/Math/Numbers.py -+++ b/lib/Crypto/Math/Numbers.py -@@ -35,14 +35,14 @@ - - __all__ = ["Integer"] - --from Crypto.Util.py3compat import * --from Crypto import Random -+from Cryptodome.Util.py3compat import * -+from Cryptodome import Random - - try: -- from Crypto.Math._Numbers_gmp import Integer -- from Crypto.Math._Numbers_gmp import implementation as _implementation -+ from Cryptodome.Math._Numbers_gmp import Integer -+ from Cryptodome.Math._Numbers_gmp import implementation as _implementation - except (ImportError, OSError): -- from Crypto.Math._Numbers_int import Integer -+ from Cryptodome.Math._Numbers_int import Integer - _implementation = { } - - ---- a/lib/Crypto/Math/Primality.py -+++ b/lib/Crypto/Math/Primality.py -@@ -33,8 +33,8 @@ - :undocumented: __package__ - """ - --from Crypto.Math.Numbers import Integer --from Crypto import Random -+from Cryptodome.Math.Numbers import Integer -+from Cryptodome import Random - - COMPOSITE = 0 - PROBABLY_PRIME = 1 -@@ -202,7 +202,7 @@ - return COMPOSITE - - --from Crypto.Util.number import sieve_base as _sieve_base -+from Cryptodome.Util.number import sieve_base as _sieve_base - ## The optimal number of small primes to use for the sieve - ## is probably dependent on the platform and the candidate size - _sieve_base = _sieve_base[:100] ---- a/lib/Crypto/Math/_Numbers_gmp.py -+++ b/lib/Crypto/Math/_Numbers_gmp.py -@@ -28,9 +28,9 @@ - # POSSIBILITY OF SUCH DAMAGE. - # =================================================================== - --from Crypto.Util.py3compat import tobytes, b, bchr -+from Cryptodome.Util.py3compat import tobytes, b, bchr - --from Crypto.Util._raw_api import (backend, load_lib, -+from Cryptodome.Util._raw_api import (backend, load_lib, - get_raw_buffer, get_c_string, - null_pointer, create_string_buffer, - c_ulong, c_ulonglong, c_size_t) -@@ -109,9 +109,9 @@ - c_ulong = c_ulonglong - # Try to load private MPIR lib first (wheel) - try: -- from Crypto.Util._file_system import pycryptodome_filename -+ from Cryptodome.Util._file_system import pycryptodome_filename - -- mpir_dll = pycryptodome_filename(("Crypto", "Math"), "mpir.dll") -+ mpir_dll = pycryptodome_filename(("Cryptodome", "Math"), "mpir.dll") - lib = load_lib(mpir_dll, gmp_defs) - except OSError: - lib = load_lib("mpir", gmp_defs) -@@ -134,7 +134,7 @@ - - else: - # We are using CFFI -- from Crypto.Util._raw_api import ffi -+ from Cryptodome.Util._raw_api import ffi - - def new_mpz(): - return ffi.new("MPZ*") ---- a/lib/Crypto/Math/_Numbers_int.py -+++ b/lib/Crypto/Math/_Numbers_int.py -@@ -28,8 +28,8 @@ - # POSSIBILITY OF SUCH DAMAGE. - # =================================================================== - --from Crypto.Util.number import long_to_bytes, bytes_to_long --from Crypto.Util.py3compat import maxint -+from Cryptodome.Util.number import long_to_bytes, bytes_to_long -+from Cryptodome.Util.py3compat import maxint - - class Integer(object): - """A class to model a natural integer (including zero)""" ---- a/lib/Crypto/Protocol/KDF.py -+++ b/lib/Crypto/Protocol/KDF.py -@@ -34,23 +34,23 @@ - import struct - from struct import unpack - --from Crypto.Util.py3compat import * -+from Cryptodome.Util.py3compat import * - --from Crypto.Hash import SHA1, SHA256, HMAC, CMAC --from Crypto.Util.strxor import strxor --from Crypto.Util.number import size as bit_size, long_to_bytes, bytes_to_long -+from Cryptodome.Hash import SHA1, SHA256, HMAC, CMAC -+from Cryptodome.Util.strxor import strxor -+from Cryptodome.Util.number import size as bit_size, long_to_bytes, bytes_to_long - --from Crypto.Util._raw_api import (load_pycryptodome_raw_lib, -+from Cryptodome.Util._raw_api import (load_pycryptodome_raw_lib, - create_string_buffer, - get_raw_buffer, c_size_t) - --_raw_salsa20_lib = load_pycryptodome_raw_lib("Crypto.Cipher._Salsa20", -+_raw_salsa20_lib = load_pycryptodome_raw_lib("Cryptodome.Cipher._Salsa20", - """ - int Salsa20_8_core(const uint8_t *x, const uint8_t *y, - uint8_t *out); - """) - --_raw_scrypt_lib = load_pycryptodome_raw_lib("Crypto.Protocol._scrypt", -+_raw_scrypt_lib = load_pycryptodome_raw_lib("Cryptodome.Protocol._scrypt", - """ - typedef int (core_t)(const uint8_t [64], const uint8_t [64], uint8_t [64]); - int scryptROMix(const uint8_t *data_in, uint8_t *data_out, ---- a/lib/Crypto/Protocol/SecretSharing.py -+++ b/lib/Crypto/Protocol/SecretSharing.py -@@ -40,10 +40,10 @@ - secret, unless *k* players gather together to assemble their shares. - """ - --from Crypto.Util.py3compat import * --from Crypto.Util import number --from Crypto.Util.number import long_to_bytes, bytes_to_long --from Crypto.Random import get_random_bytes as rng -+from Cryptodome.Util.py3compat import * -+from Cryptodome.Util import number -+from Cryptodome.Util.number import long_to_bytes, bytes_to_long -+from Cryptodome.Random import get_random_bytes as rng - - def _mult_gf2(f1, f2): - """Multiply two polynomials in GF(2)""" ---- a/lib/Crypto/Protocol/__init__.py -+++ b/lib/Crypto/Protocol/__init__.py -@@ -33,10 +33,10 @@ - Implements various cryptographic protocols. (Don't expect to find - network protocols here.) - --Crypto.Protocol.KDF -+Cryptodome.Protocol.KDF - A collection of standard key derivation functions. - --Crypto.Protocol.SecretSharing -+Cryptodome.Protocol.SecretSharing - Distribute a secret amongst a group of participants. - """ - ---- a/lib/Crypto/PublicKey/DSA.py -+++ b/lib/Crypto/PublicKey/DSA.py -@@ -89,22 +89,22 @@ - import struct - import itertools - --from Crypto.Util.py3compat import * -+from Cryptodome.Util.py3compat import * - --from Crypto import Random --from Crypto.IO import PKCS8, PEM --from Crypto.Hash import SHA256 --from Crypto.Util.asn1 import ( -+from Cryptodome import Random -+from Cryptodome.IO import PKCS8, PEM -+from Cryptodome.Hash import SHA256 -+from Cryptodome.Util.asn1 import ( - DerObject, DerSequence, - DerInteger, DerObjectId, - DerBitString, - ) - --from Crypto.Math.Numbers import Integer --from Crypto.Math.Primality import (test_probable_prime, COMPOSITE, -+from Cryptodome.Math.Numbers import Integer -+from Cryptodome.Math.Primality import (test_probable_prime, COMPOSITE, - PROBABLY_PRIME) - --from Crypto.PublicKey import (_expand_subject_public_key_info, -+from Cryptodome.PublicKey import (_expand_subject_public_key_info, - _create_subject_public_key_info, - _extract_subject_public_key_info) - -@@ -379,10 +379,10 @@ - # Methods defined in PyCrypto that we don't support anymore - - def sign(self, M, K): -- raise NotImplementedError("Use module Crypto.Signature.DSS instead") -+ raise NotImplementedError("Use module Cryptodome.Signature.DSS instead") - - def verify(self, M, signature): -- raise NotImplementedError("Use module Crypto.Signature.DSS instead") -+ raise NotImplementedError("Use module Cryptodome.Signature.DSS instead") - - def encrypt(self, plaintext, K): - raise NotImplementedError ---- a/lib/Crypto/PublicKey/ECC.py -+++ b/lib/Crypto/PublicKey/ECC.py -@@ -78,15 +78,15 @@ - import struct - import binascii - --from Crypto.Util.py3compat import bord, tobytes, b, tostr, bchr -+from Cryptodome.Util.py3compat import bord, tobytes, b, tostr, bchr - --from Crypto.Math.Numbers import Integer --from Crypto.Random import get_random_bytes --from Crypto.Util.asn1 import (DerObjectId, DerOctetString, DerSequence, -+from Cryptodome.Math.Numbers import Integer -+from Cryptodome.Random import get_random_bytes -+from Cryptodome.Util.asn1 import (DerObjectId, DerOctetString, DerSequence, - DerBitString) - --from Crypto.IO import PKCS8, PEM --from Crypto.PublicKey import (_expand_subject_public_key_info, -+from Cryptodome.IO import PKCS8, PEM -+from Cryptodome.PublicKey import (_expand_subject_public_key_info, - _create_subject_public_key_info, - _extract_subject_public_key_info) - ---- a/lib/Crypto/PublicKey/ElGamal.py -+++ b/lib/Crypto/PublicKey/ElGamal.py -@@ -106,10 +106,10 @@ - - __all__ = ['generate', 'construct', 'ElGamalKey'] - --from Crypto import Random --from Crypto.Math.Primality import ( generate_probable_safe_prime, -+from Cryptodome import Random -+from Cryptodome.Math.Primality import ( generate_probable_safe_prime, - test_probable_prime, COMPOSITE ) --from Crypto.Math.Numbers import Integer -+from Cryptodome.Math.Numbers import Integer - - # Generate an ElGamal key with N bits - def generate(bits, randfunc): ---- a/lib/Crypto/PublicKey/RSA.py -+++ b/lib/Crypto/PublicKey/RSA.py -@@ -75,16 +75,16 @@ - import binascii - import struct - --from Crypto import Random --from Crypto.IO import PKCS8, PEM --from Crypto.Util.py3compat import tobytes, bord, bchr, b, tostr --from Crypto.Util.asn1 import DerSequence -+from Cryptodome import Random -+from Cryptodome.IO import PKCS8, PEM -+from Cryptodome.Util.py3compat import tobytes, bord, bchr, b, tostr -+from Cryptodome.Util.asn1 import DerSequence - --from Crypto.Math.Numbers import Integer --from Crypto.Math.Primality import (test_probable_prime, -+from Cryptodome.Math.Numbers import Integer -+from Cryptodome.Math.Primality import (test_probable_prime, - generate_probable_prime, COMPOSITE) - --from Crypto.PublicKey import (_expand_subject_public_key_info, -+from Cryptodome.PublicKey import (_expand_subject_public_key_info, - _create_subject_public_key_info, - _extract_subject_public_key_info) - -@@ -381,16 +381,16 @@ - - # Methods defined in PyCrypto that we don't support anymore - def sign(self, M, K): -- raise NotImplementedError("Use module Crypto.Signature.pkcs1_15 instead") -+ raise NotImplementedError("Use module Cryptodome.Signature.pkcs1_15 instead") - - def verify(self, M, signature): -- raise NotImplementedError("Use module Crypto.Signature.pkcs1_15 instead") -+ raise NotImplementedError("Use module Cryptodome.Signature.pkcs1_15 instead") - - def encrypt(self, plaintext, K): -- raise NotImplementedError("Use module Crypto.Cipher.PKCS1_OAEP instead") -+ raise NotImplementedError("Use module Cryptodome.Cipher.PKCS1_OAEP instead") - - def decrypt(self, ciphertext): -- raise NotImplementedError("Use module Crypto.Cipher.PKCS1_OAEP instead") -+ raise NotImplementedError("Use module Cryptodome.Cipher.PKCS1_OAEP instead") - - def blind(self, M, B): - raise NotImplementedError ---- a/lib/Crypto/PublicKey/__init__.py -+++ b/lib/Crypto/PublicKey/__init__.py -@@ -26,7 +26,7 @@ - be used to sign messages, and some can *only* be used for signatures. - """ - --from Crypto.Util.asn1 import (DerSequence, DerInteger, DerBitString, -+from Cryptodome.Util.asn1 import (DerSequence, DerInteger, DerBitString, - DerObjectId, DerNull) - - ---- a/lib/Crypto/Random/random.py -+++ b/lib/Crypto/Random/random.py -@@ -26,7 +26,7 @@ - - __all__ = ['StrongRandom', 'getrandbits', 'randrange', 'randint', 'choice', 'shuffle', 'sample'] - --from Crypto import Random -+from Cryptodome import Random - - class StrongRandom(object): - def __init__(self, rng=None, randfunc=None): -@@ -133,6 +133,6 @@ - sample = _r.sample - - # These are at the bottom to avoid problems with recursive imports --from Crypto.Util.number import ceil_div, bytes_to_long, long_to_bytes, size -+from Cryptodome.Util.number import ceil_div, bytes_to_long, long_to_bytes, size - - # vim:set ts=4 sw=4 sts=4 expandtab: ---- a/lib/Crypto/Signature/DSS.py -+++ b/lib/Crypto/Signature/DSS.py -@@ -63,15 +63,15 @@ - - __all__ = ['new', 'DssSigScheme'] - --from Crypto.Util.py3compat import bchr, b -+from Cryptodome.Util.py3compat import bchr, b - - --from Crypto.Util.asn1 import DerSequence --from Crypto.Util.number import long_to_bytes --from Crypto.Math.Numbers import Integer -+from Cryptodome.Util.asn1 import DerSequence -+from Cryptodome.Util.number import long_to_bytes -+from Cryptodome.Math.Numbers import Integer - --from Crypto.Hash import HMAC --from Crypto.PublicKey.ECC import _curve, EccKey -+from Cryptodome.Hash import HMAC -+from Cryptodome.PublicKey.ECC import _curve, EccKey - - - class DssSigScheme(object): ---- a/lib/Crypto/Signature/PKCS1_PSS.py -+++ b/lib/Crypto/Signature/PKCS1_PSS.py -@@ -36,7 +36,7 @@ - - import types - --from Crypto.Signature import pss -+from Cryptodome.Signature import pss - - - def _pycrypto_verify(self, hash_object, signature): ---- a/lib/Crypto/Signature/PKCS1_v1_5.py -+++ b/lib/Crypto/Signature/PKCS1_v1_5.py -@@ -36,7 +36,7 @@ - - import types - --from Crypto.Signature import pkcs1_15 -+from Cryptodome.Signature import pkcs1_15 - - def _pycrypto_verify(self, hash_object, signature): - try: ---- a/lib/Crypto/Signature/pkcs1_15.py -+++ b/lib/Crypto/Signature/pkcs1_15.py -@@ -64,11 +64,11 @@ - .. __: http://www.rsa.com/rsalabs/node.asp?id=2125 - """ - --from Crypto.Util.py3compat import b, bchr -+from Cryptodome.Util.py3compat import b, bchr - --import Crypto.Util.number --from Crypto.Util.number import ceil_div, bytes_to_long, long_to_bytes --from Crypto.Util.asn1 import DerSequence, DerNull, DerOctetString, DerObjectId -+import Cryptodome.Util.number -+from Cryptodome.Util.number import ceil_div, bytes_to_long, long_to_bytes -+from Cryptodome.Util.asn1 import DerSequence, DerNull, DerOctetString, DerObjectId - - class PKCS115_SigScheme: - """An instance of the PKCS#1 v1.5 signature scheme for a specific RSA key.""" -@@ -107,7 +107,7 @@ - """ - - # See 8.2.1 in RFC3447 -- modBits = Crypto.Util.number.size(self._key.n) -+ modBits = Cryptodome.Util.number.size(self._key.n) - k = ceil_div(modBits,8) # Convert from bits to bytes - - # Step 1 -@@ -141,7 +141,7 @@ - """ - - # See 8.2.2 in RFC3447 -- modBits = Crypto.Util.number.size(self._key.n) -+ modBits = Cryptodome.Util.number.size(self._key.n) - k = ceil_div(modBits, 8) # Convert from bits to bytes - - # Step 1 ---- a/lib/Crypto/Signature/pss.py -+++ b/lib/Crypto/Signature/pss.py -@@ -64,14 +64,14 @@ - .. __: http://www.rsa.com/rsalabs/node.asp?id=2125 - """ - --from Crypto.Util.py3compat import b, bchr, bord --import Crypto.Util.number --from Crypto.Util.number import (ceil_div, -+from Cryptodome.Util.py3compat import b, bchr, bord -+import Cryptodome.Util.number -+from Cryptodome.Util.number import (ceil_div, - long_to_bytes, - bytes_to_long - ) --from Crypto.Util.strxor import strxor --from Crypto import Random -+from Cryptodome.Util.strxor import strxor -+from Cryptodome import Random - - - class PSS_SigScheme: -@@ -139,7 +139,7 @@ - else: - mgf = self._mgfunc - -- modBits = Crypto.Util.number.size(self._key.n) -+ modBits = Cryptodome.Util.number.size(self._key.n) - - # See 8.1.1 in RFC3447 - k = ceil_div(modBits, 8) # k is length in bytes of the modulus -@@ -183,7 +183,7 @@ - else: - mgf = lambda x, y: MGF1(x, y, msg_hash) - -- modBits = Crypto.Util.number.size(self._key.n) -+ modBits = Cryptodome.Util.number.size(self._key.n) - - # See 8.1.2 in RFC3447 - k = ceil_div(modBits, 8) # Convert from bits to bytes ---- a/lib/Crypto/Util/Counter.py -+++ b/lib/Crypto/Util/Counter.py -@@ -54,7 +54,7 @@ - - """ - --from Crypto.Util.py3compat import * -+from Cryptodome.Util.py3compat import * - - def new(nbits, prefix=b(""), suffix=b(""), initial_value=1, little_endian=False, allow_wraparound=False): - """Create a stateful counter block function suitable for CTR encryption modes. ---- a/lib/Crypto/Util/Padding.py -+++ b/lib/Crypto/Util/Padding.py -@@ -39,7 +39,7 @@ - - __all__ = [ 'ValueError', 'pad', 'unpad' ] - --from Crypto.Util.py3compat import * -+from Cryptodome.Util.py3compat import * - - - def pad(data_to_pad, block_size, style='pkcs7'): ---- a/lib/Crypto/Util/RFC1751.py -+++ b/lib/Crypto/Util/RFC1751.py -@@ -28,7 +28,7 @@ - - - import binascii --from Crypto.Util.py3compat import * -+from Cryptodome.Util.py3compat import * - - binary={0:'0000', 1:'0001', 2:'0010', 3:'0011', 4:'0100', 5:'0101', - 6:'0110', 7:'0111', 8:'1000', 9:'1001', 10:'1010', 11:'1011', ---- a/lib/Crypto/Util/__init__.py -+++ b/lib/Crypto/Util/__init__.py -@@ -21,7 +21,7 @@ - """Miscellaneous modules - - Contains useful modules that don't belong into any of the --other Crypto.* subpackages. -+other Cryptodome.* subpackages. - - ======================== ============================================= - Module Description ---- a/lib/Crypto/Util/_file_system.py -+++ b/lib/Crypto/Util/_file_system.py -@@ -42,8 +42,8 @@ - The filename (inclusing extension) in the target directory. - """ - -- if dir_comps[0] != "Crypto": -- raise ValueError("Only available for modules under 'Crypto'") -+ if dir_comps[0] != "Cryptodome": -+ raise ValueError("Only available for modules under 'Cryptodome'") - - dir_comps = list(dir_comps[1:]) + [filename] - ---- a/lib/Crypto/Util/_raw_api.py -+++ b/lib/Crypto/Util/_raw_api.py -@@ -30,8 +30,8 @@ - - import imp - --from Crypto.Util.py3compat import byte_string --from Crypto.Util._file_system import pycryptodome_filename -+from Cryptodome.Util.py3compat import byte_string -+from Cryptodome.Util._file_system import pycryptodome_filename - - try: - from cffi import FFI ---- a/lib/Crypto/Util/asn1.py -+++ b/lib/Crypto/Util/asn1.py -@@ -28,9 +28,9 @@ - - """ - --from Crypto.Util.py3compat import byte_string, b, bchr, bord -+from Cryptodome.Util.py3compat import byte_string, b, bchr, bord - --from Crypto.Util.number import long_to_bytes, bytes_to_long -+from Cryptodome.Util.number import long_to_bytes, bytes_to_long - - __all__ = ['DerObject', 'DerInteger', 'DerOctetString', 'DerNull', - 'DerSequence', 'DerObjectId', 'DerBitString', 'DerSetOf'] ---- a/lib/Crypto/Util/number.py -+++ b/lib/Crypto/Util/number.py -@@ -27,10 +27,10 @@ - from warnings import warn as _warn - import math - import sys --from Crypto.Util.py3compat import * -+from Cryptodome.Util.py3compat import * - - try: -- from Crypto.PublicKey import _fastmath -+ from Cryptodome.PublicKey import _fastmath - except ImportError: - # For production, we are going to let import issues due to gmp/mpir shared - # libraries not loading slide silently and use slowmath. If you'd rather -@@ -443,8 +443,8 @@ - # This is called in a function instead of at the module level in order to - # avoid problems with recursive imports - global Random, StrongRandom -- from Crypto import Random -- from Crypto.Random.random import StrongRandom -+ from Cryptodome import Random -+ from Cryptodome.Random.random import StrongRandom - - - ---- a/lib/Crypto/Util/strxor.py -+++ b/lib/Crypto/Util/strxor.py -@@ -32,11 +32,11 @@ - Fast XOR of byte strings. - """ - --from Crypto.Util._raw_api import (load_pycryptodome_raw_lib, c_size_t, -+from Cryptodome.Util._raw_api import (load_pycryptodome_raw_lib, c_size_t, - create_string_buffer, get_raw_buffer, - expect_byte_string) - --_raw_strxor = load_pycryptodome_raw_lib("Crypto.Util._strxor", -+_raw_strxor = load_pycryptodome_raw_lib("Cryptodome.Util._strxor", - """ - void strxor(const uint8_t *in1, - const uint8_t *in2, ---- a/lib/Crypto/__init__.py -+++ b/lib/Crypto/__init__.py -@@ -25,19 +25,19 @@ - - Subpackages: - --Crypto.Cipher -+Cryptodome.Cipher - Secret-key (AES, TDES, Salsa20, ChaCha20, CAST, Blowfish, ARC4) and public-key encryption (RSA PKCS#1) algorithms --Crypto.Hash -+Cryptodome.Hash - Hashing algorithms (SHA-1, SHA-2, SHA-3, BLAKE2, HMAC, MD5) --Crypto.IO -+Cryptodome.IO - Encodings useful for cryptographic data (PEM, PKCS#8) --Crypto.Protocol -+Cryptodome.Protocol - Cryptographic protocols (key derivation functions, Shamir's Secret Sharing scheme) --Crypto.PublicKey -+Cryptodome.PublicKey - Public-key generation, import, export (RSA, DSA, ECC) --Crypto.Signature -+Cryptodome.Signature - Public-key signature algorithms (RSA PKCS#1, DSA, ECDSA) --Crypto.Util -+Cryptodome.Util - Various useful modules and functions (padding, ASN.1, XOR) - """ - --- a/src/cast5.c +++ b/src/cast5.c @@ -4,7 +4,7 @@