blob: 4d16ce03354d86c09eed43ccd8e5b0112e5c3506 [file] [log] [blame]
Paul Kehrerdff22d42013-09-27 13:43:06 -05001# Licensed under the Apache License, Version 2.0 (the "License");
2# you may not use this file except in compliance with the License.
3# You may obtain a copy of the License at
4#
5# http://www.apache.org/licenses/LICENSE-2.0
6#
7# Unless required by applicable law or agreed to in writing, software
8# distributed under the License is distributed on an "AS IS" BASIS,
9# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
10# implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14"""
Alex Gaynor1fe70b12013-10-16 11:59:17 -070015Tests using the CRYPTREC (Camellia) Test Vectors
Paul Kehrerdff22d42013-09-27 13:43:06 -050016"""
17
18from __future__ import absolute_import, division, print_function
19
20import binascii
Alex Gaynor016eed12013-10-16 14:16:04 -070021import os
Paul Kehrerdff22d42013-09-27 13:43:06 -050022
Alex Gaynor1fe70b12013-10-16 11:59:17 -070023from cryptography.primitives.block import ciphers, modes
Paul Kehrerdff22d42013-09-27 13:43:06 -050024
Alex Gaynor1fe70b12013-10-16 11:59:17 -070025from .utils import generate_encrypt_test
Paul Kehrerdff22d42013-09-27 13:43:06 -050026from ..utils import load_cryptrec_vectors_from_file
27
Paul Kehrerdff22d42013-09-27 13:43:06 -050028
Paul Kehrerdff22d42013-09-27 13:43:06 -050029class TestCamelliaECB(object):
Alex Gaynor1fe70b12013-10-16 11:59:17 -070030 test_NTT = generate_encrypt_test(
31 load_cryptrec_vectors_from_file,
Alex Gaynor016eed12013-10-16 14:16:04 -070032 os.path.join("Camellia", "NTT"),
Alex Gaynor512dd692013-10-16 14:27:52 -070033 ["camellia-128-ecb.txt", "camellia-192-ecb.txt", "camellia-256-ecb.txt"],
Alex Gaynor1fe70b12013-10-16 11:59:17 -070034 lambda key: ciphers.Camellia(binascii.unhexlify((key))),
35 lambda key: modes.EBC(),
Alex Gaynor512dd692013-10-16 14:27:52 -070036 only_if=lambda api: api.supports_cipher("camellia-128-ecb"),
37 skip_message="Does not support Camellia ECB",
Paul Kehrerdff22d42013-09-27 13:43:06 -050038 )