From d5269a325dd7ec82d8ee84f48e1c49deca33f9c5 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 4d5ef91be..7451d39ec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -70,6 +70,10 @@ matrix: 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.4 @@ -122,6 +126,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 # **************************************************************************