line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::Keyczar::HmacKey; |
2
|
9
|
|
|
9
|
|
52
|
use base 'Crypt::Keyczar::Key'; |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
637
|
|
3
|
9
|
|
|
9
|
|
48
|
use strict; |
|
9
|
|
|
|
|
15
|
|
|
9
|
|
|
|
|
146
|
|
4
|
9
|
|
|
9
|
|
34
|
use warnings; |
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
200
|
|
5
|
|
|
|
|
|
|
|
6
|
9
|
|
|
9
|
|
604
|
use Crypt::Keyczar qw(KEY_HASH_SIZE); |
|
9
|
|
|
|
|
16
|
|
|
9
|
|
|
|
|
362
|
|
7
|
9
|
|
|
9
|
|
54
|
use Crypt::Keyczar::Util; |
|
9
|
|
|
|
|
79
|
|
|
9
|
|
|
|
|
2382
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub expose { |
11
|
11
|
|
|
11
|
0
|
18
|
my $self = shift; |
12
|
11
|
|
|
|
|
21
|
my $expose = {}; |
13
|
11
|
|
|
|
|
28
|
$expose->{hmacKeyString} = $self->{hmacKeyString}; |
14
|
11
|
|
|
|
|
22
|
$expose->{size} = $self->{size}; |
15
|
11
|
|
|
|
|
34
|
return $expose; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub get_bytes { |
21
|
168
|
|
|
168
|
0
|
2006
|
return Crypt::Keyczar::Util::decode($_[0]->{hmacKeyString}); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub digest_size { |
26
|
7
|
|
|
7
|
0
|
34
|
return 20; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub init { |
31
|
91
|
|
|
91
|
0
|
143
|
my $self = shift; |
32
|
91
|
|
|
|
|
196
|
my $rawkey = $self->get_bytes; |
33
|
91
|
|
|
|
|
823
|
my $hash = Crypt::Keyczar::Util::hash($rawkey); |
34
|
91
|
|
|
|
|
507
|
$self->hash(substr $hash, 0, KEY_HASH_SIZE()); |
35
|
91
|
|
|
|
|
254
|
return $self; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub generate { |
40
|
9
|
|
|
9
|
0
|
19
|
my $class = shift; |
41
|
9
|
|
|
|
|
13
|
my $size = shift; |
42
|
|
|
|
|
|
|
|
43
|
9
|
|
|
|
|
37
|
my $self = $class->new; |
44
|
9
|
|
100
|
|
|
41
|
$self->{size} = $size || 256; |
45
|
|
|
|
|
|
|
|
46
|
9
|
|
|
|
|
301
|
my $raw = Crypt::Keyczar::Util::random($self->{size}/8); |
47
|
9
|
|
|
|
|
36
|
$self->{hmacKeyString} = Crypt::Keyczar::Util::encode($raw); |
48
|
9
|
|
|
|
|
28
|
$self->init(); |
49
|
9
|
|
|
|
|
32
|
return $self; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub read { |
54
|
52
|
|
|
52
|
0
|
100
|
my $class = shift; |
55
|
52
|
|
|
|
|
77
|
my $json_string = shift; |
56
|
|
|
|
|
|
|
|
57
|
52
|
|
|
|
|
157
|
my $obj = Crypt::Keyczar::Util::decode_json($json_string); |
58
|
52
|
|
|
|
|
128
|
my $self = bless $obj, $class; |
59
|
52
|
|
|
|
|
142
|
$self->init(); |
60
|
52
|
|
|
|
|
151
|
return $self; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub get_engine { |
65
|
16
|
|
|
16
|
0
|
27
|
my $self = shift; |
66
|
16
|
|
|
|
|
34
|
return Crypt::Keyczar::HmacEngine->new('sha1', $self->get_bytes); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
package Crypt::Keyczar::HmacEngine; |
73
|
9
|
|
|
9
|
|
50
|
use base 'Exporter'; |
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
513
|
|
74
|
9
|
|
|
9
|
|
47
|
use strict; |
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
147
|
|
75
|
9
|
|
|
9
|
|
33
|
use warnings; |
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
184
|
|
76
|
9
|
|
|
9
|
|
43
|
use Crypt::Keyczar::Engine; |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
196
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |
80
|
|
|
|
|
|
|
__END__ |