/ tests / poly1305mac.t
poly1305mac.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  my $m1 = unpack('H*', "Cryptographic Forum Research Group");
26  runtests(
27      {
28          title => 'Poly1305 MAC with test vectors from RFC 7539, section 2.4.2',
29          cases   => [
30              mac         => {
31                  input           => 'input',
32                  output          => 'output',
33                  auxilliary      => 'key',
34                  cmd             => mk_cmd('lesec-tool', 'mac',
35                                            '-plugin ltc',
36                                            'poly1305',
37                                            mk_key_from('key'),
38                                            mk_opts(-outlen => 'STRING')),
39              },
40          ],
41          vectors => [
42              {
43                  key     => { key => '85d6be7857556d337f4452fe42d506a80103808afb0db2fd4abff6af4149f51b' },
44                  tests => [
45                      {
46                          input   => $m1,
47                          output  => "A8061DC1305136C6C22B8BAF0C0127A9",
48                      }
49                  ]
50              }
51          ]
52      }
53  );