aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/hazmat/primitives/test_x25519.py10
-rw-r--r--tests/hazmat/primitives/test_x448.py12
2 files changed, 21 insertions, 1 deletions
diff --git a/tests/hazmat/primitives/test_x25519.py b/tests/hazmat/primitives/test_x25519.py
index 682c3125..f412f2e8 100644
--- a/tests/hazmat/primitives/test_x25519.py
+++ b/tests/hazmat/primitives/test_x25519.py
@@ -32,6 +32,9 @@ def test_x25519_unsupported(backend):
X25519PublicKey.from_public_bytes(b"0" * 32)
with raises_unsupported_algorithm(_Reasons.UNSUPPORTED_EXCHANGE_ALGORITHM):
+ X25519PrivateKey.from_private_bytes(b"0" * 32)
+
+ with raises_unsupported_algorithm(_Reasons.UNSUPPORTED_EXCHANGE_ALGORITHM):
X25519PrivateKey.generate()
@@ -166,6 +169,13 @@ class TestX25519Exchange(object):
with pytest.raises(ValueError):
X25519PublicKey.from_public_bytes(b"a" * 33)
+ def test_invalid_length_from_private_bytes(self, backend):
+ with pytest.raises(ValueError):
+ X25519PrivateKey.from_private_bytes(b"a" * 31)
+
+ with pytest.raises(ValueError):
+ X25519PrivateKey.from_private_bytes(b"a" * 33)
+
def test_invalid_private_bytes(self, backend):
key = X25519PrivateKey.generate()
with pytest.raises(ValueError):
diff --git a/tests/hazmat/primitives/test_x448.py b/tests/hazmat/primitives/test_x448.py
index 51be0e10..817de76f 100644
--- a/tests/hazmat/primitives/test_x448.py
+++ b/tests/hazmat/primitives/test_x448.py
@@ -28,7 +28,10 @@ from ...utils import (
@pytest.mark.requires_backend_interface(interface=DHBackend)
def test_x448_unsupported(backend):
with raises_unsupported_algorithm(_Reasons.UNSUPPORTED_EXCHANGE_ALGORITHM):
- X448PublicKey.from_public_bytes(b"0" * 32)
+ X448PublicKey.from_public_bytes(b"0" * 56)
+
+ with raises_unsupported_algorithm(_Reasons.UNSUPPORTED_EXCHANGE_ALGORITHM):
+ X448PrivateKey.from_private_bytes(b"0" * 56)
with raises_unsupported_algorithm(_Reasons.UNSUPPORTED_EXCHANGE_ALGORITHM):
X448PrivateKey.generate()
@@ -176,6 +179,13 @@ class TestX448Exchange(object):
with pytest.raises(ValueError):
X448PublicKey.from_public_bytes(b"a" * 57)
+ def test_invalid_length_from_private_bytes(self, backend):
+ with pytest.raises(ValueError):
+ X448PrivateKey.from_private_bytes(b"a" * 55)
+
+ with pytest.raises(ValueError):
+ X448PrivateKey.from_private_bytes(b"a" * 57)
+
def test_invalid_private_bytes(self, backend):
key = X448PrivateKey.generate()
with pytest.raises(ValueError):