aboutsummaryrefslogtreecommitdiffstats
path: root/tests/wycheproof
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2018-12-17 21:44:15 -0500
committerPaul Kehrer <paul.l.kehrer@gmail.com>2018-12-18 10:44:15 +0800
commitd13fd93ddde42c806929f334ae03c02b954aa64a (patch)
treebcb0f3642d6aaf092b6127e5355d0d338270543c /tests/wycheproof
parent7deaf5a8397b3c1fae5e6e3ffb788146f24c4af4 (diff)
downloadcryptography-d13fd93ddde42c806929f334ae03c02b954aa64a.tar.gz
cryptography-d13fd93ddde42c806929f334ae03c02b954aa64a.tar.bz2
cryptography-d13fd93ddde42c806929f334ae03c02b954aa64a.zip
Support compressed points in the wycheproof tests (#4648)
* Support compressed points in the wycheproof tests * Handle entries with no public key * Ok, let's try this
Diffstat (limited to 'tests/wycheproof')
-rw-r--r--tests/wycheproof/test_ecdh.py20
1 files changed, 5 insertions, 15 deletions
diff --git a/tests/wycheproof/test_ecdh.py b/tests/wycheproof/test_ecdh.py
index a0c3f0d9..5fcc45b7 100644
--- a/tests/wycheproof/test_ecdh.py
+++ b/tests/wycheproof/test_ecdh.py
@@ -97,28 +97,18 @@ def test_ecdh_ecpoint(backend, wycheproof):
private_key = ec.derive_private_key(
int(wycheproof.testcase["private"], 16), curve, backend
)
- # We don't support compressed points
- if (
- wycheproof.has_flag("CompressedPoint") or
- not wycheproof.testcase["public"]
- ):
+
+ if wycheproof.invalid:
with pytest.raises(ValueError):
- ec.EllipticCurvePublicNumbers.from_encoded_point(
+ ec.EllipticCurvePublicKey.from_encoded_point(
curve, binascii.unhexlify(wycheproof.testcase["public"])
)
return
- public_numbers = ec.EllipticCurvePublicNumbers.from_encoded_point(
+ assert wycheproof.valid or wycheproof.acceptable
+ public_key = ec.EllipticCurvePublicKey.from_encoded_point(
curve, binascii.unhexlify(wycheproof.testcase["public"])
)
- if wycheproof.testcase["comment"] == "point is not on curve":
- assert wycheproof.invalid
- with pytest.raises(ValueError):
- public_numbers.public_key(backend)
- return
-
- assert wycheproof.valid or wycheproof.acceptable
- public_key = public_numbers.public_key(backend)
computed_shared = private_key.exchange(ec.ECDH(), public_key)
expected_shared = binascii.unhexlify(wycheproof.testcase["shared"])
assert computed_shared == expected_shared