line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::PBKDF2::Hash::HMACSHA2; |
2
|
|
|
|
|
|
|
# ABSTRACT: HMAC-SHA2 support for Crypt::PBKDF2 using Digest::SHA |
3
|
|
|
|
|
|
|
our $VERSION = '0.161520'; # VERSION |
4
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:ARODLAND'; # AUTHORITY |
5
|
3
|
|
|
3
|
|
1818
|
use Moo 2; |
|
3
|
|
|
|
|
63
|
|
|
3
|
|
|
|
|
17
|
|
6
|
3
|
|
|
3
|
|
672
|
use strictures 2; |
|
3
|
|
|
|
|
17
|
|
|
3
|
|
|
|
|
102
|
|
7
|
3
|
|
|
3
|
|
557
|
use namespace::autoclean; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
19
|
|
8
|
3
|
|
|
3
|
|
1166
|
use Digest::SHA (); |
|
3
|
|
|
|
|
4854
|
|
|
3
|
|
|
|
|
66
|
|
9
|
3
|
|
|
3
|
|
14
|
use Type::Tiny; |
|
3
|
|
|
|
|
28
|
|
|
3
|
|
|
|
|
79
|
|
10
|
3
|
|
|
3
|
|
11
|
use Types::Standard qw(Enum); |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
36
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
with 'Crypt::PBKDF2::Hash'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has 'sha_size' => ( |
15
|
|
|
|
|
|
|
is => 'ro', |
16
|
|
|
|
|
|
|
isa => Type::Tiny->new( |
17
|
|
|
|
|
|
|
name => 'SHASize', |
18
|
|
|
|
|
|
|
parent => Enum[qw( 224 256 384 512 )], |
19
|
|
|
|
|
|
|
display_name => 'valid number of bits for SHA-2', |
20
|
|
|
|
|
|
|
), |
21
|
|
|
|
|
|
|
default => 256, |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has '_hasher' => ( |
25
|
|
|
|
|
|
|
is => 'lazy', |
26
|
|
|
|
|
|
|
init_arg => undef, |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub _build__hasher { |
30
|
24
|
|
|
24
|
|
690
|
my $self = shift; |
31
|
24
|
|
|
|
|
34
|
my $shasize = $self->sha_size; |
32
|
|
|
|
|
|
|
|
33
|
24
|
|
|
|
|
331
|
return Digest::SHA->can("hmac_sha$shasize"); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub hash_len { |
37
|
63
|
|
|
63
|
0
|
49
|
my $self = shift; |
38
|
63
|
|
|
|
|
168
|
return $self->sha_size() / 8; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub generate { |
42
|
4200
|
|
|
4200
|
0
|
2618
|
my $self = shift; # ($data, $key) |
43
|
4200
|
|
|
|
|
47839
|
return $self->_hasher->(@_); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub to_algo_string { |
47
|
21
|
|
|
21
|
0
|
40
|
my $self = shift; |
48
|
|
|
|
|
|
|
|
49
|
21
|
|
|
|
|
44
|
return $self->sha_size; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub from_algo_string { |
53
|
21
|
|
|
21
|
0
|
21
|
my ($class, $str) = @_; |
54
|
|
|
|
|
|
|
|
55
|
21
|
|
|
|
|
345
|
return $class->new( sha_size => $str ); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__END__ |