Skip to content

Commit

Permalink
use PointJacobi for ECDH
Browse files Browse the repository at this point in the history
this is a crude way to use the new features in python-ecdsa,
will need to be reworked later (to use ECDH object)
  • Loading branch information
tomato42 committed Dec 11, 2019
1 parent 2b1e0ed commit fdf2196
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion tlslite/keyexchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion tlslite/utils/ecc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down

0 comments on commit fdf2196

Please sign in to comment.