diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2014-04-23 12:37:59 -0700 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2014-04-23 12:37:59 -0700 |
commit | ff2b8cebe85c5326c52a0b4ffe467f99e5526849 (patch) | |
tree | 0aa12fbd439c44c9c9750e2babb3a7f5df5efa28 /tests/hazmat/backends/test_openssl.py | |
parent | e5a3ccfb8fdbbfd8b6f20a9fc720d88ce1e40b9b (diff) | |
parent | 50e6230014e298658c7776e0659223e664265c4a (diff) | |
download | cryptography-ff2b8cebe85c5326c52a0b4ffe467f99e5526849.tar.gz cryptography-ff2b8cebe85c5326c52a0b4ffe467f99e5526849.tar.bz2 cryptography-ff2b8cebe85c5326c52a0b4ffe467f99e5526849.zip |
Merge pull request #949 from reaperhulk/rsa-oaep-decrypt
OAEP support for RSA decryption
Diffstat (limited to 'tests/hazmat/backends/test_openssl.py')
-rw-r--r-- | tests/hazmat/backends/test_openssl.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/hazmat/backends/test_openssl.py b/tests/hazmat/backends/test_openssl.py index 98537360..58511666 100644 --- a/tests/hazmat/backends/test_openssl.py +++ b/tests/hazmat/backends/test_openssl.py @@ -293,6 +293,57 @@ class TestOpenSSLRSA(object): def test_unsupported_mgf1_hash_algorithm(self): assert backend.mgf1_hash_supported(DummyHash()) is False + def test_unsupported_mgf1_hash_algorithm_decrypt(self): + private_key = rsa.RSAPrivateKey.generate( + public_exponent=65537, + key_size=512, + backend=backend + ) + with raises_unsupported_algorithm(_Reasons.UNSUPPORTED_HASH): + private_key.decrypt( + b"ciphertext", + padding.OAEP( + mgf=padding.MGF1(algorithm=hashes.SHA256()), + algorithm=hashes.SHA1(), + label=None + ), + backend + ) + + def test_unsupported_oaep_hash_algorithm_decrypt(self): + private_key = rsa.RSAPrivateKey.generate( + public_exponent=65537, + key_size=512, + backend=backend + ) + with raises_unsupported_algorithm(_Reasons.UNSUPPORTED_HASH): + private_key.decrypt( + b"ciphertext", + padding.OAEP( + mgf=padding.MGF1(algorithm=hashes.SHA1()), + algorithm=hashes.SHA256(), + label=None + ), + backend + ) + + def test_unsupported_oaep_label_decrypt(self): + private_key = rsa.RSAPrivateKey.generate( + public_exponent=65537, + key_size=512, + backend=backend + ) + with pytest.raises(ValueError): + private_key.decrypt( + b"ciphertext", + padding.OAEP( + mgf=padding.MGF1(algorithm=hashes.SHA1()), + algorithm=hashes.SHA1(), + label=b"label" + ), + backend + ) + @pytest.mark.skipif( backend._lib.OPENSSL_VERSION_NUMBER <= 0x10001000, |