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 100 our $VERSION = '0.005';
3 # ABSTRACT: Constant-time comparison for keys, tokens and signatures
4 100 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 100 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 100 ▶use Digest::SHA ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8  
9 180 ▶sub equal {
Subroutine equal: called CC=5 SCAR=16.1
Pod documented
10 180 my ($class, $given, $want) = @_;
11 180 ▶ my $have = Digest::SHA::sha256(defined($given) ? "$given" : '');
Branch: 1 branch
BranchTrueFalseTotal
defined $given ? : 179 1 180
12 180 ▶ my $need = Digest::SHA::sha256(defined($want) ? "$want" : '');
Branch: 1 branch
BranchTrueFalseTotal
defined $want ? : 180 0 180
13 180 my $diff = 0;
14 180 $diff |= ord(substr($have, $_, 1)) ^ ord(substr($need, $_, 1)) for 0 .. length($need) - 1;
15 180 ▶ return $diff == 0 ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$diff == 0 ? : 148 32 180
16 }
17  
18  
19 100 1;
20  
21 __END__
« blib/lib/Langertha/Skeid/KeyBroker.pm ↑ Summary lib/Langertha/Skeid/Protocol/Refusal.pm »