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 26, 2020
1 parent d324e95 commit e92ba72
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .travis.yml
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
11 changes: 10 additions & 1 deletion tlslite/utils/cryptomath.py
Expand Up @@ -50,11 +50,20 @@
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:
# pycrypto defaults to ECB when just key is provided
# pycryptodome requires specifying the mode of operation
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 e92ba72

Please sign in to comment.