Skip to content

Commit

Permalink
Merge pull request #422 from tlsfuzzer/pycryptodome-0.7
Browse files Browse the repository at this point in the history
detect pycryptodome, don't use it [0.7]
  • Loading branch information
tomato42 committed Nov 20, 2020
2 parents 719628a + 7c45f4a commit 0b9c9d2
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 35 deletions.
61 changes: 39 additions & 22 deletions .travis.yml
@@ -1,3 +1,6 @@
dist: trusty
sudo: false
cache: pip
language: python

# whitelist branches on which tests will be run
Expand All @@ -14,25 +17,25 @@ addons:
- swig
# needed for GMPY
- libgmp-dev
before_cache:
- rm -f $HOME/.cache/pip/log/debug.log

python:
- 2.6
- 2.7
- 3.2
- 3.3
- 3.4
- 3.5
- 3.6
- 3.7-dev

env:
- TACKPY=true
- TACKPY=false

matrix:
exclude:
- env: TACKPY=true
jobs:
include:
- python: 2.6
env: TACKPY=false
- python: 2.7
env: TACKPY=false
- python: 3.4
env: TACKPY=false
- python: 3.5
env: TACKPY=false
- python: 3.6
env: TACKPY=false
- python: 3.7
dist: xenial
sudo: true
env: TACKPY=false
- python: 2.7
env: TACKPY=true
- python: 3.4
Expand All @@ -45,6 +48,10 @@ matrix:
env: M2CRYPTO=true
- python: 3.6
env: M2CRYPTO=true
- python: 3.7
dist: xenial
sudo: true
env: M2CRYPTO=true
- python: 2.7
env: PYCRYPTO=true
- python: 3.4
Expand All @@ -53,8 +60,14 @@ matrix:
env: PYCRYPTO=true
- python: 3.6
env: PYCRYPTO=true
- python: 3.7-dev
- python: 3.7
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
Expand All @@ -71,7 +84,9 @@ matrix:
env: M2CRYPTO=true PYCRYPTO=true GMPY=true
- python: 3.6
env: M2CRYPTO=true PYCRYPTO=true GMPY=true
- python: 3.7-dev
- python: 3.7
dist: xenial
sudo: true
env: M2CRYPTO=true PYCRYPTO=true GMPY=true

before_install:
Expand All @@ -93,14 +108,18 @@ before_install:
- git rev-parse HEAD
- echo "TRAVIS_COMMIT_RANGE=$TRAVIS_COMMIT_RANGE"
- git fetch origin master:refs/remotes/origin/master
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter

install:
- if [[ -e build-requirements-${TRAVIS_PYTHON_VERSION}.txt ]]; then travis_retry pip install -r build-requirements-${TRAVIS_PYTHON_VERSION}.txt; else travis_retry pip install -r build-requirements.txt; fi
- 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

script:
- |
Expand Down Expand Up @@ -140,7 +159,5 @@ script:
done
fi
sudo: false

after_success:
- coveralls
- travis_retry coveralls
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -84,7 +84,7 @@ Currently it is distributed under Gnu LGPLv2 license.
Requirements:

* Python 2.6 or higher is required.
* Python 3.2 or higher is supported.
* Python 3.3 or higher is supported.
* python ecdsa library ([GitHub](https://github.com/warner/python-ecdsa),
[PyPI](https://pypi.python.org/pypi/ecdsa))

Expand Down
2 changes: 2 additions & 0 deletions build-requirements-2.6.txt
Expand Up @@ -7,3 +7,5 @@ hypothesis<3
coveralls<1.3.0
pylint
diff_cover
pycparser<2.19
idna<2.8
4 changes: 3 additions & 1 deletion build-requirements-2.7.txt
Expand Up @@ -3,4 +3,6 @@ coverage
hypothesis
coveralls
pylint
diff_cover
mock
diff_cover<2.5.0
pytest>=4.6.5
4 changes: 3 additions & 1 deletion build-requirements-3.2.txt
Expand Up @@ -5,4 +5,6 @@ coverage<4
hypothesis<1.10
coveralls<1
pylint<2.0
diff_cover
diff_cover<2.5.0
typed-ast<1.3.0
inflect<4.0.0
6 changes: 0 additions & 6 deletions build-requirements-3.3.txt

This file was deleted.

3 changes: 2 additions & 1 deletion build-requirements.txt
Expand Up @@ -3,4 +3,5 @@ hypothesis
coveralls
pylint
diff_cover
coveralls
pytest>=4.6.5
pluggy>=0.7
5 changes: 3 additions & 2 deletions setup.py
Expand Up @@ -23,17 +23,18 @@
package_data={
'package1': ['LICENSE', 'README.md']},
install_requires=['ecdsa'],
python_requires=">=2.6, !=3.0.*, !=3.1.*, !=3.2.*",
obsoletes=["tlslite"],
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'License :: OSI Approved :: GNU Lesser General Public License v2 (LGPLv2)',
'Operating System :: OS Independent',
'Programming Language :: Python',
"Programming Language :: Python :: 2",
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
"Programming Language :: Python :: 3",
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
Expand Down
11 changes: 10 additions & 1 deletion tlslite/utils/cryptomath.py
Expand Up @@ -46,11 +46,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 0b9c9d2

Please sign in to comment.