diff options
author | Colleen Murphy <cmurphy@users.noreply.github.com> | 2016-06-04 09:09:08 -0700 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2016-06-04 09:09:08 -0700 |
commit | 34d5c39a9c1efa6c2f2c9f473890ebe44816e85a (patch) | |
tree | 8009a882571352fbd33ad05ff82c841eb4a0ff2e /tests/hazmat/primitives/test_rsa.py | |
parent | 4f125c122499e21050e46f20a18bbc4848b0f43b (diff) | |
download | cryptography-34d5c39a9c1efa6c2f2c9f473890ebe44816e85a.tar.gz cryptography-34d5c39a9c1efa6c2f2c9f473890ebe44816e85a.tar.bz2 cryptography-34d5c39a9c1efa6c2f2c9f473890ebe44816e85a.zip |
Add convenience methods to sign and verify w/ RSA (#2945)
This patch adds wrapper methods to allow the user to sign and verify a
single message block without having to go through the multi-step
process of creating a signer or verifier, updating it with the one
message, and finalizing the result. This will make signing and
verifying data more user-friendly when only using small messages.
Partial bug #1529
Diffstat (limited to 'tests/hazmat/primitives/test_rsa.py')
-rw-r--r-- | tests/hazmat/primitives/test_rsa.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/hazmat/primitives/test_rsa.py b/tests/hazmat/primitives/test_rsa.py index c94e0df9..9f3008e3 100644 --- a/tests/hazmat/primitives/test_rsa.py +++ b/tests/hazmat/primitives/test_rsa.py @@ -481,6 +481,17 @@ class TestRSASignature(object): signer.update(b"no failure") signer.finalize() + def test_sign(self, backend): + private_key = RSA_KEY_512.private_key(backend) + message = b"one little message" + pkcs = padding.PKCS1v15() + algorithm = hashes.SHA1() + signature = private_key.sign(message, pkcs, algorithm) + public_key = private_key.public_key() + verifier = public_key.verifier(signature, pkcs, algorithm) + verifier.update(message) + verifier.verify() + @pytest.mark.requires_backend_interface(interface=RSABackend) class TestRSAVerification(object): @@ -836,6 +847,17 @@ class TestRSAVerification(object): with pytest.raises(InvalidSignature): verifier.verify() + def test_verify(self, backend): + private_key = RSA_KEY_512.private_key(backend) + message = b"one little message" + pkcs = padding.PKCS1v15() + algorithm = hashes.SHA1() + signer = private_key.signer(pkcs, algorithm) + signer.update(message) + signature = signer.finalize() + public_key = private_key.public_key() + public_key.verify(signature, message, pkcs, algorithm) + @pytest.mark.requires_backend_interface(interface=RSABackend) class TestRSAPSSMGF1Verification(object): |