mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-10 15:44:32 +00:00
tool/compile_gatt: add fallback for PyCryptodome installed as replacement for PyCrypto
This commit is contained in:
parent
cf38a091e0
commit
ced5a857a4
@ -9,6 +9,8 @@
|
|||||||
|
|
||||||
# dependencies:
|
# dependencies:
|
||||||
# - pip3 install pycryptodomex
|
# - pip3 install pycryptodomex
|
||||||
|
# alternatively, the pycryptodome package can be used instead
|
||||||
|
# - pip3 install pycryptodome
|
||||||
|
|
||||||
import codecs
|
import codecs
|
||||||
import csv
|
import csv
|
||||||
@ -20,15 +22,20 @@ import sys
|
|||||||
import argparse
|
import argparse
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
# try to import Cryptodome
|
have_crypto = True
|
||||||
|
# try to import PyCryptodome independent from PyCrypto
|
||||||
try:
|
try:
|
||||||
from Cryptodome.Cipher import AES
|
from Cryptodome.Cipher import AES
|
||||||
from Cryptodome.Hash import CMAC
|
from Cryptodome.Hash import CMAC
|
||||||
have_crypto = True
|
except ImportError:
|
||||||
|
# fallback: try to import PyCryptodome as (an almost drop-in) replacement for the PyCrypto library
|
||||||
|
try:
|
||||||
|
from Crypto.Cipher import AES
|
||||||
|
from Crypto.Hash import CMAC
|
||||||
except ImportError:
|
except ImportError:
|
||||||
have_crypto = False
|
have_crypto = False
|
||||||
print("\n[!] PyCryptodome required to calculate GATT Database Hash but not installed (using random value instead)")
|
print("\n[!] PyCryptodome required to calculate GATT Database Hash but not installed (using random value instead)")
|
||||||
print("[!] Please install PyCryptodome, e.g. 'pip install pycryptodomex'\n")
|
print("[!] Please install PyCryptodome, e.g. 'pip install pycryptodomex' or 'pip install pycryptodome'\n")
|
||||||
|
|
||||||
header = '''
|
header = '''
|
||||||
// {0} generated from {1} for BTstack
|
// {0} generated from {1} for BTstack
|
||||||
|
Loading…
x
Reference in New Issue
Block a user