aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat/primitives/test_3des.py
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2014-01-01 08:11:13 -0800
committerAlex Gaynor <alex.gaynor@gmail.com>2014-01-01 08:11:13 -0800
commit2a160d6a159817dd9d08a84e77d102e328f9af4f (patch)
tree461b7c607367f243bb46996ec16ad7424e48d440 /tests/hazmat/primitives/test_3des.py
parent62aefffb1396190930074bf04c91459d1536bd0e (diff)
parent522487e5a7dd3004747da85c9f6c53fc5dc4de06 (diff)
downloadcryptography-2a160d6a159817dd9d08a84e77d102e328f9af4f.tar.gz
cryptography-2a160d6a159817dd9d08a84e77d102e328f9af4f.tar.bz2
cryptography-2a160d6a159817dd9d08a84e77d102e328f9af4f.zip
Merge branch 'master' into validate-iv
Conflicts: tests/hazmat/backends/test_openssl.py tests/hazmat/primitives/test_block.py
Diffstat (limited to 'tests/hazmat/primitives/test_3des.py')
-rw-r--r--tests/hazmat/primitives/test_3des.py53
1 files changed, 38 insertions, 15 deletions
diff --git a/tests/hazmat/primitives/test_3des.py b/tests/hazmat/primitives/test_3des.py
index 69ec9c9a..581c47eb 100644
--- a/tests/hazmat/primitives/test_3des.py
+++ b/tests/hazmat/primitives/test_3des.py
@@ -20,12 +20,21 @@ from __future__ import absolute_import, division, print_function
import binascii
import os
+import pytest
+
from cryptography.hazmat.primitives.ciphers import algorithms, modes
from .utils import generate_encrypt_test
from ...utils import load_nist_vectors
+@pytest.mark.supported(
+ only_if=lambda backend: backend.cipher_supported(
+ algorithms.TripleDES("\x00" * 8), modes.CBC("\x00" * 8)
+ ),
+ skip_message="Does not support TripleDES CBC",
+)
+@pytest.mark.cipher
class TestTripleDES_CBC(object):
test_KAT = generate_encrypt_test(
load_nist_vectors,
@@ -37,8 +46,8 @@ class TestTripleDES_CBC(object):
"TCBCvarkey.rsp",
"TCBCvartext.rsp",
],
- lambda keys, iv: algorithms.TripleDES(binascii.unhexlify(keys)),
- lambda keys, iv: modes.CBC(binascii.unhexlify(iv)),
+ lambda keys, **kwargs: algorithms.TripleDES(binascii.unhexlify(keys)),
+ lambda iv, **kwargs: modes.CBC(binascii.unhexlify(iv)),
)
test_MMT = generate_encrypt_test(
@@ -49,13 +58,20 @@ class TestTripleDES_CBC(object):
"TCBCMMT2.rsp",
"TCBCMMT3.rsp",
],
- lambda key1, key2, key3, iv: (
- algorithms.TripleDES(binascii.unhexlify(key1 + key2 + key3))
+ lambda key1, key2, key3, **kwargs: algorithms.TripleDES(
+ binascii.unhexlify(key1 + key2 + key3)
),
- lambda key1, key2, key3, iv: modes.CBC(binascii.unhexlify(iv)),
+ lambda iv, **kwargs: modes.CBC(binascii.unhexlify(iv)),
)
+@pytest.mark.supported(
+ only_if=lambda backend: backend.cipher_supported(
+ algorithms.TripleDES("\x00" * 8), modes.OFB("\x00" * 8)
+ ),
+ skip_message="Does not support TripleDES OFB",
+)
+@pytest.mark.cipher
class TestTripleDES_OFB(object):
test_KAT = generate_encrypt_test(
load_nist_vectors,
@@ -67,8 +83,8 @@ class TestTripleDES_OFB(object):
"TOFBvartext.rsp",
"TOFBinvperm.rsp",
],
- lambda keys, iv: algorithms.TripleDES(binascii.unhexlify(keys)),
- lambda keys, iv: modes.OFB(binascii.unhexlify(iv)),
+ lambda keys, **kwargs: algorithms.TripleDES(binascii.unhexlify(keys)),
+ lambda iv, **kwargs: modes.OFB(binascii.unhexlify(iv)),
)
test_MMT = generate_encrypt_test(
@@ -79,13 +95,20 @@ class TestTripleDES_OFB(object):
"TOFBMMT2.rsp",
"TOFBMMT3.rsp",
],
- lambda key1, key2, key3, iv: (
- algorithms.TripleDES(binascii.unhexlify(key1 + key2 + key3))
+ lambda key1, key2, key3, **kwargs: algorithms.TripleDES(
+ binascii.unhexlify(key1 + key2 + key3)
),
- lambda key1, key2, key3, iv: modes.OFB(binascii.unhexlify(iv)),
+ lambda iv, **kwargs: modes.OFB(binascii.unhexlify(iv)),
)
+@pytest.mark.supported(
+ only_if=lambda backend: backend.cipher_supported(
+ algorithms.TripleDES("\x00" * 8), modes.CFB("\x00" * 8)
+ ),
+ skip_message="Does not support TripleDES CFB",
+)
+@pytest.mark.cipher
class TestTripleDES_CFB(object):
test_KAT = generate_encrypt_test(
load_nist_vectors,
@@ -97,8 +120,8 @@ class TestTripleDES_CFB(object):
"TCFB64varkey.rsp",
"TCFB64vartext.rsp",
],
- lambda keys, iv: algorithms.TripleDES(binascii.unhexlify(keys)),
- lambda keys, iv: modes.CFB(binascii.unhexlify(iv)),
+ lambda keys, **kwargs: algorithms.TripleDES(binascii.unhexlify(keys)),
+ lambda iv, **kwargs: modes.CFB(binascii.unhexlify(iv)),
)
test_MMT = generate_encrypt_test(
@@ -109,8 +132,8 @@ class TestTripleDES_CFB(object):
"TCFB64MMT2.rsp",
"TCFB64MMT3.rsp",
],
- lambda key1, key2, key3, iv: (
- algorithms.TripleDES(binascii.unhexlify(key1 + key2 + key3))
+ lambda key1, key2, key3, **kwargs: algorithms.TripleDES(
+ binascii.unhexlify(key1 + key2 + key3)
),
- lambda key1, key2, key3, iv: modes.CFB(binascii.unhexlify(iv)),
+ lambda iv, **kwargs: modes.CFB(binascii.unhexlify(iv)),
)