Passphrase/Pepper/Simple.pm

filter: Statementstmt 97.0% 33 / 34 Branchbran 50.0% 3 / 6 Conditioncond 25.0% 2 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 100% 9 / 9 Podpod 66.6% 2 / 3 totaltotal 75.3% 49 / 65 CC 7 SCAR 11.9
CC
7
Cov
79%
new
6.6
prehash_password
3.1
BEGIN
1.1
CRAP 3.3
« Passphrase.pm ↑ Summary Passphrase/Pepper/Base.pm »
1 package Crypt::Passphrase::Pepper::Simple;
2 2 $Crypt::Passphrase::Pepper::Simple::VERSION = '0.024';
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use parent 'Crypt::Passphrase::Pepper::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use Carp 'croak';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Digest::SHA;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 my %algorithms = (
12 'sha1-hmac' => \&Digest::SHA::hmac_sha1,
13 'sha224-hmac' => \&Digest::SHA::hmac_sha224,
14 'sha256-hmac' => \&Digest::SHA::hmac_sha256,
15 'sha384-hmac' => \&Digest::SHA::hmac_sha384,
16 'sha512-hmac' => \&Digest::SHA::hmac_sha512,
17 );
18  
19 1 ▶sub new {
Subroutine new: called CC=5 SCAR=18.9
Pod undocumented
20 1 my ($class, %args) = @_;
21  
22 1 ▶ my $peppers = $args{peppers} or croak('No peppers given');
Branch: 1 branch
BranchTrueFalseTotal
my $peppers = $args{"peppers"} or croak("No peppers given") 1 0 1
23 0 ▶ $args{active} //= (sort {; no warnings 'numeric'; $b <=> $a || $b cmp $a } keys %{ $peppers })[0];
Subroutine BEGIN: called CC=1 SCAR=1.2
Condition16%1/6
$args{"active"} //= (sort {BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x51\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55"} $b <=> $a or $b cmp $a;} keys %{$peppers;})[0]
l!l&&r!l&&!r
010
$b <=> $a || $b cmp $a
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{"active"} //= (sort {BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x51\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55"} $b <=> $a or $b cmp $a;} keys %{$peppers;})[0]
$args{"active"} (sort {BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x51\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55"} $b <=> $a or $b cmp $a;} keys %{$peppers;})[0]
MC/DC0%0/2
$b <=> $a || $b cmp $a
$b <=> $a $b cmp $a
Truth table33%1/3
A //= B
A= $args{"active"}B= (sort {BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x51\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55"} $b <=> $a or $b cmp $a;} keys %{$peppers;})[0]
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $b <=> $aB= $b cmp $a
ABresult
1X1
011
000
24 1 ▶ $args{algorithm} //= 'sha512-hmac';
Condition50%1/2
$args{"algorithm"} //= "sha512-hmac"
l!l
01
MC/DC0%0/1
$args{"algorithm"} //= "sha512-hmac"
$args{"algorithm"}
Truth table50%1/2
A
A= $args{"algorithm"}
Aresult
11
00
25  
26 1 return $class->SUPER::new(%args);
27 }
28  
29 2 ▶sub prehash_password {
Subroutine prehash_password: called CC=3 SCAR=11.4
Pod documented
30 2 my ($self, $password, $algorithm, $id) = @_;
31 2 ▶ my $secret = $self->{peppers}{$id} or croak "No such pepper $id";
Branch: 1 branch
BranchTrueFalseTotal
my $secret = $self->{"peppers"}{$id} or croak("No such pepper $id") 2 0 2
32 2 ▶ my $func = $algorithms{$algorithm} or croak "No such algorithm $algorithm";
Branch: 1 branch
BranchTrueFalseTotal
my $func = $algorithms{$algorithm} or croak("No such algorithm $algorithm") 2 0 2
33 2 return $func->($password, $secret);
34 }
35  
36 1 ▶sub supported_hashes {
Subroutine supported_hashes: called CC=1 SCAR=0.0
Pod documented
37 1 my $self = shift;
38 1 return keys %algorithms;
39 }
40  
41 2 1;
42  
43 #ABSTRACT: A pepper-wrapper for Crypt::Passphrase
44  
45 __END__
« Passphrase.pm ↑ Summary Passphrase/Pepper/Base.pm »