/ tests / sha3.t
sha3.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 $empty = '';
 26  my $a3_200_times = "a3" x 200;
 27  runtests(
 28      {
 29          title => 'Sha3-224 with test vectors from libtomcrypt',
 30          cases => [
 31              hash => {
 32                  input   => 'input',
 33                  output  => 'output',
 34                  cmd     => mk_cmd('lesec-tool', 'digest',
 35                                    '-plugin' => 'ltc',
 36                                    'sha3-224')
 37              }
 38          ],
 39          vectors => [
 40              {
 41                  tests => [
 42                      {
 43                          input   => $empty,
 44                          output  => "6b4e03423667dbb73b6e15454f0eb1abd4597f9a1b078e3f5b5a6bc7",
 45                      },
 46                      {
 47                          input   => $a3_200_times,
 48                          output  => "9376816aba503f72f96ce7eb65ac095deee3be4bf9bbc2a1cb7e11e0",
 49                      },
 50                  ]
 51              }
 52          ]
 53      },
 54      {
 55          title => 'Sha3-256 with test vectors from libtomcrypt',
 56          cases => [
 57              hash => {
 58                  input   => 'input',
 59                  output  => 'output',
 60                  cmd     => mk_cmd('lesec-tool', 'digest',
 61                                    '-plugin' => 'ltc',
 62                                    'sha3-256')
 63              }
 64          ],
 65          vectors => [
 66              {
 67                  tests => [
 68                      {
 69                          input   => $empty,
 70                          output  => "a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a",
 71                      },
 72                      {
 73                          input   => $a3_200_times,
 74                          output  => "79f38adec5c20307a98ef76e8324afbfd46cfd81b22e3973c65fa1bd9de31787",
 75                      },
 76                      {
 77                          input   => 'b771d5cef5d1a41a93d15643d7181d2a2ef0a8e84d91812f20ed21f147bef732bf3a60ef4067c3734b85bc8cd471780f10dc9e8291b58339a677b960218f71e793f2797aea349406512829065d37bb55ea796fa4f56fd8896b49b2cd19b43215ad967c712b24e5032d065232e02c127409d2ed4146b9d75d763d52db98d949d3b0fed6a8052fbb',
 78                          output  => "a19eee92bb2097b64e823d597798aa18be9b7c736b8059abfd6779ac35ac81b5",
 79                      },
 80                  ]
 81              }
 82          ]
 83      },
 84      {
 85          title => 'Sha3-384 with test vectors from libtomcrypt',
 86          cases => [
 87              hash => {
 88                  input   => 'input',
 89                  output  => 'output',
 90                  cmd     => mk_cmd('lesec-tool', 'digest',
 91                                    '-plugin' => 'ltc',
 92                                    'sha3-384')
 93              }
 94          ],
 95          vectors => [
 96              {
 97                  tests => [
 98                      {
 99                          input   => $a3_200_times,
100                          output  => "1881de2ca7e41ef95dc4732b8f5f002b189cc1e42b74168ed1732649ce1dbcdd76197a31fd55ee989f2d7050dd473e8f",
101                      }
102                  ]
103              }
104          ]
105      },
106      {
107          title => 'Sha3-512 with test vectors from libtomcrypt',
108          cases => [
109              hash => {
110                  input   => 'input',
111                  output  => 'output',
112                  cmd     => mk_cmd('lesec-tool', 'digest',
113                                    '-plugin' => 'ltc',
114                                    'sha3-512')
115              }
116          ],
117          vectors => [
118              {
119                  tests => [
120                      {
121                          input   => $a3_200_times,
122                          output  => "e76dfad22084a8b1467fcf2ffa58361bec7628edf5f3fdc0e4805dc48caeeca81b7c13c30adf52a3659584739a2df46be589c51ca1a4a8416df6545a1ce8ba00",
123                      },
124                  ]
125              }
126          ]
127      },
128  );