line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::Keyczar::HmacKey; |
2
|
9
|
|
|
9
|
|
47
|
use base 'Crypt::Keyczar::Key'; |
|
9
|
|
|
|
|
13
|
|
|
9
|
|
|
|
|
927
|
|
3
|
9
|
|
|
9
|
|
50
|
use strict; |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
271
|
|
4
|
9
|
|
|
9
|
|
45
|
use warnings; |
|
9
|
|
|
|
|
14
|
|
|
9
|
|
|
|
|
307
|
|
5
|
|
|
|
|
|
|
|
6
|
9
|
|
|
9
|
|
1520
|
use Crypt::Keyczar qw(KEY_HASH_SIZE); |
|
9
|
|
|
|
|
20
|
|
|
9
|
|
|
|
|
599
|
|
7
|
9
|
|
|
9
|
|
48
|
use Crypt::Keyczar::Util; |
|
9
|
|
|
|
|
152
|
|
|
9
|
|
|
|
|
5198
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub expose { |
11
|
11
|
|
|
11
|
0
|
32
|
my $self = shift; |
12
|
11
|
|
|
|
|
25
|
my $expose = {}; |
13
|
11
|
|
|
|
|
43
|
$expose->{hmacKeyString} = $self->{hmacKeyString}; |
14
|
11
|
|
|
|
|
27
|
$expose->{size} = $self->{size}; |
15
|
11
|
|
|
|
|
37
|
return $expose; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub get_bytes { |
21
|
168
|
|
|
168
|
0
|
2832
|
return Crypt::Keyczar::Util::decode($_[0]->{hmacKeyString}); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub digest_size { |
26
|
7
|
|
|
7
|
0
|
39
|
return 20; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub init { |
31
|
91
|
|
|
91
|
0
|
131
|
my $self = shift; |
32
|
91
|
|
|
|
|
206
|
my $rawkey = $self->get_bytes; |
33
|
91
|
|
|
|
|
916
|
my $hash = Crypt::Keyczar::Util::hash($rawkey); |
34
|
91
|
|
|
|
|
546
|
$self->hash(substr $hash, 0, KEY_HASH_SIZE()); |
35
|
91
|
|
|
|
|
195
|
return $self; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub generate { |
40
|
9
|
|
|
9
|
0
|
12
|
my $class = shift; |
41
|
9
|
|
|
|
|
15
|
my $size = shift; |
42
|
|
|
|
|
|
|
|
43
|
9
|
|
|
|
|
50
|
my $self = $class->new; |
44
|
9
|
|
100
|
|
|
48
|
$self->{size} = $size || 256; |
45
|
|
|
|
|
|
|
|
46
|
9
|
|
|
|
|
6405
|
my $raw = Crypt::Keyczar::Util::random($self->{size}/8); |
47
|
9
|
|
|
|
|
38
|
$self->{hmacKeyString} = Crypt::Keyczar::Util::encode($raw); |
48
|
9
|
|
|
|
|
25
|
$self->init(); |
49
|
9
|
|
|
|
|
39
|
return $self; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub read { |
54
|
52
|
|
|
52
|
0
|
75
|
my $class = shift; |
55
|
52
|
|
|
|
|
68
|
my $json_string = shift; |
56
|
|
|
|
|
|
|
|
57
|
52
|
|
|
|
|
154
|
my $obj = Crypt::Keyczar::Util::decode_json($json_string); |
58
|
52
|
|
|
|
|
135
|
my $self = bless $obj, $class; |
59
|
52
|
|
|
|
|
208
|
$self->init(); |
60
|
52
|
|
|
|
|
166
|
return $self; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub get_engine { |
65
|
16
|
|
|
16
|
0
|
19
|
my $self = shift; |
66
|
16
|
|
|
|
|
35
|
return Crypt::Keyczar::HmacEngine->new('sha1', $self->get_bytes); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
package Crypt::Keyczar::HmacEngine; |
73
|
9
|
|
|
9
|
|
66
|
use base 'Exporter'; |
|
9
|
|
|
|
|
58
|
|
|
9
|
|
|
|
|
948
|
|
74
|
9
|
|
|
9
|
|
45
|
use strict; |
|
9
|
|
|
|
|
16
|
|
|
9
|
|
|
|
|
241
|
|
75
|
9
|
|
|
9
|
|
53
|
use warnings; |
|
9
|
|
|
|
|
24
|
|
|
9
|
|
|
|
|
434
|
|
76
|
9
|
|
|
9
|
|
49
|
use Crypt::Keyczar::Engine; |
|
9
|
|
|
|
|
16
|
|
|
9
|
|
|
|
|
435
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |
80
|
|
|
|
|
|
|
__END__ |