blib/lib/RIPEMD160/MAC.pm

filter: Statementstmt 59.3% 35 / 59 Branchbran 20.0% 2 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 70.0% 7 / 10 Podpod 0.0% 0 / 6 totaltotal 51.7% 44 / 85 CC 6 SCAR 16.0
CC
6
Cov
54%
addfile
12.6
reset
6.0
new
2.0
CRAP 5.0
↑ Summary blib/lib/RIPEMD160.pm »
1 package RIPEMD160::MAC;
2  
3 1 ▶use RIPEMD160 0.02;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use vars qw($VERSION @ISA @EXPORT);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 require Exporter;
9 1 @ISA = qw(Exporter);
10  
11 # Items to export into callers namespace by default
12 1 @EXPORT = qw();
13 1 $VERSION = '0.1';
14  
15 8 ▶sub new {
Subroutine new: called CC=2 SCAR=6.9
Pod undocumented
16 8 my($pkg, $key) = @_;
17  
18 8 my $self = {
19 'key' => $key,
20 'hash' => new RIPEMD160,
21 'k_ipad' => chr(0x36) x 64,
22 'k_opad' => chr(0x5c) x 64,
23 };
24  
25 8 bless $self, $pkg;
26  
27 8 ▶ if (length($self->{'key'}) > 64) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $self->{"key"} > 64) 3 5 8
28 3 $self->{'key'} = RIPEMD160->hash($self->{'key'});
29 }
30  
31 8 $self->{'k_ipad'} ^= $self->{'key'};
32 8 $self->{'k_opad'} ^= $self->{'key'};
33  
34 8 $self->{'hash'}->add($self->{'k_ipad'});
35  
36 8 return $self;
37 }
38  
39 0 ▶sub reset {
Subroutine reset: not called CC=2 SCAR=17.9
Pod undocumented
40 0 my($self) = @_;
41  
42 0 $self->{'hash'}->reset();
43 0 $self->{'k_ipad'} = chr(0x36) x 64;
44 0 $self->{'k_opad'} = chr(0x5c) x 64;
45  
46 0 ▶ if (length($self->{'key'}) > 64) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $self->{"key"} > 64) 0 0 0
47 0 $self->{'key'} = RIPEMD160->hash($self->{'key'});
48 }
49  
50 0 $self->{'k_ipad'} ^= $self->{'key'};
51 0 $self->{'k_opad'} ^= $self->{'key'};
52  
53 0 $self->{'hash'}->add($self->{'k_ipad'});
54  
55 0 return $self;
56 }
57  
58 8 ▶sub add {
Subroutine add: called CC=1 SCAR=0.0
Pod undocumented
59 8 my($self, @data) = @_;
60  
61 8 $self->{'hash'}->add(@data);
62 }
63  
64 sub addfile
65 0 ▶{
Subroutine addfile: not called CC=4 SCAR=25.3
Pod undocumented
66 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
67 0 my ($self, $handle) = @_;
68 0 my ($package, $file, $line) = caller;
69 0 my ($data);
70  
71 0 ▶ if (!ref($handle)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $handle) 0 0 0
72 0 ▶ $handle = $package . "::" . $handle unless ($handle =~ /(\:\:|\')/);
Branch: 1 branch
BranchTrueFalseTotal
unless $handle =~ /(\:\:|\')/ 0 0 0
73 }
74 0 ▶ while (read($handle, $data, 8192)) {
Branch: 1 branch
BranchTrueFalseTotal
if (read $handle, $data, 8192) 0 0 0
75 0 $self->{'hash'}->add($data);
76 }
77 }
78  
79 0 ▶sub mac {
Subroutine mac: not called CC=1 SCAR=6.9
Pod undocumented
80 0 my($self) = @_;
81  
82 0 my($inner) = $self->{'hash'}->digest();
83  
84 0 my($outer) = RIPEMD160->hash($self->{'k_opad'}.$inner);
85  
86 0 $self->{'key'} = "";
87 0 $self->{'k_ipad'} = "";
88 0 $self->{'k_opad'} = "";
89  
90 0 return($outer);
91 }
92  
93 8 ▶sub hexmac {
Subroutine hexmac: called CC=1 SCAR=0.0
Pod undocumented
94 8 my($self) = @_;
95  
96 8 my($inner) = $self->{'hash'}->digest();
97  
98 8 my($outer) = RIPEMD160->hexhash($self->{'k_opad'}.$inner);
99  
100 8 $self->{'key'} = "";
101 8 $self->{'k_ipad'} = "";
102 8 $self->{'k_opad'} = "";
103  
104 8 return($outer);
105 }
106  
107 1 1;
108 __END__
↑ Summary blib/lib/RIPEMD160.pm »