/ tests / aes.t
aes.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   => 'AES-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                                            'aes-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                                            'aes-ecb',
46                                            mk_key_from('key'),
47                                            mk_opts(-pad  => 'STRING')),
48              },
49          ],
50          vectors => [
51              {
52                  title => '128 bit key',
53                  key   => {
54                      key => "000102030405060708090a0b0c0d0e0f"
55                  },
56                  -pad  => 0,
57                  tests => [
58                      {
59                          input   => "00112233445566778899aabbccddeeff",
60                          output  => "69c4e0d86a7b0430d8cdb78070b4c55a",
61                      }
62                  ]
63              },
64              {
65                  title => '192 bit key (test vector from libtomcrypt)',
66                  key   => {
67                      key => "000102030405060708090a0b0c0d0e0f1011121314151617"
68                  },
69                  -pad  => 0,
70                  tests => [
71                      {
72                          input   => "00112233445566778899aabbccddeeff",
73                          output  => "dda97ca4864cdfe06eaf70a0ec0d7191",
74                      }
75                  ]
76              },
77              {
78                  title => '256 bit key (test vector from libtomcrypt)',
79                  key   => {
80                      key => "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"
81                  },
82                  -pad  => 0,
83                  tests => [
84                      {
85                          input   => "00112233445566778899aabbccddeeff",
86                          output  => "8ea2b7ca516745bfeafc49904b496089",
87                      }
88                  ]
89              }
90          ]
91      }
92  );