PBKDF2/Hash/HMACSHA2.pm

filter: Statementstmt 100% 35 / 35 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 11 / 11 Podpod 0.0% 0 / 4 totaltotal 92.0% 46 / 50 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« PBKDF2/Hash/HMACSHA1.pm ↑ Summary PBKDF2/Hash.pm »
1 package Crypt::PBKDF2::Hash::HMACSHA2;
2 # ABSTRACT: HMAC-SHA2 support for Crypt::PBKDF2 using Digest::SHA
3 5 our $VERSION = '0.261630'; # VERSION
4 5 our $AUTHORITY = 'cpan:ARODLAND'; # AUTHORITY
5 5 ▶use Moo 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 ▶use Digest::SHA ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 5 ▶use Type::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 5 ▶use Types::Standard qw(Enum);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 5 with 'Crypt::PBKDF2::Hash';
13  
14 5 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 5 has '_hasher' => (
25 is => 'lazy',
26 init_arg => undef,
27 );
28  
29 1028 ▶sub _build__hasher {
Subroutine _build__hasher: called CC=1 SCAR=0.0
30 1028 my $self = shift;
31 1028 my $shasize = $self->sha_size;
32  
33 1028 return Digest::SHA->can("hmac_sha$shasize");
34 }
35  
36 9066 ▶sub hash_len {
Subroutine hash_len: called CC=1 SCAR=0.0
Pod undocumented
37 9066 my $self = shift;
38 9066 return $self->sha_size() / 8;
39 }
40  
41 1404200 ▶sub generate {
Subroutine generate: called CC=1 SCAR=0.0
Pod undocumented
42 1404200 my $self = shift; # ($data, $key)
43 1404200 return $self->_hasher->(@_);
44 }
45  
46 1022 ▶sub to_algo_string {
Subroutine to_algo_string: called CC=1 SCAR=0.0
Pod undocumented
47 1022 my $self = shift;
48  
49 1022 return $self->sha_size;
50 }
51  
52 1022 ▶sub from_algo_string {
Subroutine from_algo_string: called CC=1 SCAR=0.0
Pod undocumented
53 1022 my ($class, $str) = @_;
54  
55 1022 return $class->new( sha_size => $str );
56 }
57  
58 5 1;
59  
60 __END__
« PBKDF2/Hash/HMACSHA1.pm ↑ Summary PBKDF2/Hash.pm »