summaryrefslogtreecommitdiff
path: root/tests/hazmat/primitives
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2018-07-12 22:19:21 +0530
committerAlex Gaynor <alex.gaynor@gmail.com>2018-07-12 12:49:20 -0400
commit0fba4e28de2d0b5b8a262f512b65e487ded0c6e1 (patch)
treebe394af373887f0d616892263178c04aec789914 /tests/hazmat/primitives
parente74a263112847bf856c12128ce45f8d3ac2d116a (diff)
downloadcryptography-0fba4e28de2d0b5b8a262f512b65e487ded0c6e1.tar.gz
raise valueerror for null x25519 derived keys (#4332)
* raise valueerror for null x25519 derived keys OpenSSL errors when it hits this edge case and a null shared key is bad anyway so let's raise an error * empty commit
Diffstat (limited to 'tests/hazmat/primitives')
-rw-r--r--tests/hazmat/primitives/test_x25519.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/hazmat/primitives/test_x25519.py b/tests/hazmat/primitives/test_x25519.py
index 22a0ae66f..381be201a 100644
--- a/tests/hazmat/primitives/test_x25519.py
+++ b/tests/hazmat/primitives/test_x25519.py
@@ -76,6 +76,23 @@ class TestX25519Exchange(object):
assert computed_shared_key == shared_key
+ def test_null_shared_key_raises_error(self, backend):
+ """
+ The vector used here is taken from wycheproof's x25519 test vectors
+ """
+ public = binascii.unhexlify(
+ "5f9c95bca3508c24b1d0b1559c83ef5b04445cc4581c8e86d8224eddd09f1157"
+ )
+ private = binascii.unhexlify(
+ "78f1e8edf14481b389448dac8f59c70b038e7cf92ef2c7eff57a72466e115296"
+ )
+ private_key = X25519PrivateKey._from_private_bytes(
+ private
+ )
+ public_key = X25519PublicKey.from_public_bytes(public)
+ with pytest.raises(ValueError):
+ private_key.exchange(public_key)
+
# These vectors are also from RFC 7748
# https://tools.ietf.org/html/rfc7748#section-6.1
@pytest.mark.parametrize(