diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2013-10-16 16:55:40 -0700 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2013-10-16 16:55:40 -0700 |
commit | e761f8b33519104605b14cf8a24e9f68bd23b624 (patch) | |
tree | 672968fa7c23790bc9f5c9cd3c779adce09fae8c /tests/primitives/test_openssl_vectors.py | |
parent | 62ebc7e212a92a13c3836de5d129cb93f40a128d (diff) | |
parent | 169dee88faa7c46b5551b89cf97a1b30c0a1c6ea (diff) | |
download | cryptography-e761f8b33519104605b14cf8a24e9f68bd23b624.tar.gz cryptography-e761f8b33519104605b14cf8a24e9f68bd23b624.tar.bz2 cryptography-e761f8b33519104605b14cf8a24e9f68bd23b624.zip |
Merge branch 'master' into triple-des
Also moved most of the tests to the new format except for one which doesn't yet
have an obvious translation
Conflicts:
cryptography/primitives/block/ciphers.py
tests/primitives/test_nist.py
Diffstat (limited to 'tests/primitives/test_openssl_vectors.py')
-rw-r--r-- | tests/primitives/test_openssl_vectors.py | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/tests/primitives/test_openssl_vectors.py b/tests/primitives/test_openssl_vectors.py new file mode 100644 index 00000000..6e32eca6 --- /dev/null +++ b/tests/primitives/test_openssl_vectors.py @@ -0,0 +1,61 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" +Test using the OpenSSL Test Vectors +""" + +from __future__ import absolute_import, division, print_function + +import binascii + +from cryptography.primitives.block import ciphers, modes + +from .utils import generate_encrypt_test +from ..utils import load_openssl_vectors_from_file + + +class TestCamelliaCBC(object): + test_OpenSSL = generate_encrypt_test( + load_openssl_vectors_from_file, + "Camellia", + ["camellia-cbc.txt"], + lambda key, iv: ciphers.Camellia(binascii.unhexlify(key)), + lambda key, iv: modes.CBC(binascii.unhexlify(iv)), + only_if=lambda api: api.supports_cipher("camellia-128-cbc"), + skip_message="Does not support Camellia CBC", + ) + + +class TestCamelliaOFB(object): + test_OpenSSL = generate_encrypt_test( + load_openssl_vectors_from_file, + "Camellia", + ["camellia-ofb.txt"], + lambda key, iv: ciphers.Camellia(binascii.unhexlify(key)), + lambda key, iv: modes.OFB(binascii.unhexlify(iv)), + only_if=lambda api: api.supports_cipher("camellia-128-ofb"), + skip_message="Does not support Camellia OFB", + ) + + +class TestCamelliaCFB(object): + test_OpenSSL = generate_encrypt_test( + load_openssl_vectors_from_file, + "Camellia", + ["camellia-cfb.txt"], + lambda key, iv: ciphers.Camellia(binascii.unhexlify(key)), + lambda key, iv: modes.CFB(binascii.unhexlify(iv)), + only_if=lambda api: api.supports_cipher("camellia-128-cfb"), + skip_message="Does not support Camellia CFB", + ) |