Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Faster ECDH #372

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions tlslite/utils/ecc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down