line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package RIPEMD160::MAC; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
868
|
use RIPEMD160 0.02; |
|
1
|
|
|
|
|
24
|
|
|
1
|
|
|
|
|
38
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
6
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION @ISA @EXPORT); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
543
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
require Exporter; |
9
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Items to export into callers namespace by default |
12
|
|
|
|
|
|
|
@EXPORT = qw(); |
13
|
|
|
|
|
|
|
$VERSION = '0.1'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
16
|
8
|
|
|
8
|
0
|
122
|
my($pkg, $key) = @_; |
17
|
|
|
|
|
|
|
|
18
|
8
|
|
|
|
|
58
|
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
|
|
|
|
|
18
|
bless $self, $pkg; |
26
|
|
|
|
|
|
|
|
27
|
8
|
100
|
|
|
|
35
|
if (length($self->{'key'}) > 64) { |
28
|
3
|
|
|
|
|
14
|
$self->{'key'} = RIPEMD160->hash($self->{'key'}); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
8
|
|
|
|
|
21
|
$self->{'k_ipad'} ^= $self->{'key'}; |
32
|
8
|
|
|
|
|
15
|
$self->{'k_opad'} ^= $self->{'key'}; |
33
|
|
|
|
|
|
|
|
34
|
8
|
|
|
|
|
45
|
$self->{'hash'}->add($self->{'k_ipad'}); |
35
|
|
|
|
|
|
|
|
36
|
8
|
|
|
|
|
44
|
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'} = 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
|
38
|
my($self, @data) = @_; |
60
|
|
|
|
|
|
|
|
61
|
8
|
|
|
|
|
37
|
$self->{'hash'}->add(@data); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub addfile |
65
|
|
|
|
|
|
|
{ |
66
|
1
|
|
|
1
|
|
6
|
no strict 'refs'; |
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
343
|
|
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) = 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
|
28
|
my($self) = @_; |
95
|
|
|
|
|
|
|
|
96
|
8
|
|
|
|
|
53
|
my($inner) = $self->{'hash'}->digest(); |
97
|
|
|
|
|
|
|
|
98
|
8
|
|
|
|
|
35
|
my($outer) = RIPEMD160->hexhash($self->{'k_opad'}.$inner); |
99
|
|
|
|
|
|
|
|
100
|
8
|
|
|
|
|
16
|
$self->{'key'} = ""; |
101
|
8
|
|
|
|
|
12
|
$self->{'k_ipad'} = ""; |
102
|
8
|
|
|
|
|
11
|
$self->{'k_opad'} = ""; |
103
|
|
|
|
|
|
|
|
104
|
8
|
|
|
|
|
21
|
return($outer); |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
1; |
108
|
|
|
|
|
|
|
__END__ |