/ tests / kseed.t
kseed.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 => 'SEED-ECB with test vector from libtomcrypt (128-bit key)',
28          cases   => [
29              encrypt     => {
30                  input           => 'input',
31                  output          => 'output',
32                  auxilliary      => 'key',
33                  cmd             => mk_cmd('lesec-tool', 'enc',
34                                            '-plugin ltc',
35                                            'seed-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                                            'seed-ecb',
46                                            mk_key_from('key'),
47                                            mk_opts(-pad  => 'STRING')),
48              },
49          ],
50          vectors => [
51              {
52                  key   => { key => "00000000000000000000000000000000" },
53                  -pad  => 0,
54                  tests => [
55                      {
56                          input   => "000102030405060708090A0B0C0D0E0F",
57                          output  => "5EBAC6E0054E166819AFF1CC6D346CDB"
58                      },
59                  ]
60              },
61              {
62                  key   => { key => "000102030405060708090A0B0C0D0E0F" },
63                  -pad  => 0,
64                  tests => [
65                      {
66                          input   => "00000000000000000000000000000000",
67                          output  => "C11F22F20140505084483597E4370F43"
68                      },
69                  ]
70              },
71              {
72                  key   => { key => "4706480851E61BE85D74BFB3FD956185" },
73                  -pad  => 0,
74                  tests => [
75                      {
76                          input   => "83A2F8A288641FB9A4E9A5CC2F131C7D",
77                          output  => "EE54D13EBCAE706D226BC3142CD40D4A"
78                      },
79                  ]
80              },
81              {
82                  key   => { key => "28DBC3BC49FFD87DCFA509B11D422BE7" },
83                  -pad  => 0,
84                  tests => [
85                      {
86                          input   => "B41E6BE2EBA84A148E2EED84593C5EC7",
87                          output  => "9B9B7BFCD1813CB95D0B3618F40F5122"
88                      },
89                  ]
90              }
91          ]
92      }
93  );