Paul Kehrer | dff22d4 | 2013-09-27 13:43:06 -0500 | [diff] [blame] | 1 | # 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 Gaynor | 1fe70b1 | 2013-10-16 11:59:17 -0700 | [diff] [blame^] | 15 | Tests using the CRYPTREC (Camellia) Test Vectors |
Paul Kehrer | dff22d4 | 2013-09-27 13:43:06 -0500 | [diff] [blame] | 16 | """ |
| 17 | |
| 18 | from __future__ import absolute_import, division, print_function |
| 19 | |
| 20 | import binascii |
Paul Kehrer | dff22d4 | 2013-09-27 13:43:06 -0500 | [diff] [blame] | 21 | |
Alex Gaynor | 1fe70b1 | 2013-10-16 11:59:17 -0700 | [diff] [blame^] | 22 | from cryptography.primitives.block import ciphers, modes |
Paul Kehrer | dff22d4 | 2013-09-27 13:43:06 -0500 | [diff] [blame] | 23 | |
Alex Gaynor | 1fe70b1 | 2013-10-16 11:59:17 -0700 | [diff] [blame^] | 24 | from .utils import generate_encrypt_test |
Paul Kehrer | dff22d4 | 2013-09-27 13:43:06 -0500 | [diff] [blame] | 25 | from ..utils import load_cryptrec_vectors_from_file |
| 26 | |
Paul Kehrer | dff22d4 | 2013-09-27 13:43:06 -0500 | [diff] [blame] | 27 | |
Paul Kehrer | dff22d4 | 2013-09-27 13:43:06 -0500 | [diff] [blame] | 28 | class TestCamelliaECB(object): |
Alex Gaynor | 1fe70b1 | 2013-10-16 11:59:17 -0700 | [diff] [blame^] | 29 | test_NTT = generate_encrypt_test( |
| 30 | load_cryptrec_vectors_from_file, |
| 31 | "Camellia", |
| 32 | "NTT", |
| 33 | ["camellia-128-ecb", "camellia-192-ecb", "camellia-256"], |
| 34 | lambda key: ciphers.Camellia(binascii.unhexlify((key))), |
| 35 | lambda key: modes.EBC(), |
| 36 | only_if=lambda api: api.supports_cipher("camellia-128-ecb") |
Paul Kehrer | dff22d4 | 2013-09-27 13:43:06 -0500 | [diff] [blame] | 37 | ) |