diff --git a/.travis.yml b/.travis.yml index 3ddec02b..df0228f7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -147,6 +147,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/tlslite/utils/ecc.py b/tlslite/utils/ecc.py index 8b4c17f0..21550fc1 100644 --- a/tlslite/utils/ecc.py +++ b/tlslite/utils/ecc.py @@ -20,8 +20,13 @@ def decodeX962Point(data, curve=ecdsa.NIST256p): yCoord = bytesToNumber(parser.getFixBytes(bytelength)) if parser.getRemainingLength(): raise DecodeError("Invalid length of point encoding for curve") - return ecdsa.ellipticcurve.Point(curve.curve, xCoord, yCoord) - + if not xCoord or not yCoord: + raise DecodeError("Zero as key share from peer") + if not curve.curve.contains_point(xCoord, yCoord): + raise DecodeError("Key share from peer is not a valid point on curve") + # pylint: disable=c-extension-no-member + return ecdsa.ellipticcurve.PointJacobi(curve.curve, xCoord, yCoord, 1) + # pylint: enable=c-extension-no-member def encodeX962Point(point): """Encode a point in X9.62 format"""