lib/Langertha/Skeid/Secret.pm

filter: Statementstmt 100% 17 / 17 Branchbran 83.3% 5 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 96.4% 27 / 28 CC 5 SCAR 12.6
CC
5
Cov
96%
equal
5.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.5
« blib/lib/Langertha/Skeid/KeyBroker.pm ↑ Summary lib/Langertha/Skeid/Protocol/Refusal.pm »
1 package Langertha::Skeid::Secret;
2 87 our $VERSION = '0.004';
3 # ABSTRACT: Constant-time comparison for keys, tokens and signatures
4 87 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 87 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 87 ▶use Digest::SHA ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8  
9 170 ▶sub equal {
Subroutine equal: called CC=5 SCAR=16.1
Pod documented
10 170 my ($class, $given, $want) = @_;
11 170 ▶ my $have = Digest::SHA::sha256(defined($given) ? "$given" : '');
Branch: 1 branch
BranchTrueFalseTotal
defined $given ? : 169 1 170
12 170 ▶ my $need = Digest::SHA::sha256(defined($want) ? "$want" : '');
Branch: 1 branch
BranchTrueFalseTotal
defined $want ? : 170 0 170
13 170 my $diff = 0;
14 170 $diff |= ord(substr($have, $_, 1)) ^ ord(substr($need, $_, 1)) for 0 .. length($need) - 1;
15 170 ▶ return $diff == 0 ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$diff == 0 ? : 138 32 170
16 }
17  
18  
19 87 1;
20  
21 __END__
« blib/lib/Langertha/Skeid/KeyBroker.pm ↑ Summary lib/Langertha/Skeid/Protocol/Refusal.pm »