diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2016-01-10 15:23:40 -0600 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2016-01-10 15:23:40 -0600 |
commit | ed2d4b184a9acb5de1fa25aaacf4a71d7e23f82e (patch) | |
tree | b7db119e1276a32f9336baade3d19368144f4cc4 /tests/hazmat/primitives/test_rsa.py | |
parent | 3f6f8f593e0bd9910d406ec56bfeceba5a2badbf (diff) | |
parent | 41777171d35c2935e5d690cd51edf3ad89803bad (diff) | |
download | cryptography-ed2d4b184a9acb5de1fa25aaacf4a71d7e23f82e.tar.gz cryptography-ed2d4b184a9acb5de1fa25aaacf4a71d7e23f82e.tar.bz2 cryptography-ed2d4b184a9acb5de1fa25aaacf4a71d7e23f82e.zip |
Merge pull request #2661 from alex/coverage
Write some tests for skip conditions in tests.
Diffstat (limited to 'tests/hazmat/primitives/test_rsa.py')
-rw-r--r-- | tests/hazmat/primitives/test_rsa.py | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/tests/hazmat/primitives/test_rsa.py b/tests/hazmat/primitives/test_rsa.py index b6213d6d..c432db82 100644 --- a/tests/hazmat/primitives/test_rsa.py +++ b/tests/hazmat/primitives/test_rsa.py @@ -53,6 +53,13 @@ class DummyKeyEncryption(object): pass +@utils.register_interface(hashes.HashAlgorithm) +class DummyHashAlgorithm(object): + name = "dummy-hash" + digest_size = 32 + block_size = 64 + + def _flatten_pkcs1_examples(vectors): flattened_vectors = [] for vector in vectors: @@ -64,6 +71,24 @@ def _flatten_pkcs1_examples(vectors): return flattened_vectors +def _skip_pss_hash_algorithm_unsupported(backend, hash_alg): + if not backend.rsa_padding_supported( + padding.PSS( + mgf=padding.MGF1(hash_alg), + salt_length=padding.PSS.MAX_LENGTH + ) + ): + pytest.skip( + "Does not support {0} in MGF1 using PSS.".format(hash_alg.name) + ) + + +@pytest.mark.requires_backend_interface(interface=RSABackend) +def test_skip_pss_hash_algorithm_unsupported(backend): + with pytest.raises(pytest.skip.Exception): + _skip_pss_hash_algorithm_unsupported(backend, DummyHashAlgorithm()) + + def test_modular_inverse(): p = int( "d1f9f6c09fd3d38987f7970247b85a6da84907753d42ec52bc23b745093f4fff5cff3" @@ -268,15 +293,7 @@ class TestRSASignature(object): [hashes.SHA224(), hashes.SHA256(), hashes.SHA384(), hashes.SHA512()] ) def test_pss_signing_sha2(self, hash_alg, backend): - if not backend.rsa_padding_supported( - padding.PSS( - mgf=padding.MGF1(hash_alg), - salt_length=padding.PSS.MAX_LENGTH - ) - ): - pytest.skip( - "Does not support {0} in MGF1 using PSS.".format(hash_alg.name) - ) + _skip_pss_hash_algorithm_unsupported(backend, hash_alg) private_key = RSA_KEY_768.private_key(backend) public_key = private_key.public_key() pss = padding.PSS( |