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