File: fips198.t

package info (click to toggle)
perl 5.32.1-4%2Bdeb11u3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 113,408 kB
  • sloc: ansic: 641,443; perl: 491,650; sh: 70,967; pascal: 8,354; cpp: 4,103; xml: 2,428; makefile: 2,237; yacc: 1,173; lisp: 1
file content (28 lines) | stat: -rw-r--r-- 700 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use strict;
use Digest::SHA qw(hmac_sha1_hex);

my @data = map { "Sample #$_" } (1 .. 4);

my @out = (
	"4f4ca3d5d68ba7cc0a1208c9c61e9c5da0403c0a",
	"0922d3405faa3d194f82a45830737d5cc6c75d24",
	"bcf41eab8bb2d802f3d05caf7cb092ecf8d1a3aa",
	"9ea886efe268dbecce420c7524df32e0751a2a26"
);

my @keys = ("", "", "", "");

for (0x00 .. 0x00+63) { $keys[0] .= chr($_) }
for (0x30 .. 0x30+19) { $keys[1] .= chr($_) }
for (0x50 .. 0x50+99) { $keys[2] .= chr($_) }
for (0x70 .. 0x70+48) { $keys[3] .= chr($_) }

my $numtests = scalar @data;
print "1..$numtests\n";

my $testnum = 1;
while (@data) {
	print "not " unless hmac_sha1_hex(shift @data, shift @keys)
		eq shift @out;
	print "ok ", $testnum++, "\n";
}