line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::RIPEMD160::MAC; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
452
|
use Crypt::RIPEMD160; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
518
|
use strict; |
|
1
|
|
|
|
|
13
|
|
|
1
|
|
|
|
|
29
|
|
6
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
400
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.08'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
8
|
|
|
8
|
0
|
4286
|
my($pkg, $key) = @_; |
12
|
|
|
|
|
|
|
|
13
|
8
|
|
|
|
|
50
|
my $self = { |
14
|
|
|
|
|
|
|
'key' => $key, |
15
|
|
|
|
|
|
|
'hash' => Crypt::RIPEMD160->new, |
16
|
|
|
|
|
|
|
'k_ipad' => chr(0x36) x 64, |
17
|
|
|
|
|
|
|
'k_opad' => chr(0x5c) x 64, |
18
|
|
|
|
|
|
|
}; |
19
|
|
|
|
|
|
|
|
20
|
8
|
|
|
|
|
16
|
bless $self, $pkg; |
21
|
|
|
|
|
|
|
|
22
|
8
|
100
|
|
|
|
34
|
if (length($self->{'key'}) > 64) { |
23
|
3
|
|
|
|
|
9
|
$self->{'key'} = Crypt::RIPEMD160->hash($self->{'key'}); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
8
|
|
|
|
|
23
|
$self->{'k_ipad'} ^= $self->{'key'}; |
27
|
8
|
|
|
|
|
13
|
$self->{'k_opad'} ^= $self->{'key'}; |
28
|
|
|
|
|
|
|
|
29
|
8
|
|
|
|
|
46
|
$self->{'hash'}->add($self->{'k_ipad'}); |
30
|
|
|
|
|
|
|
|
31
|
8
|
|
|
|
|
20
|
return $self; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub reset { |
35
|
0
|
|
|
0
|
0
|
0
|
my($self) = @_; |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
0
|
$self->{'hash'}->reset(); |
38
|
0
|
|
|
|
|
0
|
$self->{'k_ipad'} = chr(0x36) x 64; |
39
|
0
|
|
|
|
|
0
|
$self->{'k_opad'} = chr(0x5c) x 64; |
40
|
|
|
|
|
|
|
|
41
|
0
|
0
|
|
|
|
0
|
if (length($self->{'key'}) > 64) { |
42
|
0
|
|
|
|
|
0
|
$self->{'key'} = Crypt::RIPEMD160->hash($self->{'key'}); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
0
|
$self->{'k_ipad'} ^= $self->{'key'}; |
46
|
0
|
|
|
|
|
0
|
$self->{'k_opad'} ^= $self->{'key'}; |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
0
|
$self->{'hash'}->add($self->{'k_ipad'}); |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
0
|
return $self; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub add { |
54
|
8
|
|
|
8
|
0
|
32
|
my($self, @data) = @_; |
55
|
|
|
|
|
|
|
|
56
|
8
|
|
|
|
|
28
|
$self->{'hash'}->add(@data); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub addfile |
60
|
|
|
|
|
|
|
{ |
61
|
1
|
|
|
1
|
|
8
|
no strict 'refs'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
343
|
|
62
|
0
|
|
|
0
|
0
|
0
|
my ($self, $handle) = @_; |
63
|
0
|
|
|
|
|
0
|
my ($package, $file, $line) = caller; |
64
|
0
|
|
|
|
|
0
|
my ($data); |
65
|
|
|
|
|
|
|
|
66
|
0
|
0
|
|
|
|
0
|
if (!ref($handle)) { |
67
|
0
|
0
|
|
|
|
0
|
$handle = $package . "::" . $handle unless ($handle =~ /(\:\:|\')/); |
68
|
|
|
|
|
|
|
} |
69
|
0
|
|
|
|
|
0
|
while (read($handle, $data, 8192)) { |
70
|
0
|
|
|
|
|
0
|
$self->{'hash'}->add($data); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub mac { |
75
|
0
|
|
|
0
|
0
|
0
|
my($self) = @_; |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
0
|
my($inner) = $self->{'hash'}->digest(); |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
0
|
my($outer) = Crypt::RIPEMD160->hash($self->{'k_opad'}.$inner); |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
0
|
$self->{'key'} = ""; |
82
|
0
|
|
|
|
|
0
|
$self->{'k_ipad'} = ""; |
83
|
0
|
|
|
|
|
0
|
$self->{'k_opad'} = ""; |
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
0
|
return($outer); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub hexmac { |
89
|
8
|
|
|
8
|
0
|
29
|
my($self) = @_; |
90
|
|
|
|
|
|
|
|
91
|
8
|
|
|
|
|
40
|
my($inner) = $self->{'hash'}->digest(); |
92
|
|
|
|
|
|
|
|
93
|
8
|
|
|
|
|
34
|
my($outer) = Crypt::RIPEMD160->hexhash($self->{'k_opad'}.$inner); |
94
|
|
|
|
|
|
|
|
95
|
8
|
|
|
|
|
19
|
$self->{'key'} = ""; |
96
|
8
|
|
|
|
|
12
|
$self->{'k_ipad'} = ""; |
97
|
8
|
|
|
|
|
13
|
$self->{'k_opad'} = ""; |
98
|
|
|
|
|
|
|
|
99
|
8
|
|
|
|
|
22
|
return($outer); |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |
103
|
|
|
|
|
|
|
__END__ |