Skip to content

Commit

Permalink
detect pycryptodome, don't use it
Browse files Browse the repository at this point in the history
fixes #198
  • Loading branch information
tomato42 committed May 25, 2020
1 parent d324e95 commit 9efbf72
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion tlslite/utils/cryptomath.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


# **************************************************************************
Expand Down

0 comments on commit 9efbf72

Please sign in to comment.