aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat/primitives/test_aead.py
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2017-07-09 07:34:58 -0500
committerAlex Gaynor <alex.gaynor@gmail.com>2017-07-09 08:34:58 -0400
commit9d5fc3e5dbe581e1fea9303e684ec9248936df55 (patch)
tree6a769a585ba9c2c5e121bb55c169dba17a814c77 /tests/hazmat/primitives/test_aead.py
parent0c9aed91697c5bc1eb16c2254406149e2395fdae (diff)
downloadcryptography-9d5fc3e5dbe581e1fea9303e684ec9248936df55.tar.gz
cryptography-9d5fc3e5dbe581e1fea9303e684ec9248936df55.tar.bz2
cryptography-9d5fc3e5dbe581e1fea9303e684ec9248936df55.zip
use an instance in aead_cipher_supported (#3772)
* use an instance in aead_cipher_supported * test for chacha20poly1305 compatibility via init exception * pep8
Diffstat (limited to 'tests/hazmat/primitives/test_aead.py')
-rw-r--r--tests/hazmat/primitives/test_aead.py24
1 files changed, 15 insertions, 9 deletions
diff --git a/tests/hazmat/primitives/test_aead.py b/tests/hazmat/primitives/test_aead.py
index bf1e8208..a1ca5ae7 100644
--- a/tests/hazmat/primitives/test_aead.py
+++ b/tests/hazmat/primitives/test_aead.py
@@ -9,7 +9,7 @@ import os
import pytest
-from cryptography.exceptions import InvalidTag, _Reasons
+from cryptography.exceptions import InvalidTag, UnsupportedAlgorithm, _Reasons
from cryptography.hazmat.backends.interfaces import CipherBackend
from cryptography.hazmat.primitives.ciphers.aead import ChaCha20Poly1305
@@ -18,11 +18,17 @@ from ...utils import (
)
-@pytest.mark.supported(
- only_if=lambda backend: (
- not backend.aead_cipher_supported(ChaCha20Poly1305)
- ),
- skip_message="Requires OpenSSL without ChaCha20Poly1305 support"
+def _chacha20poly1305_supported():
+ try:
+ ChaCha20Poly1305(b"0" * 32)
+ return True
+ except UnsupportedAlgorithm:
+ return False
+
+
+@pytest.mark.skipif(
+ _chacha20poly1305_supported(),
+ reason="Requires OpenSSL without ChaCha20Poly1305 support"
)
@pytest.mark.requires_backend_interface(interface=CipherBackend)
def test_chacha20poly1305_unsupported_on_older_openssl(backend):
@@ -30,9 +36,9 @@ def test_chacha20poly1305_unsupported_on_older_openssl(backend):
ChaCha20Poly1305(ChaCha20Poly1305.generate_key())
-@pytest.mark.supported(
- only_if=lambda backend: backend.aead_cipher_supported(ChaCha20Poly1305),
- skip_message="Does not support ChaCha20Poly1305"
+@pytest.mark.skipif(
+ not _chacha20poly1305_supported(),
+ reason="Does not support ChaCha20Poly1305"
)
@pytest.mark.requires_backend_interface(interface=CipherBackend)
class TestChaCha20Poly1305(object):