blob: 5e0b12df2e05c9064c50ba457d42704181226bc1 [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 Gaynor745c95c2013-10-16 14:41:35 -070033 [
34 "camellia-128-ecb.txt",
35 "camellia-192-ecb.txt",
36 "camellia-256-ecb.txt"
37 ],
Alex Gaynor1fe70b12013-10-16 11:59:17 -070038 lambda key: ciphers.Camellia(binascii.unhexlify((key))),
Alex Gaynorf55da9d2013-10-16 14:33:19 -070039 lambda key: modes.ECB(),
Paul Kehrer14c3a352013-10-22 21:45:16 -050040 only_if=lambda backend: backend.ciphers.supported(
Alex Gaynorb4008042013-10-16 18:49:26 -070041 ciphers.Camellia("\x00" * 16), modes.ECB()
42 ),
Alex Gaynor512dd692013-10-16 14:27:52 -070043 skip_message="Does not support Camellia ECB",
Paul Kehrerdff22d42013-09-27 13:43:06 -050044 )