Codebase list libcryptx-perl / 93d84be
SHA3 Karel Miko 6 years ago
15 changed file(s) with 1771 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
322322 if(register_hash(&sha512_desc)==-1) { croak("FATAL: cannot register_hash sha512"); }
323323 if(register_hash(&sha512_224_desc)==-1) { croak("FATAL: cannot register_hash sha512_224"); }
324324 if(register_hash(&sha512_256_desc)==-1) { croak("FATAL: cannot register_hash sha512_256"); }
325 if(register_hash(&sha3_224_desc)==-1) { croak("FATAL: cannot register_hash sha3_224"); }
326 if(register_hash(&sha3_256_desc)==-1) { croak("FATAL: cannot register_hash sha3_256"); }
327 if(register_hash(&sha3_384_desc)==-1) { croak("FATAL: cannot register_hash sha3_384"); }
328 if(register_hash(&sha3_512_desc)==-1) { croak("FATAL: cannot register_hash sha3_512"); }
325329 if(register_hash(&tiger_desc)==-1) { croak("FATAL: cannot register_hash tiger"); }
326330 if(register_hash(&whirlpool_desc)==-1) { croak("FATAL: cannot register_hash whirlpool"); }
327331 /* --- */
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.001';
6 our $VERSION = '[%(pmver || "0.000")%]';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( [%lc_name%] [%lc_name%]_hex [%lc_name%]_b64 [%lc_name%]_b64u [%lc_name%]_file [%lc_name%]_file_hex [%lc_name%]_file_b64 [%lc_name%]_file_b64u )] );
3737 SHA512 => { ltc=>'sha512', info=>'Hash function SHA-512 [size: 512 bits]', urls=>['http://en.wikipedia.org/wiki/SHA-2'] },
3838 SHA512_224 => { ltc=>'sha512_224',info=>'Hash function SHA-512/224 [size: 224 bits]', urls=>['http://en.wikipedia.org/wiki/SHA-2'] },
3939 SHA512_256 => { ltc=>'sha512_256',info=>'Hash function SHA-512/256 [size: 256 bits]', urls=>['http://en.wikipedia.org/wiki/SHA-2'] },
40 SHA3_224 => { ltc=>'sha3_224', info=>'Hash function SHA3-224 [size: 224 bits]', urls=>['http://en.wikipedia.org/wiki/SHA-3'] },
41 SHA3_256 => { ltc=>'sha3_256', info=>'Hash function SHA3-256 [size: 256 bits]', urls=>['http://en.wikipedia.org/wiki/SHA-3'] },
42 SHA3_384 => { ltc=>'sha3_384', info=>'Hash function SHA3-384 [size: 384 bits]', urls=>['http://en.wikipedia.org/wiki/SHA-3'] },
43 SHA3_512 => { ltc=>'sha3_512', info=>'Hash function SHA3-512 [size: 512 bits]', urls=>['http://en.wikipedia.org/wiki/SHA-3'] },
4044 Tiger192 => { ltc=>'tiger', info=>'Hash function Tiger-192 [size: 192 bits]', urls=>['http://en.wikipedia.org/wiki/Tiger_(cryptography)'] },
4145 Whirlpool => { ltc=>'whirlpool', info=>'Hash function Whirlpool [size: 512 bits]', urls=>['http://en.wikipedia.org/wiki/Whirlpool_(cryptography)'] },
4246 );
4549 my @test_files = bsd_glob("$FindBin::Bin/../t/data/*.file");
4650 @test_files = map { abs2rel(canonpath($_), canonpath("$FindBin::Bin/../")) } @test_files;
4751
48 for my $n (keys %list) {
52 my ($pmver) = grep { /^our\s+\$VERSION/ } read_file("$FindBin::Bin/../lib/Crypt/Digest.pm");
53 $pmver =~ s/our\s+\$VERSION\s*=\s*'(.*?)'.*$/$1/s;
54
55 for my $n (sort keys %list) {
4956 warn "Processing digest: '$n'\n";
5057
5158 my $data = {
5259 comment => "### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!",
60 pmver => $pmver,
5361 orig_name => $n,
5462 uc_name => uc($n),
5563 lc_name => lc($n),
6068 };
6169
6270 if ($outdir_t) {
63 require Crypt::Digest;
64 Crypt::Digest::import(':all');
71 eval "use Crypt::Digest ':all';"; die $@ if $@;
72 #require Crypt::Digest;
73 #Crypt::Digest::import(':all');
6574 for (@test_strings) {
66 push @{$data->{t_strings}}, { data=>pp($_),
75 my $d = pp($_);
76 $d = "\"$d\"" if $d =~ /^\d*$/; # 123 >>> "123"
77 push @{$data->{t_strings}}, { data=>$d,
6778 hex=>Crypt::Digest::digest_data_hex($n, $_),
6879 base64=>Crypt::Digest::digest_data_b64($n, $_),
6980 base64url=>Crypt::Digest::digest_data_b64u($n, $_),
0 package Crypt::Digest::SHA3_224;
1
2 ### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
3
4 use strict;
5 use warnings;
6 our $VERSION = '0.047';
7
8 use base qw(Crypt::Digest Exporter);
9 our %EXPORT_TAGS = ( all => [qw( sha3_224 sha3_224_hex sha3_224_b64 sha3_224_b64u sha3_224_file sha3_224_file_hex sha3_224_file_b64 sha3_224_file_b64u )] );
10 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
11 our @EXPORT = qw();
12
13 use Carp;
14 $Carp::Internal{(__PACKAGE__)}++;
15 use CryptX;
16
17 sub hashsize { Crypt::Digest::hashsize(__PACKAGE__) }
18
19 sub sha3_224 { Crypt::Digest::digest_data(__PACKAGE__, @_) }
20 sub sha3_224_hex { Crypt::Digest::digest_data_hex(__PACKAGE__, @_) }
21 sub sha3_224_b64 { Crypt::Digest::digest_data_b64(__PACKAGE__, @_) }
22 sub sha3_224_b64u { Crypt::Digest::digest_data_b64u(__PACKAGE__, @_) }
23
24 sub sha3_224_file { Crypt::Digest::digest_file(__PACKAGE__, @_) }
25 sub sha3_224_file_hex { Crypt::Digest::digest_file_hex(__PACKAGE__, @_) }
26 sub sha3_224_file_b64 { Crypt::Digest::digest_file_b64(__PACKAGE__, @_) }
27 sub sha3_224_file_b64u { Crypt::Digest::digest_file_b64u(__PACKAGE__, @_) }
28
29 1;
30
31 =pod
32
33 =head1 NAME
34
35 Crypt::Digest::SHA3_224 - Hash function SHA3-224 [size: 224 bits]
36
37 =head1 SYNOPSIS
38
39 ### Functional interface:
40 use Crypt::Digest::SHA3_224 qw( sha3_224 sha3_224_hex sha3_224_b64 sha3_224_b64u
41 sha3_224_file sha3_224_file_hex sha3_224_file_b64 sha3_224_file_b64u );
42
43 # calculate digest from string/buffer
44 $sha3_224_raw = sha3_224('data string');
45 $sha3_224_hex = sha3_224_hex('data string');
46 $sha3_224_b64 = sha3_224_b64('data string');
47 $sha3_224_b64u = sha3_224_b64u('data string');
48 # calculate digest from file
49 $sha3_224_raw = sha3_224_file('filename.dat');
50 $sha3_224_hex = sha3_224_file_hex('filename.dat');
51 $sha3_224_b64 = sha3_224_file_b64('filename.dat');
52 $sha3_224_b64u = sha3_224_file_b64u('filename.dat');
53 # calculate digest from filehandle
54 $sha3_224_raw = sha3_224_file(*FILEHANDLE);
55 $sha3_224_hex = sha3_224_file_hex(*FILEHANDLE);
56 $sha3_224_b64 = sha3_224_file_b64(*FILEHANDLE);
57 $sha3_224_b64u = sha3_224_file_b64u(*FILEHANDLE);
58
59 ### OO interface:
60 use Crypt::Digest::SHA3_224;
61
62 $d = Crypt::Digest::SHA3_224->new;
63 $d->add('any data');
64 $d->addfile('filename.dat');
65 $d->addfile(*FILEHANDLE);
66 $result_raw = $d->digest; # raw bytes
67 $result_hex = $d->hexdigest; # hexadecimal form
68 $result_b64 = $d->b64digest; # Base64 form
69 $result_b64u = $d->b64udigest; # Base64 URL Safe form
70
71 =head1 DESCRIPTION
72
73 Provides an interface to the SHA3_224 digest algorithm.
74
75 =head1 EXPORT
76
77 Nothing is exported by default.
78
79 You can export selected functions:
80
81 use Crypt::Digest::SHA3_224 qw(sha3_224 sha3_224_hex sha3_224_b64 sha3_224_b64u
82 sha3_224_file sha3_224_file_hex sha3_224_file_b64 sha3_224_file_b64u);
83
84 Or all of them at once:
85
86 use Crypt::Digest::SHA3_224 ':all';
87
88 =head1 FUNCTIONS
89
90 =head2 sha3_224
91
92 Logically joins all arguments into a single string, and returns its SHA3_224 digest encoded as a binary string.
93
94 $sha3_224_raw = sha3_224('data string');
95 #or
96 $sha3_224_raw = sha3_224('any data', 'more data', 'even more data');
97
98 =head2 sha3_224_hex
99
100 Logically joins all arguments into a single string, and returns its SHA3_224 digest encoded as a hexadecimal string.
101
102 $sha3_224_hex = sha3_224_hex('data string');
103 #or
104 $sha3_224_hex = sha3_224_hex('any data', 'more data', 'even more data');
105
106 =head2 sha3_224_b64
107
108 Logically joins all arguments into a single string, and returns its SHA3_224 digest encoded as a Base64 string, B<with> trailing '=' padding.
109
110 $sha3_224_b64 = sha3_224_b64('data string');
111 #or
112 $sha3_224_b64 = sha3_224_b64('any data', 'more data', 'even more data');
113
114 =head2 sha3_224_b64u
115
116 Logically joins all arguments into a single string, and returns its SHA3_224 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
117
118 $sha3_224_b64url = sha3_224_b64u('data string');
119 #or
120 $sha3_224_b64url = sha3_224_b64u('any data', 'more data', 'even more data');
121
122 =head2 sha3_224_file
123
124 Reads file (defined by filename or filehandle) content, and returns its SHA3_224 digest encoded as a binary string.
125
126 $sha3_224_raw = sha3_224_file('filename.dat');
127 #or
128 $sha3_224_raw = sha3_224_file(*FILEHANDLE);
129
130 =head2 sha3_224_file_hex
131
132 Reads file (defined by filename or filehandle) content, and returns its SHA3_224 digest encoded as a hexadecimal string.
133
134 $sha3_224_hex = sha3_224_file_hex('filename.dat');
135 #or
136 $sha3_224_hex = sha3_224_file_hex(*FILEHANDLE);
137
138 B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
139
140 =head2 sha3_224_file_b64
141
142 Reads file (defined by filename or filehandle) content, and returns its SHA3_224 digest encoded as a Base64 string, B<with> trailing '=' padding.
143
144 $sha3_224_b64 = sha3_224_file_b64('filename.dat');
145 #or
146 $sha3_224_b64 = sha3_224_file_b64(*FILEHANDLE);
147
148 =head2 sha3_224_file_b64u
149
150 Reads file (defined by filename or filehandle) content, and returns its SHA3_224 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
151
152 $sha3_224_b64url = sha3_224_file_b64u('filename.dat');
153 #or
154 $sha3_224_b64url = sha3_224_file_b64u(*FILEHANDLE);
155
156 =head1 METHODS
157
158 The OO interface provides the same set of functions as L<Crypt::Digest>.
159
160 =head2 new
161
162 $d = Crypt::Digest::SHA3_224->new();
163
164 =head2 clone
165
166 $d->clone();
167
168 =head2 reset
169
170 $d->reset();
171
172 =head2 add
173
174 $d->add('any data');
175 #or
176 $d->add('any data', 'more data', 'even more data');
177
178 =head2 addfile
179
180 $d->addfile('filename.dat');
181 #or
182 $d->addfile(*FILEHANDLE);
183
184 =head2 add_bits
185
186 $d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
187 #or
188 $d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
189
190 =head2 hashsize
191
192 $d->hashsize;
193 #or
194 Crypt::Digest::SHA3_224->hashsize();
195 #or
196 Crypt::Digest::SHA3_224::hashsize();
197
198 =head2 digest
199
200 $result_raw = $d->digest();
201
202 =head2 hexdigest
203
204 $result_hex = $d->hexdigest();
205
206 =head2 b64digest
207
208 $result_b64 = $d->b64digest();
209
210 =head2 b64udigest
211
212 $result_b64url = $d->b64udigest();
213
214 =head1 SEE ALSO
215
216 =over
217
218 =item * L<CryptX|CryptX>, L<Crypt::Digest|Crypt::Digest>
219
220 =item * L<http://en.wikipedia.org/wiki/SHA-3|http://en.wikipedia.org/wiki/SHA-3>
221
222 =back
223
224 =cut
225
226 __END__
0 package Crypt::Digest::SHA3_256;
1
2 ### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
3
4 use strict;
5 use warnings;
6 our $VERSION = '0.047';
7
8 use base qw(Crypt::Digest Exporter);
9 our %EXPORT_TAGS = ( all => [qw( sha3_256 sha3_256_hex sha3_256_b64 sha3_256_b64u sha3_256_file sha3_256_file_hex sha3_256_file_b64 sha3_256_file_b64u )] );
10 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
11 our @EXPORT = qw();
12
13 use Carp;
14 $Carp::Internal{(__PACKAGE__)}++;
15 use CryptX;
16
17 sub hashsize { Crypt::Digest::hashsize(__PACKAGE__) }
18
19 sub sha3_256 { Crypt::Digest::digest_data(__PACKAGE__, @_) }
20 sub sha3_256_hex { Crypt::Digest::digest_data_hex(__PACKAGE__, @_) }
21 sub sha3_256_b64 { Crypt::Digest::digest_data_b64(__PACKAGE__, @_) }
22 sub sha3_256_b64u { Crypt::Digest::digest_data_b64u(__PACKAGE__, @_) }
23
24 sub sha3_256_file { Crypt::Digest::digest_file(__PACKAGE__, @_) }
25 sub sha3_256_file_hex { Crypt::Digest::digest_file_hex(__PACKAGE__, @_) }
26 sub sha3_256_file_b64 { Crypt::Digest::digest_file_b64(__PACKAGE__, @_) }
27 sub sha3_256_file_b64u { Crypt::Digest::digest_file_b64u(__PACKAGE__, @_) }
28
29 1;
30
31 =pod
32
33 =head1 NAME
34
35 Crypt::Digest::SHA3_256 - Hash function SHA3-256 [size: 256 bits]
36
37 =head1 SYNOPSIS
38
39 ### Functional interface:
40 use Crypt::Digest::SHA3_256 qw( sha3_256 sha3_256_hex sha3_256_b64 sha3_256_b64u
41 sha3_256_file sha3_256_file_hex sha3_256_file_b64 sha3_256_file_b64u );
42
43 # calculate digest from string/buffer
44 $sha3_256_raw = sha3_256('data string');
45 $sha3_256_hex = sha3_256_hex('data string');
46 $sha3_256_b64 = sha3_256_b64('data string');
47 $sha3_256_b64u = sha3_256_b64u('data string');
48 # calculate digest from file
49 $sha3_256_raw = sha3_256_file('filename.dat');
50 $sha3_256_hex = sha3_256_file_hex('filename.dat');
51 $sha3_256_b64 = sha3_256_file_b64('filename.dat');
52 $sha3_256_b64u = sha3_256_file_b64u('filename.dat');
53 # calculate digest from filehandle
54 $sha3_256_raw = sha3_256_file(*FILEHANDLE);
55 $sha3_256_hex = sha3_256_file_hex(*FILEHANDLE);
56 $sha3_256_b64 = sha3_256_file_b64(*FILEHANDLE);
57 $sha3_256_b64u = sha3_256_file_b64u(*FILEHANDLE);
58
59 ### OO interface:
60 use Crypt::Digest::SHA3_256;
61
62 $d = Crypt::Digest::SHA3_256->new;
63 $d->add('any data');
64 $d->addfile('filename.dat');
65 $d->addfile(*FILEHANDLE);
66 $result_raw = $d->digest; # raw bytes
67 $result_hex = $d->hexdigest; # hexadecimal form
68 $result_b64 = $d->b64digest; # Base64 form
69 $result_b64u = $d->b64udigest; # Base64 URL Safe form
70
71 =head1 DESCRIPTION
72
73 Provides an interface to the SHA3_256 digest algorithm.
74
75 =head1 EXPORT
76
77 Nothing is exported by default.
78
79 You can export selected functions:
80
81 use Crypt::Digest::SHA3_256 qw(sha3_256 sha3_256_hex sha3_256_b64 sha3_256_b64u
82 sha3_256_file sha3_256_file_hex sha3_256_file_b64 sha3_256_file_b64u);
83
84 Or all of them at once:
85
86 use Crypt::Digest::SHA3_256 ':all';
87
88 =head1 FUNCTIONS
89
90 =head2 sha3_256
91
92 Logically joins all arguments into a single string, and returns its SHA3_256 digest encoded as a binary string.
93
94 $sha3_256_raw = sha3_256('data string');
95 #or
96 $sha3_256_raw = sha3_256('any data', 'more data', 'even more data');
97
98 =head2 sha3_256_hex
99
100 Logically joins all arguments into a single string, and returns its SHA3_256 digest encoded as a hexadecimal string.
101
102 $sha3_256_hex = sha3_256_hex('data string');
103 #or
104 $sha3_256_hex = sha3_256_hex('any data', 'more data', 'even more data');
105
106 =head2 sha3_256_b64
107
108 Logically joins all arguments into a single string, and returns its SHA3_256 digest encoded as a Base64 string, B<with> trailing '=' padding.
109
110 $sha3_256_b64 = sha3_256_b64('data string');
111 #or
112 $sha3_256_b64 = sha3_256_b64('any data', 'more data', 'even more data');
113
114 =head2 sha3_256_b64u
115
116 Logically joins all arguments into a single string, and returns its SHA3_256 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
117
118 $sha3_256_b64url = sha3_256_b64u('data string');
119 #or
120 $sha3_256_b64url = sha3_256_b64u('any data', 'more data', 'even more data');
121
122 =head2 sha3_256_file
123
124 Reads file (defined by filename or filehandle) content, and returns its SHA3_256 digest encoded as a binary string.
125
126 $sha3_256_raw = sha3_256_file('filename.dat');
127 #or
128 $sha3_256_raw = sha3_256_file(*FILEHANDLE);
129
130 =head2 sha3_256_file_hex
131
132 Reads file (defined by filename or filehandle) content, and returns its SHA3_256 digest encoded as a hexadecimal string.
133
134 $sha3_256_hex = sha3_256_file_hex('filename.dat');
135 #or
136 $sha3_256_hex = sha3_256_file_hex(*FILEHANDLE);
137
138 B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
139
140 =head2 sha3_256_file_b64
141
142 Reads file (defined by filename or filehandle) content, and returns its SHA3_256 digest encoded as a Base64 string, B<with> trailing '=' padding.
143
144 $sha3_256_b64 = sha3_256_file_b64('filename.dat');
145 #or
146 $sha3_256_b64 = sha3_256_file_b64(*FILEHANDLE);
147
148 =head2 sha3_256_file_b64u
149
150 Reads file (defined by filename or filehandle) content, and returns its SHA3_256 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
151
152 $sha3_256_b64url = sha3_256_file_b64u('filename.dat');
153 #or
154 $sha3_256_b64url = sha3_256_file_b64u(*FILEHANDLE);
155
156 =head1 METHODS
157
158 The OO interface provides the same set of functions as L<Crypt::Digest>.
159
160 =head2 new
161
162 $d = Crypt::Digest::SHA3_256->new();
163
164 =head2 clone
165
166 $d->clone();
167
168 =head2 reset
169
170 $d->reset();
171
172 =head2 add
173
174 $d->add('any data');
175 #or
176 $d->add('any data', 'more data', 'even more data');
177
178 =head2 addfile
179
180 $d->addfile('filename.dat');
181 #or
182 $d->addfile(*FILEHANDLE);
183
184 =head2 add_bits
185
186 $d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
187 #or
188 $d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
189
190 =head2 hashsize
191
192 $d->hashsize;
193 #or
194 Crypt::Digest::SHA3_256->hashsize();
195 #or
196 Crypt::Digest::SHA3_256::hashsize();
197
198 =head2 digest
199
200 $result_raw = $d->digest();
201
202 =head2 hexdigest
203
204 $result_hex = $d->hexdigest();
205
206 =head2 b64digest
207
208 $result_b64 = $d->b64digest();
209
210 =head2 b64udigest
211
212 $result_b64url = $d->b64udigest();
213
214 =head1 SEE ALSO
215
216 =over
217
218 =item * L<CryptX|CryptX>, L<Crypt::Digest|Crypt::Digest>
219
220 =item * L<http://en.wikipedia.org/wiki/SHA-3|http://en.wikipedia.org/wiki/SHA-3>
221
222 =back
223
224 =cut
225
226 __END__
0 package Crypt::Digest::SHA3_384;
1
2 ### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
3
4 use strict;
5 use warnings;
6 our $VERSION = '0.047';
7
8 use base qw(Crypt::Digest Exporter);
9 our %EXPORT_TAGS = ( all => [qw( sha3_384 sha3_384_hex sha3_384_b64 sha3_384_b64u sha3_384_file sha3_384_file_hex sha3_384_file_b64 sha3_384_file_b64u )] );
10 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
11 our @EXPORT = qw();
12
13 use Carp;
14 $Carp::Internal{(__PACKAGE__)}++;
15 use CryptX;
16
17 sub hashsize { Crypt::Digest::hashsize(__PACKAGE__) }
18
19 sub sha3_384 { Crypt::Digest::digest_data(__PACKAGE__, @_) }
20 sub sha3_384_hex { Crypt::Digest::digest_data_hex(__PACKAGE__, @_) }
21 sub sha3_384_b64 { Crypt::Digest::digest_data_b64(__PACKAGE__, @_) }
22 sub sha3_384_b64u { Crypt::Digest::digest_data_b64u(__PACKAGE__, @_) }
23
24 sub sha3_384_file { Crypt::Digest::digest_file(__PACKAGE__, @_) }
25 sub sha3_384_file_hex { Crypt::Digest::digest_file_hex(__PACKAGE__, @_) }
26 sub sha3_384_file_b64 { Crypt::Digest::digest_file_b64(__PACKAGE__, @_) }
27 sub sha3_384_file_b64u { Crypt::Digest::digest_file_b64u(__PACKAGE__, @_) }
28
29 1;
30
31 =pod
32
33 =head1 NAME
34
35 Crypt::Digest::SHA3_384 - Hash function SHA3-384 [size: 384 bits]
36
37 =head1 SYNOPSIS
38
39 ### Functional interface:
40 use Crypt::Digest::SHA3_384 qw( sha3_384 sha3_384_hex sha3_384_b64 sha3_384_b64u
41 sha3_384_file sha3_384_file_hex sha3_384_file_b64 sha3_384_file_b64u );
42
43 # calculate digest from string/buffer
44 $sha3_384_raw = sha3_384('data string');
45 $sha3_384_hex = sha3_384_hex('data string');
46 $sha3_384_b64 = sha3_384_b64('data string');
47 $sha3_384_b64u = sha3_384_b64u('data string');
48 # calculate digest from file
49 $sha3_384_raw = sha3_384_file('filename.dat');
50 $sha3_384_hex = sha3_384_file_hex('filename.dat');
51 $sha3_384_b64 = sha3_384_file_b64('filename.dat');
52 $sha3_384_b64u = sha3_384_file_b64u('filename.dat');
53 # calculate digest from filehandle
54 $sha3_384_raw = sha3_384_file(*FILEHANDLE);
55 $sha3_384_hex = sha3_384_file_hex(*FILEHANDLE);
56 $sha3_384_b64 = sha3_384_file_b64(*FILEHANDLE);
57 $sha3_384_b64u = sha3_384_file_b64u(*FILEHANDLE);
58
59 ### OO interface:
60 use Crypt::Digest::SHA3_384;
61
62 $d = Crypt::Digest::SHA3_384->new;
63 $d->add('any data');
64 $d->addfile('filename.dat');
65 $d->addfile(*FILEHANDLE);
66 $result_raw = $d->digest; # raw bytes
67 $result_hex = $d->hexdigest; # hexadecimal form
68 $result_b64 = $d->b64digest; # Base64 form
69 $result_b64u = $d->b64udigest; # Base64 URL Safe form
70
71 =head1 DESCRIPTION
72
73 Provides an interface to the SHA3_384 digest algorithm.
74
75 =head1 EXPORT
76
77 Nothing is exported by default.
78
79 You can export selected functions:
80
81 use Crypt::Digest::SHA3_384 qw(sha3_384 sha3_384_hex sha3_384_b64 sha3_384_b64u
82 sha3_384_file sha3_384_file_hex sha3_384_file_b64 sha3_384_file_b64u);
83
84 Or all of them at once:
85
86 use Crypt::Digest::SHA3_384 ':all';
87
88 =head1 FUNCTIONS
89
90 =head2 sha3_384
91
92 Logically joins all arguments into a single string, and returns its SHA3_384 digest encoded as a binary string.
93
94 $sha3_384_raw = sha3_384('data string');
95 #or
96 $sha3_384_raw = sha3_384('any data', 'more data', 'even more data');
97
98 =head2 sha3_384_hex
99
100 Logically joins all arguments into a single string, and returns its SHA3_384 digest encoded as a hexadecimal string.
101
102 $sha3_384_hex = sha3_384_hex('data string');
103 #or
104 $sha3_384_hex = sha3_384_hex('any data', 'more data', 'even more data');
105
106 =head2 sha3_384_b64
107
108 Logically joins all arguments into a single string, and returns its SHA3_384 digest encoded as a Base64 string, B<with> trailing '=' padding.
109
110 $sha3_384_b64 = sha3_384_b64('data string');
111 #or
112 $sha3_384_b64 = sha3_384_b64('any data', 'more data', 'even more data');
113
114 =head2 sha3_384_b64u
115
116 Logically joins all arguments into a single string, and returns its SHA3_384 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
117
118 $sha3_384_b64url = sha3_384_b64u('data string');
119 #or
120 $sha3_384_b64url = sha3_384_b64u('any data', 'more data', 'even more data');
121
122 =head2 sha3_384_file
123
124 Reads file (defined by filename or filehandle) content, and returns its SHA3_384 digest encoded as a binary string.
125
126 $sha3_384_raw = sha3_384_file('filename.dat');
127 #or
128 $sha3_384_raw = sha3_384_file(*FILEHANDLE);
129
130 =head2 sha3_384_file_hex
131
132 Reads file (defined by filename or filehandle) content, and returns its SHA3_384 digest encoded as a hexadecimal string.
133
134 $sha3_384_hex = sha3_384_file_hex('filename.dat');
135 #or
136 $sha3_384_hex = sha3_384_file_hex(*FILEHANDLE);
137
138 B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
139
140 =head2 sha3_384_file_b64
141
142 Reads file (defined by filename or filehandle) content, and returns its SHA3_384 digest encoded as a Base64 string, B<with> trailing '=' padding.
143
144 $sha3_384_b64 = sha3_384_file_b64('filename.dat');
145 #or
146 $sha3_384_b64 = sha3_384_file_b64(*FILEHANDLE);
147
148 =head2 sha3_384_file_b64u
149
150 Reads file (defined by filename or filehandle) content, and returns its SHA3_384 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
151
152 $sha3_384_b64url = sha3_384_file_b64u('filename.dat');
153 #or
154 $sha3_384_b64url = sha3_384_file_b64u(*FILEHANDLE);
155
156 =head1 METHODS
157
158 The OO interface provides the same set of functions as L<Crypt::Digest>.
159
160 =head2 new
161
162 $d = Crypt::Digest::SHA3_384->new();
163
164 =head2 clone
165
166 $d->clone();
167
168 =head2 reset
169
170 $d->reset();
171
172 =head2 add
173
174 $d->add('any data');
175 #or
176 $d->add('any data', 'more data', 'even more data');
177
178 =head2 addfile
179
180 $d->addfile('filename.dat');
181 #or
182 $d->addfile(*FILEHANDLE);
183
184 =head2 add_bits
185
186 $d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
187 #or
188 $d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
189
190 =head2 hashsize
191
192 $d->hashsize;
193 #or
194 Crypt::Digest::SHA3_384->hashsize();
195 #or
196 Crypt::Digest::SHA3_384::hashsize();
197
198 =head2 digest
199
200 $result_raw = $d->digest();
201
202 =head2 hexdigest
203
204 $result_hex = $d->hexdigest();
205
206 =head2 b64digest
207
208 $result_b64 = $d->b64digest();
209
210 =head2 b64udigest
211
212 $result_b64url = $d->b64udigest();
213
214 =head1 SEE ALSO
215
216 =over
217
218 =item * L<CryptX|CryptX>, L<Crypt::Digest|Crypt::Digest>
219
220 =item * L<http://en.wikipedia.org/wiki/SHA-3|http://en.wikipedia.org/wiki/SHA-3>
221
222 =back
223
224 =cut
225
226 __END__
0 package Crypt::Digest::SHA3_512;
1
2 ### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
3
4 use strict;
5 use warnings;
6 our $VERSION = '0.047';
7
8 use base qw(Crypt::Digest Exporter);
9 our %EXPORT_TAGS = ( all => [qw( sha3_512 sha3_512_hex sha3_512_b64 sha3_512_b64u sha3_512_file sha3_512_file_hex sha3_512_file_b64 sha3_512_file_b64u )] );
10 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
11 our @EXPORT = qw();
12
13 use Carp;
14 $Carp::Internal{(__PACKAGE__)}++;
15 use CryptX;
16
17 sub hashsize { Crypt::Digest::hashsize(__PACKAGE__) }
18
19 sub sha3_512 { Crypt::Digest::digest_data(__PACKAGE__, @_) }
20 sub sha3_512_hex { Crypt::Digest::digest_data_hex(__PACKAGE__, @_) }
21 sub sha3_512_b64 { Crypt::Digest::digest_data_b64(__PACKAGE__, @_) }
22 sub sha3_512_b64u { Crypt::Digest::digest_data_b64u(__PACKAGE__, @_) }
23
24 sub sha3_512_file { Crypt::Digest::digest_file(__PACKAGE__, @_) }
25 sub sha3_512_file_hex { Crypt::Digest::digest_file_hex(__PACKAGE__, @_) }
26 sub sha3_512_file_b64 { Crypt::Digest::digest_file_b64(__PACKAGE__, @_) }
27 sub sha3_512_file_b64u { Crypt::Digest::digest_file_b64u(__PACKAGE__, @_) }
28
29 1;
30
31 =pod
32
33 =head1 NAME
34
35 Crypt::Digest::SHA3_512 - Hash function SHA3-512 [size: 512 bits]
36
37 =head1 SYNOPSIS
38
39 ### Functional interface:
40 use Crypt::Digest::SHA3_512 qw( sha3_512 sha3_512_hex sha3_512_b64 sha3_512_b64u
41 sha3_512_file sha3_512_file_hex sha3_512_file_b64 sha3_512_file_b64u );
42
43 # calculate digest from string/buffer
44 $sha3_512_raw = sha3_512('data string');
45 $sha3_512_hex = sha3_512_hex('data string');
46 $sha3_512_b64 = sha3_512_b64('data string');
47 $sha3_512_b64u = sha3_512_b64u('data string');
48 # calculate digest from file
49 $sha3_512_raw = sha3_512_file('filename.dat');
50 $sha3_512_hex = sha3_512_file_hex('filename.dat');
51 $sha3_512_b64 = sha3_512_file_b64('filename.dat');
52 $sha3_512_b64u = sha3_512_file_b64u('filename.dat');
53 # calculate digest from filehandle
54 $sha3_512_raw = sha3_512_file(*FILEHANDLE);
55 $sha3_512_hex = sha3_512_file_hex(*FILEHANDLE);
56 $sha3_512_b64 = sha3_512_file_b64(*FILEHANDLE);
57 $sha3_512_b64u = sha3_512_file_b64u(*FILEHANDLE);
58
59 ### OO interface:
60 use Crypt::Digest::SHA3_512;
61
62 $d = Crypt::Digest::SHA3_512->new;
63 $d->add('any data');
64 $d->addfile('filename.dat');
65 $d->addfile(*FILEHANDLE);
66 $result_raw = $d->digest; # raw bytes
67 $result_hex = $d->hexdigest; # hexadecimal form
68 $result_b64 = $d->b64digest; # Base64 form
69 $result_b64u = $d->b64udigest; # Base64 URL Safe form
70
71 =head1 DESCRIPTION
72
73 Provides an interface to the SHA3_512 digest algorithm.
74
75 =head1 EXPORT
76
77 Nothing is exported by default.
78
79 You can export selected functions:
80
81 use Crypt::Digest::SHA3_512 qw(sha3_512 sha3_512_hex sha3_512_b64 sha3_512_b64u
82 sha3_512_file sha3_512_file_hex sha3_512_file_b64 sha3_512_file_b64u);
83
84 Or all of them at once:
85
86 use Crypt::Digest::SHA3_512 ':all';
87
88 =head1 FUNCTIONS
89
90 =head2 sha3_512
91
92 Logically joins all arguments into a single string, and returns its SHA3_512 digest encoded as a binary string.
93
94 $sha3_512_raw = sha3_512('data string');
95 #or
96 $sha3_512_raw = sha3_512('any data', 'more data', 'even more data');
97
98 =head2 sha3_512_hex
99
100 Logically joins all arguments into a single string, and returns its SHA3_512 digest encoded as a hexadecimal string.
101
102 $sha3_512_hex = sha3_512_hex('data string');
103 #or
104 $sha3_512_hex = sha3_512_hex('any data', 'more data', 'even more data');
105
106 =head2 sha3_512_b64
107
108 Logically joins all arguments into a single string, and returns its SHA3_512 digest encoded as a Base64 string, B<with> trailing '=' padding.
109
110 $sha3_512_b64 = sha3_512_b64('data string');
111 #or
112 $sha3_512_b64 = sha3_512_b64('any data', 'more data', 'even more data');
113
114 =head2 sha3_512_b64u
115
116 Logically joins all arguments into a single string, and returns its SHA3_512 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
117
118 $sha3_512_b64url = sha3_512_b64u('data string');
119 #or
120 $sha3_512_b64url = sha3_512_b64u('any data', 'more data', 'even more data');
121
122 =head2 sha3_512_file
123
124 Reads file (defined by filename or filehandle) content, and returns its SHA3_512 digest encoded as a binary string.
125
126 $sha3_512_raw = sha3_512_file('filename.dat');
127 #or
128 $sha3_512_raw = sha3_512_file(*FILEHANDLE);
129
130 =head2 sha3_512_file_hex
131
132 Reads file (defined by filename or filehandle) content, and returns its SHA3_512 digest encoded as a hexadecimal string.
133
134 $sha3_512_hex = sha3_512_file_hex('filename.dat');
135 #or
136 $sha3_512_hex = sha3_512_file_hex(*FILEHANDLE);
137
138 B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
139
140 =head2 sha3_512_file_b64
141
142 Reads file (defined by filename or filehandle) content, and returns its SHA3_512 digest encoded as a Base64 string, B<with> trailing '=' padding.
143
144 $sha3_512_b64 = sha3_512_file_b64('filename.dat');
145 #or
146 $sha3_512_b64 = sha3_512_file_b64(*FILEHANDLE);
147
148 =head2 sha3_512_file_b64u
149
150 Reads file (defined by filename or filehandle) content, and returns its SHA3_512 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
151
152 $sha3_512_b64url = sha3_512_file_b64u('filename.dat');
153 #or
154 $sha3_512_b64url = sha3_512_file_b64u(*FILEHANDLE);
155
156 =head1 METHODS
157
158 The OO interface provides the same set of functions as L<Crypt::Digest>.
159
160 =head2 new
161
162 $d = Crypt::Digest::SHA3_512->new();
163
164 =head2 clone
165
166 $d->clone();
167
168 =head2 reset
169
170 $d->reset();
171
172 =head2 add
173
174 $d->add('any data');
175 #or
176 $d->add('any data', 'more data', 'even more data');
177
178 =head2 addfile
179
180 $d->addfile('filename.dat');
181 #or
182 $d->addfile(*FILEHANDLE);
183
184 =head2 add_bits
185
186 $d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
187 #or
188 $d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
189
190 =head2 hashsize
191
192 $d->hashsize;
193 #or
194 Crypt::Digest::SHA3_512->hashsize();
195 #or
196 Crypt::Digest::SHA3_512::hashsize();
197
198 =head2 digest
199
200 $result_raw = $d->digest();
201
202 =head2 hexdigest
203
204 $result_hex = $d->hexdigest();
205
206 =head2 b64digest
207
208 $result_b64 = $d->b64digest();
209
210 =head2 b64udigest
211
212 $result_b64url = $d->b64udigest();
213
214 =head1 SEE ALSO
215
216 =over
217
218 =item * L<CryptX|CryptX>, L<Crypt::Digest|Crypt::Digest>
219
220 =item * L<http://en.wikipedia.org/wiki/SHA-3|http://en.wikipedia.org/wiki/SHA-3>
221
222 =back
223
224 =cut
225
226 __END__
2222 ltc/hashes/helper/hash_memory_multi.o ltc/hashes/md2.o ltc/hashes/md4.o ltc/hashes/md5.o ltc/hashes/rmd128.o \
2323 ltc/hashes/rmd160.o ltc/hashes/rmd256.o ltc/hashes/rmd320.o ltc/hashes/sha1.o ltc/hashes/sha2/sha224.o \
2424 ltc/hashes/sha2/sha256.o ltc/hashes/sha2/sha384.o ltc/hashes/sha2/sha512.o ltc/hashes/sha2/sha512_224.o \
25 ltc/hashes/sha2/sha512_256.o ltc/hashes/tiger.o ltc/hashes/whirl/whirl.o ltc/hashes/sha3.o \
25 ltc/hashes/sha2/sha512_256.o ltc/hashes/tiger.o ltc/hashes/whirl/whirl.o ltc/hashes/sha3.o ltc/hashes/sha3_test.o \
2626 ltc/mac/poly1305/poly1305.o ltc/mac/poly1305/poly1305_file.o ltc/mac/poly1305/poly1305_memory.o ltc/mac/poly1305/poly1305_memory_multi.o \
2727 ltc/mac/f9/f9_done.o ltc/mac/f9/f9_file.o ltc/mac/f9/f9_init.o ltc/mac/f9/f9_memory.o ltc/mac/f9/f9_memory_multi.o ltc/mac/f9/f9_process.o \
2828 ltc/mac/hmac/hmac_done.o ltc/mac/hmac/hmac_file.o ltc/mac/hmac/hmac_init.o ltc/mac/hmac/hmac_memory.o \
2222 ltc/hashes/helper/hash_memory_multi.obj ltc/hashes/md2.obj ltc/hashes/md4.obj ltc/hashes/md5.obj ltc/hashes/rmd128.obj \
2323 ltc/hashes/rmd160.obj ltc/hashes/rmd256.obj ltc/hashes/rmd320.obj ltc/hashes/sha1.obj ltc/hashes/sha2/sha224.obj \
2424 ltc/hashes/sha2/sha256.obj ltc/hashes/sha2/sha384.obj ltc/hashes/sha2/sha512.obj ltc/hashes/sha2/sha512_224.obj \
25 ltc/hashes/sha2/sha512_256.obj ltc/hashes/tiger.obj ltc/hashes/whirl/whirl.obj ltc/hashes/sha3.obj \
25 ltc/hashes/sha2/sha512_256.obj ltc/hashes/tiger.obj ltc/hashes/whirl/whirl.obj ltc/hashes/sha3.obj ltc/hashes/sha3_test.obj \
2626 ltc/mac/poly1305/poly1305.obj ltc/mac/poly1305/poly1305_file.obj ltc/mac/poly1305/poly1305_memory.obj ltc/mac/poly1305/poly1305_memory_multi.obj \
2727 ltc/mac/f9/f9_done.obj ltc/mac/f9/f9_file.obj ltc/mac/f9/f9_init.obj ltc/mac/f9/f9_memory.obj ltc/mac/f9/f9_memory_multi.obj ltc/mac/f9/f9_process.obj \
2828 ltc/mac/hmac/hmac_done.obj ltc/mac/hmac/hmac_file.obj ltc/mac/hmac/hmac_init.obj ltc/mac/hmac/hmac_memory.obj \
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
8
9 /* based on https://github.com/brainhub/SHA3IUF (public domain) */
10
11 #include "tomcrypt.h"
12
13 #ifdef LTC_SHA3
14
15 int sha3_224_test(void)
16 {
17 #ifndef LTC_TEST
18 return CRYPT_NOP;
19 #else
20 unsigned char buf[200], hash[200];
21 int i;
22 hash_state c;
23 const unsigned char c1 = 0xa3;
24
25 const unsigned char sha3_224_empty[224 / 8] = {
26 0x6b, 0x4e, 0x03, 0x42, 0x36, 0x67, 0xdb, 0xb7,
27 0x3b, 0x6e, 0x15, 0x45, 0x4f, 0x0e, 0xb1, 0xab,
28 0xd4, 0x59, 0x7f, 0x9a, 0x1b, 0x07, 0x8e, 0x3f,
29 0x5b, 0x5a, 0x6b, 0xc7
30 };
31
32 const unsigned char sha3_224_0xa3_200_times[224 / 8] = {
33 0x93, 0x76, 0x81, 0x6a, 0xba, 0x50, 0x3f, 0x72,
34 0xf9, 0x6c, 0xe7, 0xeb, 0x65, 0xac, 0x09, 0x5d,
35 0xee, 0xe3, 0xbe, 0x4b, 0xf9, 0xbb, 0xc2, 0xa1,
36 0xcb, 0x7e, 0x11, 0xe0
37 };
38
39 XMEMSET(buf, c1, sizeof(buf));
40
41 /* SHA3-224 on an empty buffer */
42 sha3_224_init(&c);
43 sha3_done(&c, hash);
44 if(XMEMCMP(sha3_224_empty, hash, sizeof(sha3_224_empty)) != 0) {
45 printf("SHA3-224() failed\n");
46 return CRYPT_FAIL_TESTVECTOR;
47 }
48
49 /* SHA3-224 in two steps. [FIPS 202] */
50 sha3_224_init(&c);
51 sha3_process(&c, buf, sizeof(buf) / 2);
52 sha3_process(&c, buf + sizeof(buf) / 2, sizeof(buf) / 2);
53 sha3_done(&c, hash);
54 if(XMEMCMP(sha3_224_0xa3_200_times, hash, sizeof(sha3_224_0xa3_200_times)) != 0) {
55 printf("SHA3-224( 0xa3 ... [200 times] ) failed (2 steps)\n");
56 return CRYPT_FAIL_TESTVECTOR;
57 }
58
59 /* SHA3-224 byte-by-byte: 200 steps. [FIPS 202] */
60 i = 200;
61 sha3_224_init(&c);
62 while (i--) {
63 sha3_process(&c, &c1, 1);
64 }
65 sha3_done(&c, hash);
66 if(XMEMCMP(sha3_224_0xa3_200_times, hash, sizeof(sha3_224_0xa3_200_times)) != 0) {
67 printf("SHA3-224( 0xa3 ... [200 times] ) failed (200 steps)\n");
68 return CRYPT_FAIL_TESTVECTOR;
69 }
70
71 return CRYPT_OK;
72 #endif
73 }
74
75 int sha3_256_test(void)
76 {
77 #ifndef LTC_TEST
78 return CRYPT_NOP;
79 #else
80 unsigned char buf[200], hash[200];
81 int i;
82 hash_state c;
83 const unsigned char c1 = 0xa3;
84
85 const unsigned char sha3_256_empty[256 / 8] = {
86 0xa7, 0xff, 0xc6, 0xf8, 0xbf, 0x1e, 0xd7, 0x66,
87 0x51, 0xc1, 0x47, 0x56, 0xa0, 0x61, 0xd6, 0x62,
88 0xf5, 0x80, 0xff, 0x4d, 0xe4, 0x3b, 0x49, 0xfa,
89 0x82, 0xd8, 0x0a, 0x4b, 0x80, 0xf8, 0x43, 0x4a
90 };
91 const unsigned char sha3_256_0xa3_200_times[256 / 8] = {
92 0x79, 0xf3, 0x8a, 0xde, 0xc5, 0xc2, 0x03, 0x07,
93 0xa9, 0x8e, 0xf7, 0x6e, 0x83, 0x24, 0xaf, 0xbf,
94 0xd4, 0x6c, 0xfd, 0x81, 0xb2, 0x2e, 0x39, 0x73,
95 0xc6, 0x5f, 0xa1, 0xbd, 0x9d, 0xe3, 0x17, 0x87
96 };
97
98 XMEMSET(buf, c1, sizeof(buf));
99
100 /* SHA3-256 on an empty buffer */
101 sha3_256_init(&c);
102 sha3_done(&c, hash);
103 if(XMEMCMP(sha3_256_empty, hash, sizeof(sha3_256_empty)) != 0) {
104 printf("SHA3-256() failed\n");
105 return CRYPT_FAIL_TESTVECTOR;
106 }
107
108 /* SHA3-256 as a single buffer. [FIPS 202] */
109 sha3_256_init(&c);
110 sha3_process(&c, buf, sizeof(buf));
111 sha3_done(&c, hash);
112 if(XMEMCMP(sha3_256_0xa3_200_times, hash, sizeof(sha3_256_0xa3_200_times)) != 0) {
113 printf("SHA3-256( 0xa3 ... [200 times] ) failed (1 buffer)\n");
114 return CRYPT_FAIL_TESTVECTOR;
115 }
116
117 /* SHA3-256 in two steps. [FIPS 202] */
118 sha3_256_init(&c);
119 sha3_process(&c, buf, sizeof(buf) / 2);
120 sha3_process(&c, buf + sizeof(buf) / 2, sizeof(buf) / 2);
121 sha3_done(&c, hash);
122 if(XMEMCMP(sha3_256_0xa3_200_times, hash, sizeof(sha3_256_0xa3_200_times)) != 0) {
123 printf("SHA3-256( 0xa3 ... [200 times] ) failed (2 steps)\n");
124 return CRYPT_FAIL_TESTVECTOR;
125 }
126
127 /* SHA3-256 byte-by-byte: 200 steps. [FIPS 202] */
128 i = 200;
129 sha3_256_init(&c);
130 while (i--) {
131 sha3_process(&c, &c1, 1);
132 }
133 sha3_done(&c, hash);
134 if(XMEMCMP(sha3_256_0xa3_200_times, hash, sizeof(sha3_256_0xa3_200_times)) != 0) {
135 printf("SHA3-256( 0xa3 ... [200 times] ) failed (200 steps)\n");
136 return CRYPT_FAIL_TESTVECTOR;
137 }
138
139 /* SHA3-256 byte-by-byte: 135 bytes. Input from [Keccak]. Output
140 * matched with sha3sum. */
141 sha3_256_init(&c);
142 sha3_process(&c, (unsigned char*)
143 "\xb7\x71\xd5\xce\xf5\xd1\xa4\x1a"
144 "\x93\xd1\x56\x43\xd7\x18\x1d\x2a"
145 "\x2e\xf0\xa8\xe8\x4d\x91\x81\x2f"
146 "\x20\xed\x21\xf1\x47\xbe\xf7\x32"
147 "\xbf\x3a\x60\xef\x40\x67\xc3\x73"
148 "\x4b\x85\xbc\x8c\xd4\x71\x78\x0f"
149 "\x10\xdc\x9e\x82\x91\xb5\x83\x39"
150 "\xa6\x77\xb9\x60\x21\x8f\x71\xe7"
151 "\x93\xf2\x79\x7a\xea\x34\x94\x06"
152 "\x51\x28\x29\x06\x5d\x37\xbb\x55"
153 "\xea\x79\x6f\xa4\xf5\x6f\xd8\x89"
154 "\x6b\x49\xb2\xcd\x19\xb4\x32\x15"
155 "\xad\x96\x7c\x71\x2b\x24\xe5\x03"
156 "\x2d\x06\x52\x32\xe0\x2c\x12\x74"
157 "\x09\xd2\xed\x41\x46\xb9\xd7\x5d"
158 "\x76\x3d\x52\xdb\x98\xd9\x49\xd3"
159 "\xb0\xfe\xd6\xa8\x05\x2f\xbb", 1080 / 8);
160 sha3_done(&c, hash);
161 if(XMEMCMP(hash, "\xa1\x9e\xee\x92\xbb\x20\x97\xb6"
162 "\x4e\x82\x3d\x59\x77\x98\xaa\x18"
163 "\xbe\x9b\x7c\x73\x6b\x80\x59\xab"
164 "\xfd\x67\x79\xac\x35\xac\x81\xb5", 256 / 8) != 0) {
165 printf("SHA3-256( b771 ... ) doesn't match the known answer\n");
166 return CRYPT_FAIL_TESTVECTOR;
167 }
168
169 return CRYPT_OK;
170 #endif
171 }
172
173 int sha3_384_test(void)
174 {
175 #ifndef LTC_TEST
176 return CRYPT_NOP;
177 #else
178 unsigned char buf[200], hash[200];
179 int i;
180 hash_state c;
181 const unsigned char c1 = 0xa3;
182
183 const unsigned char sha3_384_0xa3_200_times[384 / 8] = {
184 0x18, 0x81, 0xde, 0x2c, 0xa7, 0xe4, 0x1e, 0xf9,
185 0x5d, 0xc4, 0x73, 0x2b, 0x8f, 0x5f, 0x00, 0x2b,
186 0x18, 0x9c, 0xc1, 0xe4, 0x2b, 0x74, 0x16, 0x8e,
187 0xd1, 0x73, 0x26, 0x49, 0xce, 0x1d, 0xbc, 0xdd,
188 0x76, 0x19, 0x7a, 0x31, 0xfd, 0x55, 0xee, 0x98,
189 0x9f, 0x2d, 0x70, 0x50, 0xdd, 0x47, 0x3e, 0x8f
190 };
191
192 XMEMSET(buf, c1, sizeof(buf));
193
194 /* SHA3-384 as a single buffer. [FIPS 202] */
195 sha3_384_init(&c);
196 sha3_process(&c, buf, sizeof(buf));
197 sha3_done(&c, hash);
198 if(XMEMCMP(sha3_384_0xa3_200_times, hash, sizeof(sha3_384_0xa3_200_times)) != 0) {
199 printf("SHA3-384( 0xa3 ... [200 times] ) failed (1 buffer)\n");
200 return CRYPT_FAIL_TESTVECTOR;
201 }
202
203 /* SHA3-384 in two steps. [FIPS 202] */
204 sha3_384_init(&c);
205 sha3_process(&c, buf, sizeof(buf) / 2);
206 sha3_process(&c, buf + sizeof(buf) / 2, sizeof(buf) / 2);
207 sha3_done(&c, hash);
208 if(XMEMCMP(sha3_384_0xa3_200_times, hash, sizeof(sha3_384_0xa3_200_times)) != 0) {
209 printf("SHA3-384( 0xa3 ... [200 times] ) failed (2 steps)\n");
210 return CRYPT_FAIL_TESTVECTOR;
211 }
212
213 /* SHA3-384 byte-by-byte: 200 steps. [FIPS 202] */
214 i = 200;
215 sha3_384_init(&c);
216 while (i--) {
217 sha3_process(&c, &c1, 1);
218 }
219 sha3_done(&c, hash);
220 if(XMEMCMP(sha3_384_0xa3_200_times, hash, sizeof(sha3_384_0xa3_200_times)) != 0) {
221 printf("SHA3-384( 0xa3 ... [200 times] ) failed (200 steps)\n");
222 return CRYPT_FAIL_TESTVECTOR;
223 }
224
225 return CRYPT_OK;
226 #endif
227 }
228
229 int sha3_512_test(void)
230 {
231 #ifndef LTC_TEST
232 return CRYPT_NOP;
233 #else
234 unsigned char buf[200], hash[200];
235 int i;
236 hash_state c;
237 const unsigned char c1 = 0xa3;
238
239 const unsigned char sha3_512_0xa3_200_times[512 / 8] = {
240 0xe7, 0x6d, 0xfa, 0xd2, 0x20, 0x84, 0xa8, 0xb1,
241 0x46, 0x7f, 0xcf, 0x2f, 0xfa, 0x58, 0x36, 0x1b,
242 0xec, 0x76, 0x28, 0xed, 0xf5, 0xf3, 0xfd, 0xc0,
243 0xe4, 0x80, 0x5d, 0xc4, 0x8c, 0xae, 0xec, 0xa8,
244 0x1b, 0x7c, 0x13, 0xc3, 0x0a, 0xdf, 0x52, 0xa3,
245 0x65, 0x95, 0x84, 0x73, 0x9a, 0x2d, 0xf4, 0x6b,
246 0xe5, 0x89, 0xc5, 0x1c, 0xa1, 0xa4, 0xa8, 0x41,
247 0x6d, 0xf6, 0x54, 0x5a, 0x1c, 0xe8, 0xba, 0x00
248 };
249
250 XMEMSET(buf, c1, sizeof(buf));
251
252 /* SHA3-512 as a single buffer. [FIPS 202] */
253 sha3_512_init(&c);
254 sha3_process(&c, buf, sizeof(buf));
255 sha3_done(&c, hash);
256 if(XMEMCMP(sha3_512_0xa3_200_times, hash, sizeof(sha3_512_0xa3_200_times)) != 0) {
257 printf("SHA3-512( 0xa3 ... [200 times] ) failed (1 buffer)\n");
258 return CRYPT_FAIL_TESTVECTOR;
259 }
260
261 /* SHA3-512 in two steps. [FIPS 202] */
262 sha3_512_init(&c);
263 sha3_process(&c, buf, sizeof(buf) / 2);
264 sha3_process(&c, buf + sizeof(buf) / 2, sizeof(buf) / 2);
265 sha3_done(&c, hash);
266 if(XMEMCMP(sha3_512_0xa3_200_times, hash, sizeof(sha3_512_0xa3_200_times)) != 0) {
267 printf("SHA3-512( 0xa3 ... [200 times] ) failed (2 steps)\n");
268 return CRYPT_FAIL_TESTVECTOR;
269 }
270
271 /* SHA3-512 byte-by-byte: 200 steps. [FIPS 202] */
272 i = 200;
273 sha3_512_init(&c);
274 while (i--) {
275 sha3_process(&c, &c1, 1);
276 }
277 sha3_done(&c, hash);
278 if(XMEMCMP(sha3_512_0xa3_200_times, hash, sizeof(sha3_512_0xa3_200_times)) != 0) {
279 printf("SHA3-512( 0xa3 ... [200 times] ) failed (200 steps)\n");
280 return CRYPT_FAIL_TESTVECTOR;
281 }
282
283 return CRYPT_OK;
284 #endif
285 }
286
287 int sha3_shake_test(void)
288 {
289 #ifndef LTC_TEST
290 return CRYPT_NOP;
291 #else
292 unsigned char buf[200], hash[512];
293 int i;
294 hash_state c;
295 const unsigned char c1 = 0xa3;
296 unsigned long len;
297
298 const unsigned char shake256_empty[32] = {
299 0xab, 0x0b, 0xae, 0x31, 0x63, 0x39, 0x89, 0x43,
300 0x04, 0xe3, 0x58, 0x77, 0xb0, 0xc2, 0x8a, 0x9b,
301 0x1f, 0xd1, 0x66, 0xc7, 0x96, 0xb9, 0xcc, 0x25,
302 0x8a, 0x06, 0x4a, 0x8f, 0x57, 0xe2, 0x7f, 0x2a
303 };
304 const unsigned char shake256_0xa3_200_times[32] = {
305 0x6a, 0x1a, 0x9d, 0x78, 0x46, 0x43, 0x6e, 0x4d,
306 0xca, 0x57, 0x28, 0xb6, 0xf7, 0x60, 0xee, 0xf0,
307 0xca, 0x92, 0xbf, 0x0b, 0xe5, 0x61, 0x5e, 0x96,
308 0x95, 0x9d, 0x76, 0x71, 0x97, 0xa0, 0xbe, 0xeb
309 };
310 const unsigned char shake128_empty[32] = {
311 0x43, 0xe4, 0x1b, 0x45, 0xa6, 0x53, 0xf2, 0xa5,
312 0xc4, 0x49, 0x2c, 0x1a, 0xdd, 0x54, 0x45, 0x12,
313 0xdd, 0xa2, 0x52, 0x98, 0x33, 0x46, 0x2b, 0x71,
314 0xa4, 0x1a, 0x45, 0xbe, 0x97, 0x29, 0x0b, 0x6f
315 };
316 const unsigned char shake128_0xa3_200_times[32] = {
317 0x44, 0xc9, 0xfb, 0x35, 0x9f, 0xd5, 0x6a, 0xc0,
318 0xa9, 0xa7, 0x5a, 0x74, 0x3c, 0xff, 0x68, 0x62,
319 0xf1, 0x7d, 0x72, 0x59, 0xab, 0x07, 0x52, 0x16,
320 0xc0, 0x69, 0x95, 0x11, 0x64, 0x3b, 0x64, 0x39
321 };
322
323 XMEMSET(buf, c1, sizeof(buf));
324
325 /* SHAKE256 on an empty buffer */
326 sha3_shake_init(&c, 256);
327 for (i = 0; i < 16; i++) sha3_shake_done(&c, hash, 32); /* get 512 bytes, keep in hash the last 32 */
328 if(XMEMCMP(shake256_empty, hash, sizeof(shake256_empty)) != 0) {
329 printf("SHAKE256('') failed\n");
330 return CRYPT_FAIL_TESTVECTOR;
331 }
332
333 /* SHAKE256 via sha3_shake_memory [FIPS 202] */
334 len = 512;
335 sha3_shake_memory(256, buf, sizeof(buf), hash, &len);
336 if(XMEMCMP(shake256_0xa3_200_times, hash + 480, sizeof(shake256_0xa3_200_times)) != 0) {
337 printf("SHAKE256( 0xa3 ... [200 times] ) failed (sha3_shake_memory)\n");
338 return CRYPT_FAIL_TESTVECTOR;
339 }
340
341 /* SHAKE256 as a single buffer. [FIPS 202] */
342 sha3_shake_init(&c, 256);
343 sha3_shake_process(&c, buf, sizeof(buf));
344 for (i = 0; i < 16; i++) sha3_shake_done(&c, hash, 32); /* get 512 bytes, keep in hash the last 32 */
345 if(XMEMCMP(shake256_0xa3_200_times, hash, sizeof(shake256_0xa3_200_times)) != 0) {
346 printf("SHAKE256( 0xa3 ... [200 times] ) failed (1 buffer)\n");
347 return CRYPT_FAIL_TESTVECTOR;
348 }
349
350 /* SHAKE256 in two steps. [FIPS 202] */
351 sha3_shake_init(&c, 256);
352 sha3_shake_process(&c, buf, sizeof(buf) / 2);
353 sha3_shake_process(&c, buf + sizeof(buf) / 2, sizeof(buf) / 2);
354 for (i = 0; i < 16; i++) sha3_shake_done(&c, hash, 32); /* get 512 bytes, keep in hash the last 32 */
355 if(XMEMCMP(shake256_0xa3_200_times, hash, sizeof(shake256_0xa3_200_times)) != 0) {
356 printf("SHAKE256( 0xa3 ... [200 times] ) failed (2 steps)\n");
357 return CRYPT_FAIL_TESTVECTOR;
358 }
359
360 /* SHAKE256 byte-by-byte: 200 steps. [FIPS 202] */
361 i = 200;
362 sha3_shake_init(&c, 256);
363 while (i--) sha3_shake_process(&c, &c1, 1);
364 for (i = 0; i < 16; i++) sha3_shake_done(&c, hash, 32); /* get 512 bytes, keep in hash the last 32 */
365 if(XMEMCMP(shake256_0xa3_200_times, hash, sizeof(shake256_0xa3_200_times)) != 0) {
366 printf("SHAKE256( 0xa3 ... [200 times] ) failed (200 steps)\n");
367 return CRYPT_FAIL_TESTVECTOR;
368 }
369
370 /* SHAKE128 on an empty buffer */
371 sha3_shake_init(&c, 128);
372 for (i = 0; i < 16; i++) sha3_shake_done(&c, hash, 32); /* get 512 bytes, keep in hash the last 32 */
373 if(XMEMCMP(shake128_empty, hash, sizeof(shake128_empty)) != 0) {
374 printf("SHAKE128() failed\n");
375 return CRYPT_FAIL_TESTVECTOR;
376 }
377
378 /* SHAKE128 via sha3_shake_memory [FIPS 202] */
379 len = 512;
380 sha3_shake_memory(128, buf, sizeof(buf), hash, &len);
381 if(XMEMCMP(shake128_0xa3_200_times, hash + 480, sizeof(shake128_0xa3_200_times)) != 0) {
382 printf("SHAKE128( 0xa3 ... [200 times] ) failed (sha3_shake_memory)\n");
383 return CRYPT_FAIL_TESTVECTOR;
384 }
385
386 /* SHAKE128 as a single buffer. [FIPS 202] */
387 sha3_shake_init(&c, 128);
388 sha3_shake_process(&c, buf, sizeof(buf));
389 for (i = 0; i < 16; i++) sha3_shake_done(&c, hash, 32); /* get 512 bytes, keep in hash the last 32 */
390 if(XMEMCMP(shake128_0xa3_200_times, hash, sizeof(shake128_0xa3_200_times)) != 0) {
391 printf("SHAKE128( 0xa3 ... [200 times] ) failed (1 buffer)\n");
392 return CRYPT_FAIL_TESTVECTOR;
393 }
394
395 /* SHAKE128 in two steps. [FIPS 202] */
396 sha3_shake_init(&c, 128);
397 sha3_shake_process(&c, buf, sizeof(buf) / 2);
398 sha3_shake_process(&c, buf + sizeof(buf) / 2, sizeof(buf) / 2);
399 for (i = 0; i < 16; i++) sha3_shake_done(&c, hash, 32); /* get 512 bytes, keep in hash the last 32 */
400 if(XMEMCMP(shake128_0xa3_200_times, hash, sizeof(shake128_0xa3_200_times)) != 0) {
401 printf("SHAKE128( 0xa3 ... [200 times] ) failed (2 steps)\n");
402 return CRYPT_FAIL_TESTVECTOR;
403 }
404
405 /* SHAKE128 byte-by-byte: 200 steps. [FIPS 202] */
406 i = 200;
407 sha3_shake_init(&c, 128);
408 while (i--) sha3_shake_process(&c, &c1, 1);
409 for (i = 0; i < 16; i++) sha3_shake_done(&c, hash, 32); /* get 512 bytes, keep in hash the last 32 */
410 if(XMEMCMP(shake128_0xa3_200_times, hash, sizeof(shake128_0xa3_200_times)) != 0) {
411 printf("SHAKE128( 0xa3 ... [200 times] ) failed (200 steps)\n");
412 return CRYPT_FAIL_TESTVECTOR;
413 }
414
415 return CRYPT_OK;
416 #endif
417 }
418
419 #endif
44
55 plan skip_all => "File::Find not installed" unless eval { require File::Find };
66 plan skip_all => "Test::Pod not installed" unless eval { require Test::Pod };
7 plan tests => 77;
7 plan tests => 81;
88
99 my @files;
1010 File::Find::find({ wanted=>sub { push @files, $_ if /\.pm$/ }, no_chdir=>1 }, 'lib');
0 ### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
1
2 use strict;
3 use warnings;
4
5 use Test::More tests => 8*3 + 9*4 + 6;
6
7 use Crypt::Digest qw( digest_data digest_data_hex digest_data_b64 digest_data_b64u digest_file digest_file_hex digest_file_b64 digest_file_b64u );
8 use Crypt::Digest::SHA3_224 qw( sha3_224 sha3_224_hex sha3_224_b64 sha3_224_b64u sha3_224_file sha3_224_file_hex sha3_224_file_b64 sha3_224_file_b64u );
9
10 is( Crypt::Digest::hashsize('SHA3_224'), 28, 'hashsize/1');
11 is( Crypt::Digest->hashsize('SHA3_224'), 28, 'hashsize/2');
12 is( Crypt::Digest::SHA3_224::hashsize, 28, 'hashsize/3');
13 is( Crypt::Digest::SHA3_224->hashsize, 28, 'hashsize/4');
14 is( Crypt::Digest->new('SHA3_224')->hashsize, 28, 'hashsize/5');
15 is( Crypt::Digest::SHA3_224->new->hashsize, 28, 'hashsize/6');
16
17
18 is( sha3_224(""), pack("H*","6b4e03423667dbb73b6e15454f0eb1abd4597f9a1b078e3f5b5a6bc7"), 'sha3_224 (raw/1)');
19 is( sha3_224_hex(""), "6b4e03423667dbb73b6e15454f0eb1abd4597f9a1b078e3f5b5a6bc7", 'sha3_224 (hex/1)');
20 is( sha3_224_b64(""), "a04DQjZn27c7bhVFTw6xq9RZf5obB44/W1prxw==", 'sha3_224 (base64/1)');
21 is( digest_data('SHA3_224', ""), pack("H*","6b4e03423667dbb73b6e15454f0eb1abd4597f9a1b078e3f5b5a6bc7"), 'sha3_224 (digest_data_raw/1)');
22 is( digest_data_hex('SHA3_224', ""), "6b4e03423667dbb73b6e15454f0eb1abd4597f9a1b078e3f5b5a6bc7", 'sha3_224 (digest_data_hex/1)');
23 is( digest_data_b64('SHA3_224', ""), "a04DQjZn27c7bhVFTw6xq9RZf5obB44/W1prxw==", 'sha3_224 (digest_data_b64/1)');
24 is( digest_data_b64u('SHA3_224', ""), "a04DQjZn27c7bhVFTw6xq9RZf5obB44_W1prxw", 'sha3_224 (digest_data_b64u/1)');
25 is( Crypt::Digest::SHA3_224->new->add("")->hexdigest, "6b4e03423667dbb73b6e15454f0eb1abd4597f9a1b078e3f5b5a6bc7", 'sha3_224 (OO/1)');
26
27 is( sha3_224("123"), pack("H*","602bdc204140db016bee5374895e5568ce422fabe17e064061d80097"), 'sha3_224 (raw/2)');
28 is( sha3_224_hex("123"), "602bdc204140db016bee5374895e5568ce422fabe17e064061d80097", 'sha3_224 (hex/2)');
29 is( sha3_224_b64("123"), "YCvcIEFA2wFr7lN0iV5VaM5CL6vhfgZAYdgAlw==", 'sha3_224 (base64/2)');
30 is( digest_data('SHA3_224', "123"), pack("H*","602bdc204140db016bee5374895e5568ce422fabe17e064061d80097"), 'sha3_224 (digest_data_raw/2)');
31 is( digest_data_hex('SHA3_224', "123"), "602bdc204140db016bee5374895e5568ce422fabe17e064061d80097", 'sha3_224 (digest_data_hex/2)');
32 is( digest_data_b64('SHA3_224', "123"), "YCvcIEFA2wFr7lN0iV5VaM5CL6vhfgZAYdgAlw==", 'sha3_224 (digest_data_b64/2)');
33 is( digest_data_b64u('SHA3_224', "123"), "YCvcIEFA2wFr7lN0iV5VaM5CL6vhfgZAYdgAlw", 'sha3_224 (digest_data_b64u/2)');
34 is( Crypt::Digest::SHA3_224->new->add("123")->hexdigest, "602bdc204140db016bee5374895e5568ce422fabe17e064061d80097", 'sha3_224 (OO/2)');
35
36 is( sha3_224("test\0test\0test\n"), pack("H*","ae786c2326ad35c1d50654029e54c298755324aaa152899efd443654"), 'sha3_224 (raw/3)');
37 is( sha3_224_hex("test\0test\0test\n"), "ae786c2326ad35c1d50654029e54c298755324aaa152899efd443654", 'sha3_224 (hex/3)');
38 is( sha3_224_b64("test\0test\0test\n"), "rnhsIyatNcHVBlQCnlTCmHVTJKqhUome/UQ2VA==", 'sha3_224 (base64/3)');
39 is( digest_data('SHA3_224', "test\0test\0test\n"), pack("H*","ae786c2326ad35c1d50654029e54c298755324aaa152899efd443654"), 'sha3_224 (digest_data_raw/3)');
40 is( digest_data_hex('SHA3_224', "test\0test\0test\n"), "ae786c2326ad35c1d50654029e54c298755324aaa152899efd443654", 'sha3_224 (digest_data_hex/3)');
41 is( digest_data_b64('SHA3_224', "test\0test\0test\n"), "rnhsIyatNcHVBlQCnlTCmHVTJKqhUome/UQ2VA==", 'sha3_224 (digest_data_b64/3)');
42 is( digest_data_b64u('SHA3_224', "test\0test\0test\n"), "rnhsIyatNcHVBlQCnlTCmHVTJKqhUome_UQ2VA", 'sha3_224 (digest_data_b64u/3)');
43 is( Crypt::Digest::SHA3_224->new->add("test\0test\0test\n")->hexdigest, "ae786c2326ad35c1d50654029e54c298755324aaa152899efd443654", 'sha3_224 (OO/3)');
44
45
46 is( sha3_224_file('t/data/binary-test.file'), pack("H*","823fba21c0ccbbc12d683cb97707da3a9d8a73f019397d1d61052e85"), 'sha3_224 (raw/file/1)');
47 is( sha3_224_file_hex('t/data/binary-test.file'), "823fba21c0ccbbc12d683cb97707da3a9d8a73f019397d1d61052e85", 'sha3_224 (hex/file/1)');
48 is( sha3_224_file_b64('t/data/binary-test.file'), "gj+6IcDMu8EtaDy5dwfaOp2Kc/AZOX0dYQUuhQ==", 'sha3_224 (base64/file/1)');
49 is( digest_file('SHA3_224', 't/data/binary-test.file'), pack("H*","823fba21c0ccbbc12d683cb97707da3a9d8a73f019397d1d61052e85"), 'sha3_224 (digest_file_raw/file/1)');
50 is( digest_file_hex('SHA3_224', 't/data/binary-test.file'), "823fba21c0ccbbc12d683cb97707da3a9d8a73f019397d1d61052e85", 'sha3_224 (digest_file_hex/file/1)');
51 is( digest_file_b64('SHA3_224', 't/data/binary-test.file'), "gj+6IcDMu8EtaDy5dwfaOp2Kc/AZOX0dYQUuhQ==", 'sha3_224 (digest_file_b64/file/1)');
52 is( digest_file_b64u('SHA3_224', 't/data/binary-test.file'), "gj-6IcDMu8EtaDy5dwfaOp2Kc_AZOX0dYQUuhQ", 'sha3_224 (digest_file_b64u/file/1)');
53 is( Crypt::Digest::SHA3_224->new->addfile('t/data/binary-test.file')->hexdigest, "823fba21c0ccbbc12d683cb97707da3a9d8a73f019397d1d61052e85", 'sha3_224 (OO/file/1)');
54 {
55 open(my $fh, '<', 't/data/binary-test.file');
56 binmode($fh);
57 is( Crypt::Digest::SHA3_224->new->addfile($fh)->hexdigest, "823fba21c0ccbbc12d683cb97707da3a9d8a73f019397d1d61052e85", 'sha3_224 (OO/filehandle/1)');
58 close($fh);
59 }
60
61 is( sha3_224_file('t/data/text-CR.file'), pack("H*","2a7677578a2130ff1234c62d459822fe6256e331dc2f92b1de0ff354"), 'sha3_224 (raw/file/2)');
62 is( sha3_224_file_hex('t/data/text-CR.file'), "2a7677578a2130ff1234c62d459822fe6256e331dc2f92b1de0ff354", 'sha3_224 (hex/file/2)');
63 is( sha3_224_file_b64('t/data/text-CR.file'), "KnZ3V4ohMP8SNMYtRZgi/mJW4zHcL5Kx3g/zVA==", 'sha3_224 (base64/file/2)');
64 is( digest_file('SHA3_224', 't/data/text-CR.file'), pack("H*","2a7677578a2130ff1234c62d459822fe6256e331dc2f92b1de0ff354"), 'sha3_224 (digest_file_raw/file/2)');
65 is( digest_file_hex('SHA3_224', 't/data/text-CR.file'), "2a7677578a2130ff1234c62d459822fe6256e331dc2f92b1de0ff354", 'sha3_224 (digest_file_hex/file/2)');
66 is( digest_file_b64('SHA3_224', 't/data/text-CR.file'), "KnZ3V4ohMP8SNMYtRZgi/mJW4zHcL5Kx3g/zVA==", 'sha3_224 (digest_file_b64/file/2)');
67 is( digest_file_b64u('SHA3_224', 't/data/text-CR.file'), "KnZ3V4ohMP8SNMYtRZgi_mJW4zHcL5Kx3g_zVA", 'sha3_224 (digest_file_b64u/file/2)');
68 is( Crypt::Digest::SHA3_224->new->addfile('t/data/text-CR.file')->hexdigest, "2a7677578a2130ff1234c62d459822fe6256e331dc2f92b1de0ff354", 'sha3_224 (OO/file/2)');
69 {
70 open(my $fh, '<', 't/data/text-CR.file');
71 binmode($fh);
72 is( Crypt::Digest::SHA3_224->new->addfile($fh)->hexdigest, "2a7677578a2130ff1234c62d459822fe6256e331dc2f92b1de0ff354", 'sha3_224 (OO/filehandle/2)');
73 close($fh);
74 }
75
76 is( sha3_224_file('t/data/text-CRLF.file'), pack("H*","4276e835b367eed68ebe210d28953828d2995c847f1d35de5de57a5c"), 'sha3_224 (raw/file/3)');
77 is( sha3_224_file_hex('t/data/text-CRLF.file'), "4276e835b367eed68ebe210d28953828d2995c847f1d35de5de57a5c", 'sha3_224 (hex/file/3)');
78 is( sha3_224_file_b64('t/data/text-CRLF.file'), "QnboNbNn7taOviENKJU4KNKZXIR/HTXeXeV6XA==", 'sha3_224 (base64/file/3)');
79 is( digest_file('SHA3_224', 't/data/text-CRLF.file'), pack("H*","4276e835b367eed68ebe210d28953828d2995c847f1d35de5de57a5c"), 'sha3_224 (digest_file_raw/file/3)');
80 is( digest_file_hex('SHA3_224', 't/data/text-CRLF.file'), "4276e835b367eed68ebe210d28953828d2995c847f1d35de5de57a5c", 'sha3_224 (digest_file_hex/file/3)');
81 is( digest_file_b64('SHA3_224', 't/data/text-CRLF.file'), "QnboNbNn7taOviENKJU4KNKZXIR/HTXeXeV6XA==", 'sha3_224 (digest_file_b64/file/3)');
82 is( digest_file_b64u('SHA3_224', 't/data/text-CRLF.file'), "QnboNbNn7taOviENKJU4KNKZXIR_HTXeXeV6XA", 'sha3_224 (digest_file_b64u/file/3)');
83 is( Crypt::Digest::SHA3_224->new->addfile('t/data/text-CRLF.file')->hexdigest, "4276e835b367eed68ebe210d28953828d2995c847f1d35de5de57a5c", 'sha3_224 (OO/file/3)');
84 {
85 open(my $fh, '<', 't/data/text-CRLF.file');
86 binmode($fh);
87 is( Crypt::Digest::SHA3_224->new->addfile($fh)->hexdigest, "4276e835b367eed68ebe210d28953828d2995c847f1d35de5de57a5c", 'sha3_224 (OO/filehandle/3)');
88 close($fh);
89 }
90
91 is( sha3_224_file('t/data/text-LF.file'), pack("H*","a5d86974b60e7f6c022f0a7dc6409aabb4c9d21a93665dfe1220802f"), 'sha3_224 (raw/file/4)');
92 is( sha3_224_file_hex('t/data/text-LF.file'), "a5d86974b60e7f6c022f0a7dc6409aabb4c9d21a93665dfe1220802f", 'sha3_224 (hex/file/4)');
93 is( sha3_224_file_b64('t/data/text-LF.file'), "pdhpdLYOf2wCLwp9xkCaq7TJ0hqTZl3+EiCALw==", 'sha3_224 (base64/file/4)');
94 is( digest_file('SHA3_224', 't/data/text-LF.file'), pack("H*","a5d86974b60e7f6c022f0a7dc6409aabb4c9d21a93665dfe1220802f"), 'sha3_224 (digest_file_raw/file/4)');
95 is( digest_file_hex('SHA3_224', 't/data/text-LF.file'), "a5d86974b60e7f6c022f0a7dc6409aabb4c9d21a93665dfe1220802f", 'sha3_224 (digest_file_hex/file/4)');
96 is( digest_file_b64('SHA3_224', 't/data/text-LF.file'), "pdhpdLYOf2wCLwp9xkCaq7TJ0hqTZl3+EiCALw==", 'sha3_224 (digest_file_b64/file/4)');
97 is( digest_file_b64u('SHA3_224', 't/data/text-LF.file'), "pdhpdLYOf2wCLwp9xkCaq7TJ0hqTZl3-EiCALw", 'sha3_224 (digest_file_b64u/file/4)');
98 is( Crypt::Digest::SHA3_224->new->addfile('t/data/text-LF.file')->hexdigest, "a5d86974b60e7f6c022f0a7dc6409aabb4c9d21a93665dfe1220802f", 'sha3_224 (OO/file/4)');
99 {
100 open(my $fh, '<', 't/data/text-LF.file');
101 binmode($fh);
102 is( Crypt::Digest::SHA3_224->new->addfile($fh)->hexdigest, "a5d86974b60e7f6c022f0a7dc6409aabb4c9d21a93665dfe1220802f", 'sha3_224 (OO/filehandle/4)');
103 close($fh);
104 }
0 ### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
1
2 use strict;
3 use warnings;
4
5 use Test::More tests => 8*3 + 9*4 + 6;
6
7 use Crypt::Digest qw( digest_data digest_data_hex digest_data_b64 digest_data_b64u digest_file digest_file_hex digest_file_b64 digest_file_b64u );
8 use Crypt::Digest::SHA3_256 qw( sha3_256 sha3_256_hex sha3_256_b64 sha3_256_b64u sha3_256_file sha3_256_file_hex sha3_256_file_b64 sha3_256_file_b64u );
9
10 is( Crypt::Digest::hashsize('SHA3_256'), 32, 'hashsize/1');
11 is( Crypt::Digest->hashsize('SHA3_256'), 32, 'hashsize/2');
12 is( Crypt::Digest::SHA3_256::hashsize, 32, 'hashsize/3');
13 is( Crypt::Digest::SHA3_256->hashsize, 32, 'hashsize/4');
14 is( Crypt::Digest->new('SHA3_256')->hashsize, 32, 'hashsize/5');
15 is( Crypt::Digest::SHA3_256->new->hashsize, 32, 'hashsize/6');
16
17
18 is( sha3_256(""), pack("H*","a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a"), 'sha3_256 (raw/1)');
19 is( sha3_256_hex(""), "a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a", 'sha3_256 (hex/1)');
20 is( sha3_256_b64(""), "p//G+L8e12ZRwUdWoGHWYvWA/03kO0n6gtgKS4D4Q0o=", 'sha3_256 (base64/1)');
21 is( digest_data('SHA3_256', ""), pack("H*","a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a"), 'sha3_256 (digest_data_raw/1)');
22 is( digest_data_hex('SHA3_256', ""), "a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a", 'sha3_256 (digest_data_hex/1)');
23 is( digest_data_b64('SHA3_256', ""), "p//G+L8e12ZRwUdWoGHWYvWA/03kO0n6gtgKS4D4Q0o=", 'sha3_256 (digest_data_b64/1)');
24 is( digest_data_b64u('SHA3_256', ""), "p__G-L8e12ZRwUdWoGHWYvWA_03kO0n6gtgKS4D4Q0o", 'sha3_256 (digest_data_b64u/1)');
25 is( Crypt::Digest::SHA3_256->new->add("")->hexdigest, "a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a", 'sha3_256 (OO/1)');
26
27 is( sha3_256("123"), pack("H*","a03ab19b866fc585b5cb1812a2f63ca861e7e7643ee5d43fd7106b623725fd67"), 'sha3_256 (raw/2)');
28 is( sha3_256_hex("123"), "a03ab19b866fc585b5cb1812a2f63ca861e7e7643ee5d43fd7106b623725fd67", 'sha3_256 (hex/2)');
29 is( sha3_256_b64("123"), "oDqxm4ZvxYW1yxgSovY8qGHn52Q+5dQ/1xBrYjcl/Wc=", 'sha3_256 (base64/2)');
30 is( digest_data('SHA3_256', "123"), pack("H*","a03ab19b866fc585b5cb1812a2f63ca861e7e7643ee5d43fd7106b623725fd67"), 'sha3_256 (digest_data_raw/2)');
31 is( digest_data_hex('SHA3_256', "123"), "a03ab19b866fc585b5cb1812a2f63ca861e7e7643ee5d43fd7106b623725fd67", 'sha3_256 (digest_data_hex/2)');
32 is( digest_data_b64('SHA3_256', "123"), "oDqxm4ZvxYW1yxgSovY8qGHn52Q+5dQ/1xBrYjcl/Wc=", 'sha3_256 (digest_data_b64/2)');
33 is( digest_data_b64u('SHA3_256', "123"), "oDqxm4ZvxYW1yxgSovY8qGHn52Q-5dQ_1xBrYjcl_Wc", 'sha3_256 (digest_data_b64u/2)');
34 is( Crypt::Digest::SHA3_256->new->add("123")->hexdigest, "a03ab19b866fc585b5cb1812a2f63ca861e7e7643ee5d43fd7106b623725fd67", 'sha3_256 (OO/2)');
35
36 is( sha3_256("test\0test\0test\n"), pack("H*","fb08b084e0cff0f17d0d7054aaed12269d2fa08e4c770c4ad497d4f0372f7963"), 'sha3_256 (raw/3)');
37 is( sha3_256_hex("test\0test\0test\n"), "fb08b084e0cff0f17d0d7054aaed12269d2fa08e4c770c4ad497d4f0372f7963", 'sha3_256 (hex/3)');
38 is( sha3_256_b64("test\0test\0test\n"), "+wiwhODP8PF9DXBUqu0SJp0voI5MdwxK1JfU8DcveWM=", 'sha3_256 (base64/3)');
39 is( digest_data('SHA3_256', "test\0test\0test\n"), pack("H*","fb08b084e0cff0f17d0d7054aaed12269d2fa08e4c770c4ad497d4f0372f7963"), 'sha3_256 (digest_data_raw/3)');
40 is( digest_data_hex('SHA3_256', "test\0test\0test\n"), "fb08b084e0cff0f17d0d7054aaed12269d2fa08e4c770c4ad497d4f0372f7963", 'sha3_256 (digest_data_hex/3)');
41 is( digest_data_b64('SHA3_256', "test\0test\0test\n"), "+wiwhODP8PF9DXBUqu0SJp0voI5MdwxK1JfU8DcveWM=", 'sha3_256 (digest_data_b64/3)');
42 is( digest_data_b64u('SHA3_256', "test\0test\0test\n"), "-wiwhODP8PF9DXBUqu0SJp0voI5MdwxK1JfU8DcveWM", 'sha3_256 (digest_data_b64u/3)');
43 is( Crypt::Digest::SHA3_256->new->add("test\0test\0test\n")->hexdigest, "fb08b084e0cff0f17d0d7054aaed12269d2fa08e4c770c4ad497d4f0372f7963", 'sha3_256 (OO/3)');
44
45
46 is( sha3_256_file('t/data/binary-test.file'), pack("H*","9c5d0157abcd78eb1ee4e8bed8e03b8fae2c9a3f98a09ec28eb76d1ae2a9abd4"), 'sha3_256 (raw/file/1)');
47 is( sha3_256_file_hex('t/data/binary-test.file'), "9c5d0157abcd78eb1ee4e8bed8e03b8fae2c9a3f98a09ec28eb76d1ae2a9abd4", 'sha3_256 (hex/file/1)');
48 is( sha3_256_file_b64('t/data/binary-test.file'), "nF0BV6vNeOse5Oi+2OA7j64smj+YoJ7CjrdtGuKpq9Q=", 'sha3_256 (base64/file/1)');
49 is( digest_file('SHA3_256', 't/data/binary-test.file'), pack("H*","9c5d0157abcd78eb1ee4e8bed8e03b8fae2c9a3f98a09ec28eb76d1ae2a9abd4"), 'sha3_256 (digest_file_raw/file/1)');
50 is( digest_file_hex('SHA3_256', 't/data/binary-test.file'), "9c5d0157abcd78eb1ee4e8bed8e03b8fae2c9a3f98a09ec28eb76d1ae2a9abd4", 'sha3_256 (digest_file_hex/file/1)');
51 is( digest_file_b64('SHA3_256', 't/data/binary-test.file'), "nF0BV6vNeOse5Oi+2OA7j64smj+YoJ7CjrdtGuKpq9Q=", 'sha3_256 (digest_file_b64/file/1)');
52 is( digest_file_b64u('SHA3_256', 't/data/binary-test.file'), "nF0BV6vNeOse5Oi-2OA7j64smj-YoJ7CjrdtGuKpq9Q", 'sha3_256 (digest_file_b64u/file/1)');
53 is( Crypt::Digest::SHA3_256->new->addfile('t/data/binary-test.file')->hexdigest, "9c5d0157abcd78eb1ee4e8bed8e03b8fae2c9a3f98a09ec28eb76d1ae2a9abd4", 'sha3_256 (OO/file/1)');
54 {
55 open(my $fh, '<', 't/data/binary-test.file');
56 binmode($fh);
57 is( Crypt::Digest::SHA3_256->new->addfile($fh)->hexdigest, "9c5d0157abcd78eb1ee4e8bed8e03b8fae2c9a3f98a09ec28eb76d1ae2a9abd4", 'sha3_256 (OO/filehandle/1)');
58 close($fh);
59 }
60
61 is( sha3_256_file('t/data/text-CR.file'), pack("H*","56a1545cf3f7c35466f9587ab44569312ae9139724036fc098d716cedfb16475"), 'sha3_256 (raw/file/2)');
62 is( sha3_256_file_hex('t/data/text-CR.file'), "56a1545cf3f7c35466f9587ab44569312ae9139724036fc098d716cedfb16475", 'sha3_256 (hex/file/2)');
63 is( sha3_256_file_b64('t/data/text-CR.file'), "VqFUXPP3w1Rm+Vh6tEVpMSrpE5ckA2/AmNcWzt+xZHU=", 'sha3_256 (base64/file/2)');
64 is( digest_file('SHA3_256', 't/data/text-CR.file'), pack("H*","56a1545cf3f7c35466f9587ab44569312ae9139724036fc098d716cedfb16475"), 'sha3_256 (digest_file_raw/file/2)');
65 is( digest_file_hex('SHA3_256', 't/data/text-CR.file'), "56a1545cf3f7c35466f9587ab44569312ae9139724036fc098d716cedfb16475", 'sha3_256 (digest_file_hex/file/2)');
66 is( digest_file_b64('SHA3_256', 't/data/text-CR.file'), "VqFUXPP3w1Rm+Vh6tEVpMSrpE5ckA2/AmNcWzt+xZHU=", 'sha3_256 (digest_file_b64/file/2)');
67 is( digest_file_b64u('SHA3_256', 't/data/text-CR.file'), "VqFUXPP3w1Rm-Vh6tEVpMSrpE5ckA2_AmNcWzt-xZHU", 'sha3_256 (digest_file_b64u/file/2)');
68 is( Crypt::Digest::SHA3_256->new->addfile('t/data/text-CR.file')->hexdigest, "56a1545cf3f7c35466f9587ab44569312ae9139724036fc098d716cedfb16475", 'sha3_256 (OO/file/2)');
69 {
70 open(my $fh, '<', 't/data/text-CR.file');
71 binmode($fh);
72 is( Crypt::Digest::SHA3_256->new->addfile($fh)->hexdigest, "56a1545cf3f7c35466f9587ab44569312ae9139724036fc098d716cedfb16475", 'sha3_256 (OO/filehandle/2)');
73 close($fh);
74 }
75
76 is( sha3_256_file('t/data/text-CRLF.file'), pack("H*","82898a7bd59d89d4f09894d5d33add66ae5c1971c0fe229ca0371d7d22399f72"), 'sha3_256 (raw/file/3)');
77 is( sha3_256_file_hex('t/data/text-CRLF.file'), "82898a7bd59d89d4f09894d5d33add66ae5c1971c0fe229ca0371d7d22399f72", 'sha3_256 (hex/file/3)');
78 is( sha3_256_file_b64('t/data/text-CRLF.file'), "gomKe9WdidTwmJTV0zrdZq5cGXHA/iKcoDcdfSI5n3I=", 'sha3_256 (base64/file/3)');
79 is( digest_file('SHA3_256', 't/data/text-CRLF.file'), pack("H*","82898a7bd59d89d4f09894d5d33add66ae5c1971c0fe229ca0371d7d22399f72"), 'sha3_256 (digest_file_raw/file/3)');
80 is( digest_file_hex('SHA3_256', 't/data/text-CRLF.file'), "82898a7bd59d89d4f09894d5d33add66ae5c1971c0fe229ca0371d7d22399f72", 'sha3_256 (digest_file_hex/file/3)');
81 is( digest_file_b64('SHA3_256', 't/data/text-CRLF.file'), "gomKe9WdidTwmJTV0zrdZq5cGXHA/iKcoDcdfSI5n3I=", 'sha3_256 (digest_file_b64/file/3)');
82 is( digest_file_b64u('SHA3_256', 't/data/text-CRLF.file'), "gomKe9WdidTwmJTV0zrdZq5cGXHA_iKcoDcdfSI5n3I", 'sha3_256 (digest_file_b64u/file/3)');
83 is( Crypt::Digest::SHA3_256->new->addfile('t/data/text-CRLF.file')->hexdigest, "82898a7bd59d89d4f09894d5d33add66ae5c1971c0fe229ca0371d7d22399f72", 'sha3_256 (OO/file/3)');
84 {
85 open(my $fh, '<', 't/data/text-CRLF.file');
86 binmode($fh);
87 is( Crypt::Digest::SHA3_256->new->addfile($fh)->hexdigest, "82898a7bd59d89d4f09894d5d33add66ae5c1971c0fe229ca0371d7d22399f72", 'sha3_256 (OO/filehandle/3)');
88 close($fh);
89 }
90
91 is( sha3_256_file('t/data/text-LF.file'), pack("H*","8218ef6dfb3282fbd0079c1a1d50e689cdf6e3046f2b9219cd21e4d3513048b7"), 'sha3_256 (raw/file/4)');
92 is( sha3_256_file_hex('t/data/text-LF.file'), "8218ef6dfb3282fbd0079c1a1d50e689cdf6e3046f2b9219cd21e4d3513048b7", 'sha3_256 (hex/file/4)');
93 is( sha3_256_file_b64('t/data/text-LF.file'), "ghjvbfsygvvQB5waHVDmic324wRvK5IZzSHk01EwSLc=", 'sha3_256 (base64/file/4)');
94 is( digest_file('SHA3_256', 't/data/text-LF.file'), pack("H*","8218ef6dfb3282fbd0079c1a1d50e689cdf6e3046f2b9219cd21e4d3513048b7"), 'sha3_256 (digest_file_raw/file/4)');
95 is( digest_file_hex('SHA3_256', 't/data/text-LF.file'), "8218ef6dfb3282fbd0079c1a1d50e689cdf6e3046f2b9219cd21e4d3513048b7", 'sha3_256 (digest_file_hex/file/4)');
96 is( digest_file_b64('SHA3_256', 't/data/text-LF.file'), "ghjvbfsygvvQB5waHVDmic324wRvK5IZzSHk01EwSLc=", 'sha3_256 (digest_file_b64/file/4)');
97 is( digest_file_b64u('SHA3_256', 't/data/text-LF.file'), "ghjvbfsygvvQB5waHVDmic324wRvK5IZzSHk01EwSLc", 'sha3_256 (digest_file_b64u/file/4)');
98 is( Crypt::Digest::SHA3_256->new->addfile('t/data/text-LF.file')->hexdigest, "8218ef6dfb3282fbd0079c1a1d50e689cdf6e3046f2b9219cd21e4d3513048b7", 'sha3_256 (OO/file/4)');
99 {
100 open(my $fh, '<', 't/data/text-LF.file');
101 binmode($fh);
102 is( Crypt::Digest::SHA3_256->new->addfile($fh)->hexdigest, "8218ef6dfb3282fbd0079c1a1d50e689cdf6e3046f2b9219cd21e4d3513048b7", 'sha3_256 (OO/filehandle/4)');
103 close($fh);
104 }
0 ### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
1
2 use strict;
3 use warnings;
4
5 use Test::More tests => 8*3 + 9*4 + 6;
6
7 use Crypt::Digest qw( digest_data digest_data_hex digest_data_b64 digest_data_b64u digest_file digest_file_hex digest_file_b64 digest_file_b64u );
8 use Crypt::Digest::SHA3_384 qw( sha3_384 sha3_384_hex sha3_384_b64 sha3_384_b64u sha3_384_file sha3_384_file_hex sha3_384_file_b64 sha3_384_file_b64u );
9
10 is( Crypt::Digest::hashsize('SHA3_384'), 48, 'hashsize/1');
11 is( Crypt::Digest->hashsize('SHA3_384'), 48, 'hashsize/2');
12 is( Crypt::Digest::SHA3_384::hashsize, 48, 'hashsize/3');
13 is( Crypt::Digest::SHA3_384->hashsize, 48, 'hashsize/4');
14 is( Crypt::Digest->new('SHA3_384')->hashsize, 48, 'hashsize/5');
15 is( Crypt::Digest::SHA3_384->new->hashsize, 48, 'hashsize/6');
16
17
18 is( sha3_384(""), pack("H*","0c63a75b845e4f7d01107d852e4c2485c51a50aaaa94fc61995e71bbee983a2ac3713831264adb47fb6bd1e058d5f004"), 'sha3_384 (raw/1)');
19 is( sha3_384_hex(""), "0c63a75b845e4f7d01107d852e4c2485c51a50aaaa94fc61995e71bbee983a2ac3713831264adb47fb6bd1e058d5f004", 'sha3_384 (hex/1)');
20 is( sha3_384_b64(""), "DGOnW4ReT30BEH2FLkwkhcUaUKqqlPxhmV5xu+6YOirDcTgxJkrbR/tr0eBY1fAE", 'sha3_384 (base64/1)');
21 is( digest_data('SHA3_384', ""), pack("H*","0c63a75b845e4f7d01107d852e4c2485c51a50aaaa94fc61995e71bbee983a2ac3713831264adb47fb6bd1e058d5f004"), 'sha3_384 (digest_data_raw/1)');
22 is( digest_data_hex('SHA3_384', ""), "0c63a75b845e4f7d01107d852e4c2485c51a50aaaa94fc61995e71bbee983a2ac3713831264adb47fb6bd1e058d5f004", 'sha3_384 (digest_data_hex/1)');
23 is( digest_data_b64('SHA3_384', ""), "DGOnW4ReT30BEH2FLkwkhcUaUKqqlPxhmV5xu+6YOirDcTgxJkrbR/tr0eBY1fAE", 'sha3_384 (digest_data_b64/1)');
24 is( digest_data_b64u('SHA3_384', ""), "DGOnW4ReT30BEH2FLkwkhcUaUKqqlPxhmV5xu-6YOirDcTgxJkrbR_tr0eBY1fAE", 'sha3_384 (digest_data_b64u/1)');
25 is( Crypt::Digest::SHA3_384->new->add("")->hexdigest, "0c63a75b845e4f7d01107d852e4c2485c51a50aaaa94fc61995e71bbee983a2ac3713831264adb47fb6bd1e058d5f004", 'sha3_384 (OO/1)');
26
27 is( sha3_384("123"), pack("H*","9bd942d1678a25d029b114306f5e1dae49fe8abeeacd03cfab0f156aa2e363c988b1c12803d4a8c9ba38fdc873e5f007"), 'sha3_384 (raw/2)');
28 is( sha3_384_hex("123"), "9bd942d1678a25d029b114306f5e1dae49fe8abeeacd03cfab0f156aa2e363c988b1c12803d4a8c9ba38fdc873e5f007", 'sha3_384 (hex/2)');
29 is( sha3_384_b64("123"), "m9lC0WeKJdApsRQwb14drkn+ir7qzQPPqw8VaqLjY8mIscEoA9Soybo4/chz5fAH", 'sha3_384 (base64/2)');
30 is( digest_data('SHA3_384', "123"), pack("H*","9bd942d1678a25d029b114306f5e1dae49fe8abeeacd03cfab0f156aa2e363c988b1c12803d4a8c9ba38fdc873e5f007"), 'sha3_384 (digest_data_raw/2)');
31 is( digest_data_hex('SHA3_384', "123"), "9bd942d1678a25d029b114306f5e1dae49fe8abeeacd03cfab0f156aa2e363c988b1c12803d4a8c9ba38fdc873e5f007", 'sha3_384 (digest_data_hex/2)');
32 is( digest_data_b64('SHA3_384', "123"), "m9lC0WeKJdApsRQwb14drkn+ir7qzQPPqw8VaqLjY8mIscEoA9Soybo4/chz5fAH", 'sha3_384 (digest_data_b64/2)');
33 is( digest_data_b64u('SHA3_384', "123"), "m9lC0WeKJdApsRQwb14drkn-ir7qzQPPqw8VaqLjY8mIscEoA9Soybo4_chz5fAH", 'sha3_384 (digest_data_b64u/2)');
34 is( Crypt::Digest::SHA3_384->new->add("123")->hexdigest, "9bd942d1678a25d029b114306f5e1dae49fe8abeeacd03cfab0f156aa2e363c988b1c12803d4a8c9ba38fdc873e5f007", 'sha3_384 (OO/2)');
35
36 is( sha3_384("test\0test\0test\n"), pack("H*","69cf4f5bfec6ec9fc866208f6442dd3f140ad87d9b6092ab32624a462a6d3ab219e339b392b18596aec0520f770cd543"), 'sha3_384 (raw/3)');
37 is( sha3_384_hex("test\0test\0test\n"), "69cf4f5bfec6ec9fc866208f6442dd3f140ad87d9b6092ab32624a462a6d3ab219e339b392b18596aec0520f770cd543", 'sha3_384 (hex/3)');
38 is( sha3_384_b64("test\0test\0test\n"), "ac9PW/7G7J/IZiCPZELdPxQK2H2bYJKrMmJKRiptOrIZ4zmzkrGFlq7AUg93DNVD", 'sha3_384 (base64/3)');
39 is( digest_data('SHA3_384', "test\0test\0test\n"), pack("H*","69cf4f5bfec6ec9fc866208f6442dd3f140ad87d9b6092ab32624a462a6d3ab219e339b392b18596aec0520f770cd543"), 'sha3_384 (digest_data_raw/3)');
40 is( digest_data_hex('SHA3_384', "test\0test\0test\n"), "69cf4f5bfec6ec9fc866208f6442dd3f140ad87d9b6092ab32624a462a6d3ab219e339b392b18596aec0520f770cd543", 'sha3_384 (digest_data_hex/3)');
41 is( digest_data_b64('SHA3_384', "test\0test\0test\n"), "ac9PW/7G7J/IZiCPZELdPxQK2H2bYJKrMmJKRiptOrIZ4zmzkrGFlq7AUg93DNVD", 'sha3_384 (digest_data_b64/3)');
42 is( digest_data_b64u('SHA3_384', "test\0test\0test\n"), "ac9PW_7G7J_IZiCPZELdPxQK2H2bYJKrMmJKRiptOrIZ4zmzkrGFlq7AUg93DNVD", 'sha3_384 (digest_data_b64u/3)');
43 is( Crypt::Digest::SHA3_384->new->add("test\0test\0test\n")->hexdigest, "69cf4f5bfec6ec9fc866208f6442dd3f140ad87d9b6092ab32624a462a6d3ab219e339b392b18596aec0520f770cd543", 'sha3_384 (OO/3)');
44
45
46 is( sha3_384_file('t/data/binary-test.file'), pack("H*","d350769c1d1847a2ce4539429d06e3b715b5928d48353f7f1eefba6f76ae6299fb1bf36c2c2067ddb9645051a55279bd"), 'sha3_384 (raw/file/1)');
47 is( sha3_384_file_hex('t/data/binary-test.file'), "d350769c1d1847a2ce4539429d06e3b715b5928d48353f7f1eefba6f76ae6299fb1bf36c2c2067ddb9645051a55279bd", 'sha3_384 (hex/file/1)');
48 is( sha3_384_file_b64('t/data/binary-test.file'), "01B2nB0YR6LORTlCnQbjtxW1ko1INT9/Hu+6b3auYpn7G/NsLCBn3blkUFGlUnm9", 'sha3_384 (base64/file/1)');
49 is( digest_file('SHA3_384', 't/data/binary-test.file'), pack("H*","d350769c1d1847a2ce4539429d06e3b715b5928d48353f7f1eefba6f76ae6299fb1bf36c2c2067ddb9645051a55279bd"), 'sha3_384 (digest_file_raw/file/1)');
50 is( digest_file_hex('SHA3_384', 't/data/binary-test.file'), "d350769c1d1847a2ce4539429d06e3b715b5928d48353f7f1eefba6f76ae6299fb1bf36c2c2067ddb9645051a55279bd", 'sha3_384 (digest_file_hex/file/1)');
51 is( digest_file_b64('SHA3_384', 't/data/binary-test.file'), "01B2nB0YR6LORTlCnQbjtxW1ko1INT9/Hu+6b3auYpn7G/NsLCBn3blkUFGlUnm9", 'sha3_384 (digest_file_b64/file/1)');
52 is( digest_file_b64u('SHA3_384', 't/data/binary-test.file'), "01B2nB0YR6LORTlCnQbjtxW1ko1INT9_Hu-6b3auYpn7G_NsLCBn3blkUFGlUnm9", 'sha3_384 (digest_file_b64u/file/1)');
53 is( Crypt::Digest::SHA3_384->new->addfile('t/data/binary-test.file')->hexdigest, "d350769c1d1847a2ce4539429d06e3b715b5928d48353f7f1eefba6f76ae6299fb1bf36c2c2067ddb9645051a55279bd", 'sha3_384 (OO/file/1)');
54 {
55 open(my $fh, '<', 't/data/binary-test.file');
56 binmode($fh);
57 is( Crypt::Digest::SHA3_384->new->addfile($fh)->hexdigest, "d350769c1d1847a2ce4539429d06e3b715b5928d48353f7f1eefba6f76ae6299fb1bf36c2c2067ddb9645051a55279bd", 'sha3_384 (OO/filehandle/1)');
58 close($fh);
59 }
60
61 is( sha3_384_file('t/data/text-CR.file'), pack("H*","71245760e067c5f026d7a98e12cd3553e806781c3f5f751ec342af6cf8c12279f1a2cb3f7c3449c1e6f5f7c9d4d8b656"), 'sha3_384 (raw/file/2)');
62 is( sha3_384_file_hex('t/data/text-CR.file'), "71245760e067c5f026d7a98e12cd3553e806781c3f5f751ec342af6cf8c12279f1a2cb3f7c3449c1e6f5f7c9d4d8b656", 'sha3_384 (hex/file/2)');
63 is( sha3_384_file_b64('t/data/text-CR.file'), "cSRXYOBnxfAm16mOEs01U+gGeBw/X3Uew0KvbPjBInnxoss/fDRJweb198nU2LZW", 'sha3_384 (base64/file/2)');
64 is( digest_file('SHA3_384', 't/data/text-CR.file'), pack("H*","71245760e067c5f026d7a98e12cd3553e806781c3f5f751ec342af6cf8c12279f1a2cb3f7c3449c1e6f5f7c9d4d8b656"), 'sha3_384 (digest_file_raw/file/2)');
65 is( digest_file_hex('SHA3_384', 't/data/text-CR.file'), "71245760e067c5f026d7a98e12cd3553e806781c3f5f751ec342af6cf8c12279f1a2cb3f7c3449c1e6f5f7c9d4d8b656", 'sha3_384 (digest_file_hex/file/2)');
66 is( digest_file_b64('SHA3_384', 't/data/text-CR.file'), "cSRXYOBnxfAm16mOEs01U+gGeBw/X3Uew0KvbPjBInnxoss/fDRJweb198nU2LZW", 'sha3_384 (digest_file_b64/file/2)');
67 is( digest_file_b64u('SHA3_384', 't/data/text-CR.file'), "cSRXYOBnxfAm16mOEs01U-gGeBw_X3Uew0KvbPjBInnxoss_fDRJweb198nU2LZW", 'sha3_384 (digest_file_b64u/file/2)');
68 is( Crypt::Digest::SHA3_384->new->addfile('t/data/text-CR.file')->hexdigest, "71245760e067c5f026d7a98e12cd3553e806781c3f5f751ec342af6cf8c12279f1a2cb3f7c3449c1e6f5f7c9d4d8b656", 'sha3_384 (OO/file/2)');
69 {
70 open(my $fh, '<', 't/data/text-CR.file');
71 binmode($fh);
72 is( Crypt::Digest::SHA3_384->new->addfile($fh)->hexdigest, "71245760e067c5f026d7a98e12cd3553e806781c3f5f751ec342af6cf8c12279f1a2cb3f7c3449c1e6f5f7c9d4d8b656", 'sha3_384 (OO/filehandle/2)');
73 close($fh);
74 }
75
76 is( sha3_384_file('t/data/text-CRLF.file'), pack("H*","f3277f0def5a52c6237c2911d20ecfa8a434adcce900c70ce06e351d6c0fe08806ae1af0cf994725e08fcc00a33d38a5"), 'sha3_384 (raw/file/3)');
77 is( sha3_384_file_hex('t/data/text-CRLF.file'), "f3277f0def5a52c6237c2911d20ecfa8a434adcce900c70ce06e351d6c0fe08806ae1af0cf994725e08fcc00a33d38a5", 'sha3_384 (hex/file/3)');
78 is( sha3_384_file_b64('t/data/text-CRLF.file'), "8yd/De9aUsYjfCkR0g7PqKQ0rczpAMcM4G41HWwP4IgGrhrwz5lHJeCPzACjPTil", 'sha3_384 (base64/file/3)');
79 is( digest_file('SHA3_384', 't/data/text-CRLF.file'), pack("H*","f3277f0def5a52c6237c2911d20ecfa8a434adcce900c70ce06e351d6c0fe08806ae1af0cf994725e08fcc00a33d38a5"), 'sha3_384 (digest_file_raw/file/3)');
80 is( digest_file_hex('SHA3_384', 't/data/text-CRLF.file'), "f3277f0def5a52c6237c2911d20ecfa8a434adcce900c70ce06e351d6c0fe08806ae1af0cf994725e08fcc00a33d38a5", 'sha3_384 (digest_file_hex/file/3)');
81 is( digest_file_b64('SHA3_384', 't/data/text-CRLF.file'), "8yd/De9aUsYjfCkR0g7PqKQ0rczpAMcM4G41HWwP4IgGrhrwz5lHJeCPzACjPTil", 'sha3_384 (digest_file_b64/file/3)');
82 is( digest_file_b64u('SHA3_384', 't/data/text-CRLF.file'), "8yd_De9aUsYjfCkR0g7PqKQ0rczpAMcM4G41HWwP4IgGrhrwz5lHJeCPzACjPTil", 'sha3_384 (digest_file_b64u/file/3)');
83 is( Crypt::Digest::SHA3_384->new->addfile('t/data/text-CRLF.file')->hexdigest, "f3277f0def5a52c6237c2911d20ecfa8a434adcce900c70ce06e351d6c0fe08806ae1af0cf994725e08fcc00a33d38a5", 'sha3_384 (OO/file/3)');
84 {
85 open(my $fh, '<', 't/data/text-CRLF.file');
86 binmode($fh);
87 is( Crypt::Digest::SHA3_384->new->addfile($fh)->hexdigest, "f3277f0def5a52c6237c2911d20ecfa8a434adcce900c70ce06e351d6c0fe08806ae1af0cf994725e08fcc00a33d38a5", 'sha3_384 (OO/filehandle/3)');
88 close($fh);
89 }
90
91 is( sha3_384_file('t/data/text-LF.file'), pack("H*","06abb535191f6bb863cb800fba87ddd673f1db5bd42faa7851c689246fd6d03d184906e794df9ddbd27dece68c5dd6c9"), 'sha3_384 (raw/file/4)');
92 is( sha3_384_file_hex('t/data/text-LF.file'), "06abb535191f6bb863cb800fba87ddd673f1db5bd42faa7851c689246fd6d03d184906e794df9ddbd27dece68c5dd6c9", 'sha3_384 (hex/file/4)');
93 is( sha3_384_file_b64('t/data/text-LF.file'), "Bqu1NRkfa7hjy4APuofd1nPx21vUL6p4UcaJJG/W0D0YSQbnlN+d29J97OaMXdbJ", 'sha3_384 (base64/file/4)');
94 is( digest_file('SHA3_384', 't/data/text-LF.file'), pack("H*","06abb535191f6bb863cb800fba87ddd673f1db5bd42faa7851c689246fd6d03d184906e794df9ddbd27dece68c5dd6c9"), 'sha3_384 (digest_file_raw/file/4)');
95 is( digest_file_hex('SHA3_384', 't/data/text-LF.file'), "06abb535191f6bb863cb800fba87ddd673f1db5bd42faa7851c689246fd6d03d184906e794df9ddbd27dece68c5dd6c9", 'sha3_384 (digest_file_hex/file/4)');
96 is( digest_file_b64('SHA3_384', 't/data/text-LF.file'), "Bqu1NRkfa7hjy4APuofd1nPx21vUL6p4UcaJJG/W0D0YSQbnlN+d29J97OaMXdbJ", 'sha3_384 (digest_file_b64/file/4)');
97 is( digest_file_b64u('SHA3_384', 't/data/text-LF.file'), "Bqu1NRkfa7hjy4APuofd1nPx21vUL6p4UcaJJG_W0D0YSQbnlN-d29J97OaMXdbJ", 'sha3_384 (digest_file_b64u/file/4)');
98 is( Crypt::Digest::SHA3_384->new->addfile('t/data/text-LF.file')->hexdigest, "06abb535191f6bb863cb800fba87ddd673f1db5bd42faa7851c689246fd6d03d184906e794df9ddbd27dece68c5dd6c9", 'sha3_384 (OO/file/4)');
99 {
100 open(my $fh, '<', 't/data/text-LF.file');
101 binmode($fh);
102 is( Crypt::Digest::SHA3_384->new->addfile($fh)->hexdigest, "06abb535191f6bb863cb800fba87ddd673f1db5bd42faa7851c689246fd6d03d184906e794df9ddbd27dece68c5dd6c9", 'sha3_384 (OO/filehandle/4)');
103 close($fh);
104 }
0 ### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
1
2 use strict;
3 use warnings;
4
5 use Test::More tests => 8*3 + 9*4 + 6;
6
7 use Crypt::Digest qw( digest_data digest_data_hex digest_data_b64 digest_data_b64u digest_file digest_file_hex digest_file_b64 digest_file_b64u );
8 use Crypt::Digest::SHA3_512 qw( sha3_512 sha3_512_hex sha3_512_b64 sha3_512_b64u sha3_512_file sha3_512_file_hex sha3_512_file_b64 sha3_512_file_b64u );
9
10 is( Crypt::Digest::hashsize('SHA3_512'), 64, 'hashsize/1');
11 is( Crypt::Digest->hashsize('SHA3_512'), 64, 'hashsize/2');
12 is( Crypt::Digest::SHA3_512::hashsize, 64, 'hashsize/3');
13 is( Crypt::Digest::SHA3_512->hashsize, 64, 'hashsize/4');
14 is( Crypt::Digest->new('SHA3_512')->hashsize, 64, 'hashsize/5');
15 is( Crypt::Digest::SHA3_512->new->hashsize, 64, 'hashsize/6');
16
17
18 is( sha3_512(""), pack("H*","a69f73cca23a9ac5c8b567dc185a756e97c982164fe25859e0d1dcc1475c80a615b2123af1f5f94c11e3e9402c3ac558f500199d95b6d3e301758586281dcd26"), 'sha3_512 (raw/1)');
19 is( sha3_512_hex(""), "a69f73cca23a9ac5c8b567dc185a756e97c982164fe25859e0d1dcc1475c80a615b2123af1f5f94c11e3e9402c3ac558f500199d95b6d3e301758586281dcd26", 'sha3_512 (hex/1)');
20 is( sha3_512_b64(""), "pp9zzKI6msXItWfcGFp1bpfJghZP4lhZ4NHcwUdcgKYVshI68fX5TBHj6UAsOsVY9QAZnZW20+MBdYWGKB3NJg==", 'sha3_512 (base64/1)');
21 is( digest_data('SHA3_512', ""), pack("H*","a69f73cca23a9ac5c8b567dc185a756e97c982164fe25859e0d1dcc1475c80a615b2123af1f5f94c11e3e9402c3ac558f500199d95b6d3e301758586281dcd26"), 'sha3_512 (digest_data_raw/1)');
22 is( digest_data_hex('SHA3_512', ""), "a69f73cca23a9ac5c8b567dc185a756e97c982164fe25859e0d1dcc1475c80a615b2123af1f5f94c11e3e9402c3ac558f500199d95b6d3e301758586281dcd26", 'sha3_512 (digest_data_hex/1)');
23 is( digest_data_b64('SHA3_512', ""), "pp9zzKI6msXItWfcGFp1bpfJghZP4lhZ4NHcwUdcgKYVshI68fX5TBHj6UAsOsVY9QAZnZW20+MBdYWGKB3NJg==", 'sha3_512 (digest_data_b64/1)');
24 is( digest_data_b64u('SHA3_512', ""), "pp9zzKI6msXItWfcGFp1bpfJghZP4lhZ4NHcwUdcgKYVshI68fX5TBHj6UAsOsVY9QAZnZW20-MBdYWGKB3NJg", 'sha3_512 (digest_data_b64u/1)');
25 is( Crypt::Digest::SHA3_512->new->add("")->hexdigest, "a69f73cca23a9ac5c8b567dc185a756e97c982164fe25859e0d1dcc1475c80a615b2123af1f5f94c11e3e9402c3ac558f500199d95b6d3e301758586281dcd26", 'sha3_512 (OO/1)');
26
27 is( sha3_512("123"), pack("H*","48c8947f69c054a5caa934674ce8881d02bb18fb59d5a63eeaddff735b0e9801e87294783281ae49fc8287a0fd86779b27d7972d3e84f0fa0d826d7cb67dfefc"), 'sha3_512 (raw/2)');
28 is( sha3_512_hex("123"), "48c8947f69c054a5caa934674ce8881d02bb18fb59d5a63eeaddff735b0e9801e87294783281ae49fc8287a0fd86779b27d7972d3e84f0fa0d826d7cb67dfefc", 'sha3_512 (hex/2)');
29 is( sha3_512_b64("123"), "SMiUf2nAVKXKqTRnTOiIHQK7GPtZ1aY+6t3/c1sOmAHocpR4MoGuSfyCh6D9hnebJ9eXLT6E8PoNgm18tn3+/A==", 'sha3_512 (base64/2)');
30 is( digest_data('SHA3_512', "123"), pack("H*","48c8947f69c054a5caa934674ce8881d02bb18fb59d5a63eeaddff735b0e9801e87294783281ae49fc8287a0fd86779b27d7972d3e84f0fa0d826d7cb67dfefc"), 'sha3_512 (digest_data_raw/2)');
31 is( digest_data_hex('SHA3_512', "123"), "48c8947f69c054a5caa934674ce8881d02bb18fb59d5a63eeaddff735b0e9801e87294783281ae49fc8287a0fd86779b27d7972d3e84f0fa0d826d7cb67dfefc", 'sha3_512 (digest_data_hex/2)');
32 is( digest_data_b64('SHA3_512', "123"), "SMiUf2nAVKXKqTRnTOiIHQK7GPtZ1aY+6t3/c1sOmAHocpR4MoGuSfyCh6D9hnebJ9eXLT6E8PoNgm18tn3+/A==", 'sha3_512 (digest_data_b64/2)');
33 is( digest_data_b64u('SHA3_512', "123"), "SMiUf2nAVKXKqTRnTOiIHQK7GPtZ1aY-6t3_c1sOmAHocpR4MoGuSfyCh6D9hnebJ9eXLT6E8PoNgm18tn3-_A", 'sha3_512 (digest_data_b64u/2)');
34 is( Crypt::Digest::SHA3_512->new->add("123")->hexdigest, "48c8947f69c054a5caa934674ce8881d02bb18fb59d5a63eeaddff735b0e9801e87294783281ae49fc8287a0fd86779b27d7972d3e84f0fa0d826d7cb67dfefc", 'sha3_512 (OO/2)');
35
36 is( sha3_512("test\0test\0test\n"), pack("H*","32ae141bb6ed097396f3258e2d4d5b9d03901a1fd09b82ab753027d3f6806763cc50daa3c50ab077e2acb0b792995cb3b539e6ec0171e56b9c6635780e79f693"), 'sha3_512 (raw/3)');
37 is( sha3_512_hex("test\0test\0test\n"), "32ae141bb6ed097396f3258e2d4d5b9d03901a1fd09b82ab753027d3f6806763cc50daa3c50ab077e2acb0b792995cb3b539e6ec0171e56b9c6635780e79f693", 'sha3_512 (hex/3)');
38 is( sha3_512_b64("test\0test\0test\n"), "Mq4UG7btCXOW8yWOLU1bnQOQGh/Qm4KrdTAn0/aAZ2PMUNqjxQqwd+KssLeSmVyztTnm7AFx5WucZjV4Dnn2kw==", 'sha3_512 (base64/3)');
39 is( digest_data('SHA3_512', "test\0test\0test\n"), pack("H*","32ae141bb6ed097396f3258e2d4d5b9d03901a1fd09b82ab753027d3f6806763cc50daa3c50ab077e2acb0b792995cb3b539e6ec0171e56b9c6635780e79f693"), 'sha3_512 (digest_data_raw/3)');
40 is( digest_data_hex('SHA3_512', "test\0test\0test\n"), "32ae141bb6ed097396f3258e2d4d5b9d03901a1fd09b82ab753027d3f6806763cc50daa3c50ab077e2acb0b792995cb3b539e6ec0171e56b9c6635780e79f693", 'sha3_512 (digest_data_hex/3)');
41 is( digest_data_b64('SHA3_512', "test\0test\0test\n"), "Mq4UG7btCXOW8yWOLU1bnQOQGh/Qm4KrdTAn0/aAZ2PMUNqjxQqwd+KssLeSmVyztTnm7AFx5WucZjV4Dnn2kw==", 'sha3_512 (digest_data_b64/3)');
42 is( digest_data_b64u('SHA3_512', "test\0test\0test\n"), "Mq4UG7btCXOW8yWOLU1bnQOQGh_Qm4KrdTAn0_aAZ2PMUNqjxQqwd-KssLeSmVyztTnm7AFx5WucZjV4Dnn2kw", 'sha3_512 (digest_data_b64u/3)');
43 is( Crypt::Digest::SHA3_512->new->add("test\0test\0test\n")->hexdigest, "32ae141bb6ed097396f3258e2d4d5b9d03901a1fd09b82ab753027d3f6806763cc50daa3c50ab077e2acb0b792995cb3b539e6ec0171e56b9c6635780e79f693", 'sha3_512 (OO/3)');
44
45
46 is( sha3_512_file('t/data/binary-test.file'), pack("H*","1ac54b7f8bb2e36b90e796fc6435e5a5e97e4884e3e85c75eb51a0c45724843e63a508adc0ffaf3c9998e23de6b38c6293a8deaf9467a6b512b28c38f2801cef"), 'sha3_512 (raw/file/1)');
47 is( sha3_512_file_hex('t/data/binary-test.file'), "1ac54b7f8bb2e36b90e796fc6435e5a5e97e4884e3e85c75eb51a0c45724843e63a508adc0ffaf3c9998e23de6b38c6293a8deaf9467a6b512b28c38f2801cef", 'sha3_512 (hex/file/1)');
48 is( sha3_512_file_b64('t/data/binary-test.file'), "GsVLf4uy42uQ55b8ZDXlpel+SITj6Fx161GgxFckhD5jpQitwP+vPJmY4j3ms4xik6jer5RnprUSsow48oAc7w==", 'sha3_512 (base64/file/1)');
49 is( digest_file('SHA3_512', 't/data/binary-test.file'), pack("H*","1ac54b7f8bb2e36b90e796fc6435e5a5e97e4884e3e85c75eb51a0c45724843e63a508adc0ffaf3c9998e23de6b38c6293a8deaf9467a6b512b28c38f2801cef"), 'sha3_512 (digest_file_raw/file/1)');
50 is( digest_file_hex('SHA3_512', 't/data/binary-test.file'), "1ac54b7f8bb2e36b90e796fc6435e5a5e97e4884e3e85c75eb51a0c45724843e63a508adc0ffaf3c9998e23de6b38c6293a8deaf9467a6b512b28c38f2801cef", 'sha3_512 (digest_file_hex/file/1)');
51 is( digest_file_b64('SHA3_512', 't/data/binary-test.file'), "GsVLf4uy42uQ55b8ZDXlpel+SITj6Fx161GgxFckhD5jpQitwP+vPJmY4j3ms4xik6jer5RnprUSsow48oAc7w==", 'sha3_512 (digest_file_b64/file/1)');
52 is( digest_file_b64u('SHA3_512', 't/data/binary-test.file'), "GsVLf4uy42uQ55b8ZDXlpel-SITj6Fx161GgxFckhD5jpQitwP-vPJmY4j3ms4xik6jer5RnprUSsow48oAc7w", 'sha3_512 (digest_file_b64u/file/1)');
53 is( Crypt::Digest::SHA3_512->new->addfile('t/data/binary-test.file')->hexdigest, "1ac54b7f8bb2e36b90e796fc6435e5a5e97e4884e3e85c75eb51a0c45724843e63a508adc0ffaf3c9998e23de6b38c6293a8deaf9467a6b512b28c38f2801cef", 'sha3_512 (OO/file/1)');
54 {
55 open(my $fh, '<', 't/data/binary-test.file');
56 binmode($fh);
57 is( Crypt::Digest::SHA3_512->new->addfile($fh)->hexdigest, "1ac54b7f8bb2e36b90e796fc6435e5a5e97e4884e3e85c75eb51a0c45724843e63a508adc0ffaf3c9998e23de6b38c6293a8deaf9467a6b512b28c38f2801cef", 'sha3_512 (OO/filehandle/1)');
58 close($fh);
59 }
60
61 is( sha3_512_file('t/data/text-CR.file'), pack("H*","2537d084e27c839299a76b7f54e786f13eba94030c4adc5b254106212d2e1db2e6dd2bea0d785e6b3561713fb1677d28a5ec914c9d5360145606054b6576e0c1"), 'sha3_512 (raw/file/2)');
62 is( sha3_512_file_hex('t/data/text-CR.file'), "2537d084e27c839299a76b7f54e786f13eba94030c4adc5b254106212d2e1db2e6dd2bea0d785e6b3561713fb1677d28a5ec914c9d5360145606054b6576e0c1", 'sha3_512 (hex/file/2)');
63 is( sha3_512_file_b64('t/data/text-CR.file'), "JTfQhOJ8g5KZp2t/VOeG8T66lAMMStxbJUEGIS0uHbLm3SvqDXheazVhcT+xZ30opeyRTJ1TYBRWBgVLZXbgwQ==", 'sha3_512 (base64/file/2)');
64 is( digest_file('SHA3_512', 't/data/text-CR.file'), pack("H*","2537d084e27c839299a76b7f54e786f13eba94030c4adc5b254106212d2e1db2e6dd2bea0d785e6b3561713fb1677d28a5ec914c9d5360145606054b6576e0c1"), 'sha3_512 (digest_file_raw/file/2)');
65 is( digest_file_hex('SHA3_512', 't/data/text-CR.file'), "2537d084e27c839299a76b7f54e786f13eba94030c4adc5b254106212d2e1db2e6dd2bea0d785e6b3561713fb1677d28a5ec914c9d5360145606054b6576e0c1", 'sha3_512 (digest_file_hex/file/2)');
66 is( digest_file_b64('SHA3_512', 't/data/text-CR.file'), "JTfQhOJ8g5KZp2t/VOeG8T66lAMMStxbJUEGIS0uHbLm3SvqDXheazVhcT+xZ30opeyRTJ1TYBRWBgVLZXbgwQ==", 'sha3_512 (digest_file_b64/file/2)');
67 is( digest_file_b64u('SHA3_512', 't/data/text-CR.file'), "JTfQhOJ8g5KZp2t_VOeG8T66lAMMStxbJUEGIS0uHbLm3SvqDXheazVhcT-xZ30opeyRTJ1TYBRWBgVLZXbgwQ", 'sha3_512 (digest_file_b64u/file/2)');
68 is( Crypt::Digest::SHA3_512->new->addfile('t/data/text-CR.file')->hexdigest, "2537d084e27c839299a76b7f54e786f13eba94030c4adc5b254106212d2e1db2e6dd2bea0d785e6b3561713fb1677d28a5ec914c9d5360145606054b6576e0c1", 'sha3_512 (OO/file/2)');
69 {
70 open(my $fh, '<', 't/data/text-CR.file');
71 binmode($fh);
72 is( Crypt::Digest::SHA3_512->new->addfile($fh)->hexdigest, "2537d084e27c839299a76b7f54e786f13eba94030c4adc5b254106212d2e1db2e6dd2bea0d785e6b3561713fb1677d28a5ec914c9d5360145606054b6576e0c1", 'sha3_512 (OO/filehandle/2)');
73 close($fh);
74 }
75
76 is( sha3_512_file('t/data/text-CRLF.file'), pack("H*","2fceadea90f637c1e09802d9d4bb0799b95c17d51eff2e8db118d1f6fced01f43bdee512d4d6bf58727debcb80331a9939b683cf30496af67aa3095b517f11ed"), 'sha3_512 (raw/file/3)');
77 is( sha3_512_file_hex('t/data/text-CRLF.file'), "2fceadea90f637c1e09802d9d4bb0799b95c17d51eff2e8db118d1f6fced01f43bdee512d4d6bf58727debcb80331a9939b683cf30496af67aa3095b517f11ed", 'sha3_512 (hex/file/3)');
78 is( sha3_512_file_b64('t/data/text-CRLF.file'), "L86t6pD2N8HgmALZ1LsHmblcF9Ue/y6NsRjR9vztAfQ73uUS1Na/WHJ968uAMxqZObaDzzBJavZ6owlbUX8R7Q==", 'sha3_512 (base64/file/3)');
79 is( digest_file('SHA3_512', 't/data/text-CRLF.file'), pack("H*","2fceadea90f637c1e09802d9d4bb0799b95c17d51eff2e8db118d1f6fced01f43bdee512d4d6bf58727debcb80331a9939b683cf30496af67aa3095b517f11ed"), 'sha3_512 (digest_file_raw/file/3)');
80 is( digest_file_hex('SHA3_512', 't/data/text-CRLF.file'), "2fceadea90f637c1e09802d9d4bb0799b95c17d51eff2e8db118d1f6fced01f43bdee512d4d6bf58727debcb80331a9939b683cf30496af67aa3095b517f11ed", 'sha3_512 (digest_file_hex/file/3)');
81 is( digest_file_b64('SHA3_512', 't/data/text-CRLF.file'), "L86t6pD2N8HgmALZ1LsHmblcF9Ue/y6NsRjR9vztAfQ73uUS1Na/WHJ968uAMxqZObaDzzBJavZ6owlbUX8R7Q==", 'sha3_512 (digest_file_b64/file/3)');
82 is( digest_file_b64u('SHA3_512', 't/data/text-CRLF.file'), "L86t6pD2N8HgmALZ1LsHmblcF9Ue_y6NsRjR9vztAfQ73uUS1Na_WHJ968uAMxqZObaDzzBJavZ6owlbUX8R7Q", 'sha3_512 (digest_file_b64u/file/3)');
83 is( Crypt::Digest::SHA3_512->new->addfile('t/data/text-CRLF.file')->hexdigest, "2fceadea90f637c1e09802d9d4bb0799b95c17d51eff2e8db118d1f6fced01f43bdee512d4d6bf58727debcb80331a9939b683cf30496af67aa3095b517f11ed", 'sha3_512 (OO/file/3)');
84 {
85 open(my $fh, '<', 't/data/text-CRLF.file');
86 binmode($fh);
87 is( Crypt::Digest::SHA3_512->new->addfile($fh)->hexdigest, "2fceadea90f637c1e09802d9d4bb0799b95c17d51eff2e8db118d1f6fced01f43bdee512d4d6bf58727debcb80331a9939b683cf30496af67aa3095b517f11ed", 'sha3_512 (OO/filehandle/3)');
88 close($fh);
89 }
90
91 is( sha3_512_file('t/data/text-LF.file'), pack("H*","46e2ef6af9a108abc49d692ca06ec20b136b96cfa0c4dbb9ecfce7d02c5712dbb2cd5f7e8a84b3ff15465e50d1ec6caffe5212749d96a3468e3477c3da877282"), 'sha3_512 (raw/file/4)');
92 is( sha3_512_file_hex('t/data/text-LF.file'), "46e2ef6af9a108abc49d692ca06ec20b136b96cfa0c4dbb9ecfce7d02c5712dbb2cd5f7e8a84b3ff15465e50d1ec6caffe5212749d96a3468e3477c3da877282", 'sha3_512 (hex/file/4)');
93 is( sha3_512_file_b64('t/data/text-LF.file'), "RuLvavmhCKvEnWksoG7CCxNrls+gxNu57Pzn0CxXEtuyzV9+ioSz/xVGXlDR7Gyv/lISdJ2Wo0aONHfD2odygg==", 'sha3_512 (base64/file/4)');
94 is( digest_file('SHA3_512', 't/data/text-LF.file'), pack("H*","46e2ef6af9a108abc49d692ca06ec20b136b96cfa0c4dbb9ecfce7d02c5712dbb2cd5f7e8a84b3ff15465e50d1ec6caffe5212749d96a3468e3477c3da877282"), 'sha3_512 (digest_file_raw/file/4)');
95 is( digest_file_hex('SHA3_512', 't/data/text-LF.file'), "46e2ef6af9a108abc49d692ca06ec20b136b96cfa0c4dbb9ecfce7d02c5712dbb2cd5f7e8a84b3ff15465e50d1ec6caffe5212749d96a3468e3477c3da877282", 'sha3_512 (digest_file_hex/file/4)');
96 is( digest_file_b64('SHA3_512', 't/data/text-LF.file'), "RuLvavmhCKvEnWksoG7CCxNrls+gxNu57Pzn0CxXEtuyzV9+ioSz/xVGXlDR7Gyv/lISdJ2Wo0aONHfD2odygg==", 'sha3_512 (digest_file_b64/file/4)');
97 is( digest_file_b64u('SHA3_512', 't/data/text-LF.file'), "RuLvavmhCKvEnWksoG7CCxNrls-gxNu57Pzn0CxXEtuyzV9-ioSz_xVGXlDR7Gyv_lISdJ2Wo0aONHfD2odygg", 'sha3_512 (digest_file_b64u/file/4)');
98 is( Crypt::Digest::SHA3_512->new->addfile('t/data/text-LF.file')->hexdigest, "46e2ef6af9a108abc49d692ca06ec20b136b96cfa0c4dbb9ecfce7d02c5712dbb2cd5f7e8a84b3ff15465e50d1ec6caffe5212749d96a3468e3477c3da877282", 'sha3_512 (OO/file/4)');
99 {
100 open(my $fh, '<', 't/data/text-LF.file');
101 binmode($fh);
102 is( Crypt::Digest::SHA3_512->new->addfile($fh)->hexdigest, "46e2ef6af9a108abc49d692ca06ec20b136b96cfa0c4dbb9ecfce7d02c5712dbb2cd5f7e8a84b3ff15465e50d1ec6caffe5212749d96a3468e3477c3da877282", 'sha3_512 (OO/filehandle/4)');
103 close($fh);
104 }