diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2014-03-17 20:50:03 -0700 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2014-03-17 20:50:03 -0700 |
commit | 38c42635490d24d7ee88041b52002156c6f5a676 (patch) | |
tree | 34606dbe780ec7704051f26b0f12ab8755fca812 /tests/hazmat/primitives/utils.py | |
parent | 0380374fdae7bd744e46ad526af721fae11aa475 (diff) | |
parent | a38e8e580c09cebcab528be7e806f63539498f94 (diff) | |
download | cryptography-38c42635490d24d7ee88041b52002156c6f5a676.tar.gz cryptography-38c42635490d24d7ee88041b52002156c6f5a676.tar.bz2 cryptography-38c42635490d24d7ee88041b52002156c6f5a676.zip |
Merge pull request #792 from reaperhulk/rsa-pss-verify
RSA PSS Verify
Diffstat (limited to 'tests/hazmat/primitives/utils.py')
-rw-r--r-- | tests/hazmat/primitives/utils.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/hazmat/primitives/utils.py b/tests/hazmat/primitives/utils.py index f0a00319..31491023 100644 --- a/tests/hazmat/primitives/utils.py +++ b/tests/hazmat/primitives/utils.py @@ -21,6 +21,7 @@ import itertools import pytest from cryptography.hazmat.primitives import hashes, hmac +from cryptography.hazmat.primitives.asymmetric import rsa, padding from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC from cryptography.hazmat.primitives.ciphers import Cipher from cryptography.hazmat.primitives.kdf.hkdf import HKDF @@ -373,3 +374,35 @@ def generate_hkdf_test(param_loader, path, file_names, algorithm): hkdf_test(backend, algorithm, params) return test_hkdf + + +def generate_rsa_pss_test(param_loader, path, file_names, hash_alg): + all_params = _load_all_params(path, file_names, param_loader) + all_params = [i for i in all_params + if i["algorithm"] == hash_alg.name.upper()] + + @pytest.mark.parametrize("params", all_params) + def test_rsa_pss(self, backend, params): + rsa_pss_test(backend, params, hash_alg) + + return test_rsa_pss + + +def rsa_pss_test(backend, params, hash_alg): + public_key = rsa.RSAPublicKey( + public_exponent=params["public_exponent"], + modulus=params["modulus"] + ) + verifier = public_key.verifier( + binascii.unhexlify(params["s"]), + padding.PSS( + mgf=padding.MGF1( + algorithm=hash_alg, + salt_length=params["salt_length"] + ) + ), + hash_alg, + backend + ) + verifier.update(binascii.unhexlify(params["msg"])) + verifier.verify() |