/ tests / camellia.t
camellia.t
 1  #! /usr/bin/env perl
 2  
 3  # Licensed under the Apache License, Version 2.0 (the "License");
 4  # you may not use this file except in compliance with the License.
 5  # See the NOTICE file distributed with this work for additional
 6  # information regarding copyright ownership.
 7  # You may obtain a copy of the License at
 8  #
 9  #     http://www.apache.org/licenses/LICENSE-2.0
10  #
11  # Unless required by applicable law or agreed to in writing, software
12  # distributed under the License is distributed on an "AS IS" BASIS,
13  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  # See the License for the specific language governing permissions and
15  # limitations under the License.
16  
17  use strict;
18  use warnings;
19  
20  use FindBin;
21  use lib "$FindBin::Bin";
22  use driver;
23  use cmd_helpers;
24  
25  runtests(
26      {
27          title => 'Camellia-ECB with test vector from libtomcrypt',
28          cases   => [
29              encrypt     => {
30                  input           => 'input',
31                  output          => 'output',
32                  auxilliary      => 'key',
33                  cmd             => mk_cmd('lesec-tool', 'enc',
34                                            '-plugin ltc',
35                                            'camellia-ecb',
36                                            mk_key_from('key'),
37                                            mk_opts(-pad  => 'STRING')),
38              },
39              decrypt     => {
40                  input           => 'output',
41                  output          => 'input',
42                  auxilliary      => 'key',
43                  cmd             => mk_cmd('lesec-tool', 'dec',
44                                            '-plugin ltc',
45                                            'camellia-ecb',
46                                            mk_key_from('key'),
47                                            mk_opts(-pad  => 'STRING')),
48              },
49          ],
50          vectors => [
51              {
52                  title => '128 bit key',
53                  key => { key => "0123456789abcdeffedcba9876543210" },
54                  -pad  => 0,
55                  tests => [
56                      {
57                          input   => "0123456789abcdeffedcba9876543210",
58                          output  => "67673138549669730857065648eabe43"
59                      },
60                  ]
61              },
62              {
63                  title => '192 bit key',
64                  key => { key => "0123456789abcdeffedcba98765432100011223344556677" },
65                  -pad  => 0,
66                  tests => [
67                      {
68                          input   => "0123456789abcdeffedcba9876543210",
69                          output  => "b4993401b3e996f84ee5cee7d79b09b9"
70                      },
71                  ]
72              },
73              {
74                  title => '256 bit key 1',
75                  key => { key => "0123456789abcdeffedcba987654321000112233445566778899aabbccddeeff" },
76                  -pad  => 0,
77                  tests => [
78                      {
79                          input   => "0123456789abcdeffedcba9876543210",
80                          output  => "9acc237dff16d76c20ef7c919e3a7509"
81                      },
82                  ]
83              },
84              {
85                  title => '256 bit key 2',
86                  key => { key => "603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4" },
87                  -pad  => 0,
88                  tests => [
89                      {
90                          INPUT   => "F69F2445DF4F9B17AD2B417BE66C3710",
91                          OUTPUT  => "7960109FB6DC42947FCFE59EA3C5EB6B"
92                      },
93                  ]
94              }
95          ]
96      }
97  );