Skip to content

Commit fdf2196

Browse files
committed
use PointJacobi for ECDH
this is a crude way to use the new features in python-ecdsa, will need to be reworked later (to use ECDH object)
1 parent 2b1e0ed commit fdf2196

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

tlslite/keyexchange.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from .utils.x25519 import x25519, x448, X25519_G, X448_G, X25519_ORDER_SIZE, \
2424
X448_ORDER_SIZE
2525
from .utils.compat import int_types
26+
from .utils.codec import DecodeError
2627

2728

2829
class KeyExchange(object):
@@ -907,7 +908,7 @@ def calc_shared_key(self, private, peer_share):
907908
try:
908909
ecdhYc = decodeX962Point(peer_share,
909910
curve)
910-
except AssertionError:
911+
except (AssertionError, DecodeError):
911912
raise TLSIllegalParameterException("Invalid ECC point")
912913

913914
S = ecdhYc * private

tlslite/utils/ecc.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ def decodeX962Point(data, curve=ecdsa.NIST256p):
1616
bytelength = getPointByteSize(curve)
1717
xCoord = bytesToNumber(parser.getFixBytes(bytelength))
1818
yCoord = bytesToNumber(parser.getFixBytes(bytelength))
19-
return ecdsa.ellipticcurve.Point(curve.curve, xCoord, yCoord)
19+
assert xCoord and yCoord
20+
assert curve.curve.contains_point(xCoord, yCoord)
21+
return ecdsa.ellipticcurve.PointJacobi(curve.curve, xCoord, yCoord, 1)
2022

2123
def encodeX962Point(point):
2224
"""Encode a point in X9.62 format"""

0 commit comments

Comments
 (0)