diff --git a/.travis.yml b/.travis.yml index 72edf8a37..cbb554f0b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -116,6 +116,11 @@ before_install: - 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 + - pushd "$(mktemp -d)" + - git clone https://github.com/tomato42/python-ecdsa.git + - cd python-ecdsa + - python setup.py install + - popd 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 diff --git a/build-requirements-2.7.txt b/build-requirements-2.7.txt index 37007c166..c5a7e7d9d 100644 --- a/build-requirements-2.7.txt +++ b/build-requirements-2.7.txt @@ -3,5 +3,6 @@ coverage hypothesis coveralls pylint -diff_cover +mock +diff_cover<2.5.0 pytest>=4.6.5 diff --git a/build-requirements-3.3.txt b/build-requirements-3.3.txt index 5b216fdab..cd6a9ed40 100644 --- a/build-requirements-3.3.txt +++ b/build-requirements-3.3.txt @@ -1,7 +1,7 @@ enum34 -coverage +coverage<5.0 hypothesis<3.44 coveralls pylint -diff_cover +diff_cover<2.5.0 typed-ast<1.3.0 diff --git a/tlslite/keyexchange.py b/tlslite/keyexchange.py index d31b9df96..42ccc91f0 100644 --- a/tlslite/keyexchange.py +++ b/tlslite/keyexchange.py @@ -23,6 +23,7 @@ from .utils.x25519 import x25519, x448, X25519_G, X448_G, X25519_ORDER_SIZE, \ X448_ORDER_SIZE from .utils.compat import int_types +from .utils.codec import DecodeError class KeyExchange(object): @@ -907,7 +908,7 @@ def calc_shared_key(self, private, peer_share): try: ecdhYc = decodeX962Point(peer_share, curve) - except AssertionError: + except (AssertionError, DecodeError): raise TLSIllegalParameterException("Invalid ECC point") S = ecdhYc * private diff --git a/tlslite/utils/ecc.py b/tlslite/utils/ecc.py index 87d875a4b..522a64e97 100644 --- a/tlslite/utils/ecc.py +++ b/tlslite/utils/ecc.py @@ -16,7 +16,9 @@ def decodeX962Point(data, curve=ecdsa.NIST256p): bytelength = getPointByteSize(curve) xCoord = bytesToNumber(parser.getFixBytes(bytelength)) yCoord = bytesToNumber(parser.getFixBytes(bytelength)) - return ecdsa.ellipticcurve.Point(curve.curve, xCoord, yCoord) + assert xCoord and yCoord + assert curve.curve.contains_point(xCoord, yCoord) + return ecdsa.ellipticcurve.PointJacobi(curve.curve, xCoord, yCoord, 1) def encodeX962Point(point): """Encode a point in X9.62 format"""