line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::Digest::SHAKE; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
69287
|
use strict; |
|
2
|
|
|
|
|
14
|
|
|
2
|
|
|
|
|
56
|
|
4
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
85
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.080_001'; |
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
10
|
use Carp; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
134
|
|
8
|
|
|
|
|
|
|
$Carp::Internal{(__PACKAGE__)}++; |
9
|
2
|
|
|
2
|
|
386
|
use CryptX; |
|
2
|
|
|
|
|
14
|
|
|
2
|
|
|
|
|
504
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub addfile { |
12
|
0
|
|
|
0
|
1
|
|
my ($self, $file) = @_; |
13
|
|
|
|
|
|
|
|
14
|
0
|
|
|
|
|
|
my $handle; |
15
|
0
|
0
|
|
|
|
|
if (ref(\$file) eq 'SCALAR') { #filename |
16
|
0
|
0
|
|
|
|
|
open($handle, "<", $file) || croak "FATAL: cannot open '$file': $!"; |
17
|
0
|
|
|
|
|
|
binmode($handle); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
else { #handle |
20
|
0
|
|
|
|
|
|
$handle = $file |
21
|
|
|
|
|
|
|
} |
22
|
0
|
0
|
|
|
|
|
croak "FATAL: invalid handle" unless defined $handle; |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
my $n; |
25
|
0
|
|
|
|
|
|
my $buf = ""; |
26
|
0
|
|
|
|
|
|
while (($n = read($handle, $buf, 32*1024))) { |
27
|
0
|
|
|
|
|
|
$self->add($buf) |
28
|
|
|
|
|
|
|
} |
29
|
0
|
0
|
|
|
|
|
croak "FATAL: read failed: $!" unless defined $n; |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
return $self; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
0
|
|
|
sub CLONE_SKIP { 1 } # prevent cloning |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=pod |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 NAME |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Crypt::Digest::SHAKE - Hash functions SHAKE128, SHAKE256 from SHA3 family |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 SYNOPSIS |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
use Crypt::Digest::SHAKE |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
$d = Crypt::Digest::SHAKE->new(128); |
49
|
|
|
|
|
|
|
$d->add('any data'); |
50
|
|
|
|
|
|
|
$d->addfile('filename.dat'); |
51
|
|
|
|
|
|
|
$d->addfile(*FILEHANDLE); |
52
|
|
|
|
|
|
|
$part1 = $d->done(100); # 100 raw bytes |
53
|
|
|
|
|
|
|
$part2 = $d->done(100); # another 100 raw bytes |
54
|
|
|
|
|
|
|
#... |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 DESCRIPTION |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Provides an interface to the SHA3's sponge function SHAKE. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 METHODS |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head2 new |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
$d = Crypt::Digest::SHA3-SHAKE->new($num); |
65
|
|
|
|
|
|
|
# $num ... 128 or 256 |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 clone |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
$d->clone(); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 reset |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
$d->reset(); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head2 add |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
$d->add('any data'); |
78
|
|
|
|
|
|
|
#or |
79
|
|
|
|
|
|
|
$d->add('any data', 'more data', 'even more data'); |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 addfile |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
$d->addfile('filename.dat'); |
84
|
|
|
|
|
|
|
#or |
85
|
|
|
|
|
|
|
$d->addfile(*FILEHANDLE); |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 done |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
$result_raw = $d->done($len); |
90
|
|
|
|
|
|
|
# can be called multiple times |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 SEE ALSO |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=over |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=item * L, L |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=item * L |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=back |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |