From 9efbf724330f96bd6fa265784742d45b8d039c72 Mon Sep 17 00:00:00 2001 From: Hubert Kario Date: Mon, 25 May 2020 17:09:37 +0200 Subject: [PATCH] detect pycryptodome, don't use it fixes #198 --- .travis.yml | 5 +++++ tlslite/utils/cryptomath.py | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 450880413..c4f718460 100644 --- a/.travis.yml +++ b/.travis.yml @@ -76,6 +76,10 @@ jobs: # dist: xenial # sudo: true # env: PYCRYPTO=true + - python: 3.7 + dist: xenial + sudo: true + env: PYCRYPTODOME=true - python: 2.7 env: GMPY=true - python: 3.5 @@ -132,6 +136,7 @@ install: - if [[ $TACKPY == 'true' ]]; then travis_retry pip install tackpy; fi - if [[ $M2CRYPTO == 'true' ]]; then travis_retry pip install --pre m2crypto; fi - if [[ $PYCRYPTO == 'true' ]]; then travis_retry pip install pycrypto; fi + - if [[ $PYCRYPTODOME == 'true' ]]; then travis_retry pip install pycryptodome; fi - if [[ $GMPY == 'true' ]]; then travis_retry pip install gmpy; fi - travis_retry pip install -r requirements.txt - if [[ $CC_COV == 'true' ]]; then ./cc-test-reporter before-build; fi diff --git a/tlslite/utils/cryptomath.py b/tlslite/utils/cryptomath.py index f47c89dd7..024f18087 100644 --- a/tlslite/utils/cryptomath.py +++ b/tlslite/utils/cryptomath.py @@ -50,11 +50,18 @@ gmpyLoaded = False #Try to load pycrypto +# pylint: disable=invalid-name try: import Crypto.Cipher.AES - pycryptoLoaded = True + # check if we're not using pycryptodome + try: + Crypto.Cipher.AES.AESCipher(b'2' * (128//8)) + pycryptoLoaded = True + except AttributeError: + pycryptoLoaded = False except ImportError: pycryptoLoaded = False +# pylint: enable=invalid-name # **************************************************************************