aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2024-01-25 13:09:27 -0800
committerGitHub <noreply@github.com>2024-01-25 21:09:27 +0000
commit3da3a3703bef1772b08bfc7da4b9221b5592f506 (patch)
treeb3da53e9ae5f2f7dcb4db090bf222e14ff7b7a8a /tests
parent08b24d87a64734ac7f5c575b309ad7d49c246353 (diff)
downloadpyca-cryptography-3da3a3703bef1772b08bfc7da4b9221b5592f506.zip
pyca-cryptography-3da3a3703bef1772b08bfc7da4b9221b5592f506.tar.gz
pyca-cryptography-3da3a3703bef1772b08bfc7da4b9221b5592f506.tar.bz2
support bytes-like consistently across our asym sign/verify APIs (#10260)
and update our docs to show it as well
Diffstat (limited to 'tests')
-rw-r--r--tests/hazmat/primitives/test_dsa.py8
-rw-r--r--tests/hazmat/primitives/test_ec.py9
-rw-r--r--tests/hazmat/primitives/test_ed25519.py6
-rw-r--r--tests/hazmat/primitives/test_ed448.py6
4 files changed, 29 insertions, 0 deletions
diff --git a/tests/hazmat/primitives/test_dsa.py b/tests/hazmat/primitives/test_dsa.py
index c3990cd..2928a1e 100644
--- a/tests/hazmat/primitives/test_dsa.py
+++ b/tests/hazmat/primitives/test_dsa.py
@@ -522,6 +522,14 @@ class TestDSASignature:
public_key = private_key.public_key()
public_key.verify(signature, message, algorithm)
+ def test_sign_verify_buffer(self, backend):
+ private_key = DSA_KEY_1024.private_key(backend)
+ message = bytearray(b"one little message")
+ algorithm = hashes.SHA1()
+ signature = private_key.sign(message, algorithm)
+ public_key = private_key.public_key()
+ public_key.verify(bytearray(signature), message, algorithm)
+
def test_prehashed_sign(self, backend):
private_key = DSA_KEY_1024.private_key(backend)
message = b"one little message"
diff --git a/tests/hazmat/primitives/test_ec.py b/tests/hazmat/primitives/test_ec.py
index d794d42..334e76d 100644
--- a/tests/hazmat/primitives/test_ec.py
+++ b/tests/hazmat/primitives/test_ec.py
@@ -516,6 +516,15 @@ class TestECDSAVectors:
public_key = private_key.public_key()
public_key.verify(signature, message, algorithm)
+ def test_sign_verify_buffers(self, backend):
+ _skip_curve_unsupported(backend, ec.SECP256R1())
+ message = bytearray(b"one little message")
+ algorithm = ec.ECDSA(hashes.SHA1())
+ private_key = ec.generate_private_key(ec.SECP256R1(), backend)
+ signature = private_key.sign(message, algorithm)
+ public_key = private_key.public_key()
+ public_key.verify(bytearray(signature), message, algorithm)
+
def test_sign_prehashed(self, backend):
_skip_curve_unsupported(backend, ec.SECP256R1())
message = b"one little message"
diff --git a/tests/hazmat/primitives/test_ed25519.py b/tests/hazmat/primitives/test_ed25519.py
index 8e6b33b..26f7d0c 100644
--- a/tests/hazmat/primitives/test_ed25519.py
+++ b/tests/hazmat/primitives/test_ed25519.py
@@ -117,6 +117,12 @@ class TestEd25519Signing:
with pytest.raises(InvalidSignature):
key.public_key().verify(b"0" * 64, b"test data")
+ def test_sign_verify_buffer(self, backend):
+ key = Ed25519PrivateKey.generate()
+ data = bytearray(b"test data")
+ signature = key.sign(data)
+ key.public_key().verify(bytearray(signature), data)
+
def test_generate(self, backend):
key = Ed25519PrivateKey.generate()
assert key
diff --git a/tests/hazmat/primitives/test_ed448.py b/tests/hazmat/primitives/test_ed448.py
index d363f38..6c7bded 100644
--- a/tests/hazmat/primitives/test_ed448.py
+++ b/tests/hazmat/primitives/test_ed448.py
@@ -86,6 +86,12 @@ class TestEd448Signing:
with pytest.raises(InvalidSignature):
key.public_key().verify(b"0" * 64, b"test data")
+ def test_sign_verify_buffer(self, backend):
+ key = Ed448PrivateKey.generate()
+ data = bytearray(b"test data")
+ signature = key.sign(data)
+ key.public_key().verify(bytearray(signature), data)
+
def test_generate(self, backend):
key = Ed448PrivateKey.generate()
assert key