Skip to content

Commit 0b9c9d2

Browse files
authored
Merge pull request #422 from tlsfuzzer/pycryptodome-0.7
detect pycryptodome, don't use it [0.7]
2 parents 719628a + 7c45f4a commit 0b9c9d2

9 files changed

+63
-35
lines changed

.travis.yml

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
dist: trusty
2+
sudo: false
3+
cache: pip
14
language: python
25

36
# whitelist branches on which tests will be run
@@ -14,25 +17,25 @@ addons:
1417
- swig
1518
# needed for GMPY
1619
- libgmp-dev
20+
before_cache:
21+
- rm -f $HOME/.cache/pip/log/debug.log
1722

18-
python:
19-
- 2.6
20-
- 2.7
21-
- 3.2
22-
- 3.3
23-
- 3.4
24-
- 3.5
25-
- 3.6
26-
- 3.7-dev
27-
28-
env:
29-
- TACKPY=true
30-
- TACKPY=false
31-
32-
matrix:
33-
exclude:
34-
- env: TACKPY=true
23+
jobs:
3524
include:
25+
- python: 2.6
26+
env: TACKPY=false
27+
- python: 2.7
28+
env: TACKPY=false
29+
- python: 3.4
30+
env: TACKPY=false
31+
- python: 3.5
32+
env: TACKPY=false
33+
- python: 3.6
34+
env: TACKPY=false
35+
- python: 3.7
36+
dist: xenial
37+
sudo: true
38+
env: TACKPY=false
3639
- python: 2.7
3740
env: TACKPY=true
3841
- python: 3.4
@@ -45,6 +48,10 @@ matrix:
4548
env: M2CRYPTO=true
4649
- python: 3.6
4750
env: M2CRYPTO=true
51+
- python: 3.7
52+
dist: xenial
53+
sudo: true
54+
env: M2CRYPTO=true
4855
- python: 2.7
4956
env: PYCRYPTO=true
5057
- python: 3.4
@@ -53,8 +60,14 @@ matrix:
5360
env: PYCRYPTO=true
5461
- python: 3.6
5562
env: PYCRYPTO=true
56-
- python: 3.7-dev
63+
- python: 3.7
64+
dist: xenial
65+
sudo: true
5766
env: PYCRYPTO=true
67+
- python: 3.7
68+
dist: xenial
69+
sudo: true
70+
env: PYCRYPTODOME=true
5871
- python: 2.7
5972
env: GMPY=true
6073
- python: 3.4
@@ -71,7 +84,9 @@ matrix:
7184
env: M2CRYPTO=true PYCRYPTO=true GMPY=true
7285
- python: 3.6
7386
env: M2CRYPTO=true PYCRYPTO=true GMPY=true
74-
- python: 3.7-dev
87+
- python: 3.7
88+
dist: xenial
89+
sudo: true
7590
env: M2CRYPTO=true PYCRYPTO=true GMPY=true
7691

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

97114
install:
98115
- 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
99116
- if [[ $TACKPY == 'true' ]]; then travis_retry pip install tackpy; fi
100117
- if [[ $M2CRYPTO == 'true' ]]; then travis_retry pip install --pre m2crypto; fi
101118
- if [[ $PYCRYPTO == 'true' ]]; then travis_retry pip install pycrypto; fi
119+
- if [[ $PYCRYPTODOME == 'true' ]]; then travis_retry pip install pycryptodome; fi
102120
- if [[ $GMPY == 'true' ]]; then travis_retry pip install gmpy; fi
103121
- travis_retry pip install -r requirements.txt
122+
- if [[ $CC_COV == 'true' ]]; then ./cc-test-reporter before-build; fi
104123

105124
script:
106125
- |
@@ -140,7 +159,5 @@ script:
140159
done
141160
fi
142161
143-
sudo: false
144-
145162
after_success:
146-
- coveralls
163+
- travis_retry coveralls

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ Currently it is distributed under Gnu LGPLv2 license.
8484
Requirements:
8585

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

build-requirements-2.6.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ hypothesis<3
77
coveralls<1.3.0
88
pylint
99
diff_cover
10+
pycparser<2.19
11+
idna<2.8

build-requirements-2.7.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ coverage
33
hypothesis
44
coveralls
55
pylint
6-
diff_cover
6+
mock
7+
diff_cover<2.5.0
8+
pytest>=4.6.5

build-requirements-3.2.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ coverage<4
55
hypothesis<1.10
66
coveralls<1
77
pylint<2.0
8-
diff_cover
8+
diff_cover<2.5.0
9+
typed-ast<1.3.0
10+
inflect<4.0.0

build-requirements-3.3.txt

Lines changed: 0 additions & 6 deletions
This file was deleted.

build-requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ hypothesis
33
coveralls
44
pylint
55
diff_cover
6-
coveralls
6+
pytest>=4.6.5
7+
pluggy>=0.7

setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,18 @@
2323
package_data={
2424
'package1': ['LICENSE', 'README.md']},
2525
install_requires=['ecdsa'],
26+
python_requires=">=2.6, !=3.0.*, !=3.1.*, !=3.2.*",
2627
obsoletes=["tlslite"],
2728
classifiers=[
2829
'Development Status :: 4 - Beta',
2930
'Intended Audience :: Developers',
3031
'License :: OSI Approved :: GNU Lesser General Public License v2 (LGPLv2)',
3132
'Operating System :: OS Independent',
3233
'Programming Language :: Python',
34+
"Programming Language :: Python :: 2",
3335
'Programming Language :: Python :: 2.6',
3436
'Programming Language :: Python :: 2.7',
35-
'Programming Language :: Python :: 3.2',
36-
'Programming Language :: Python :: 3.3',
37+
"Programming Language :: Python :: 3",
3738
'Programming Language :: Python :: 3.4',
3839
'Programming Language :: Python :: 3.5',
3940
'Programming Language :: Python :: 3.6',

tlslite/utils/cryptomath.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,20 @@
4646
gmpyLoaded = False
4747

4848
#Try to load pycrypto
49+
# pylint: disable=invalid-name
4950
try:
5051
import Crypto.Cipher.AES
51-
pycryptoLoaded = True
52+
# check if we're not using pycryptodome
53+
try:
54+
# pycrypto defaults to ECB when just key is provided
55+
# pycryptodome requires specifying the mode of operation
56+
Crypto.Cipher.AES.AESCipher(b'2' * (128//8))
57+
pycryptoLoaded = True
58+
except AttributeError:
59+
pycryptoLoaded = False
5260
except ImportError:
5361
pycryptoLoaded = False
62+
# pylint: enable=invalid-name
5463

5564

5665
# **************************************************************************

0 commit comments

Comments
 (0)