line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::Keyczar::AesKey; |
2
|
3
|
|
|
3
|
|
16
|
use base 'Crypt::Keyczar::Key'; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
294
|
|
3
|
3
|
|
|
3
|
|
15
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
84
|
|
4
|
3
|
|
|
3
|
|
29
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
88
|
|
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
555
|
use Crypt::Keyczar qw(KEY_HASH_SIZE); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
167
|
|
7
|
3
|
|
|
3
|
|
1554
|
use Crypt::Keyczar::HmacKey; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
81
|
|
8
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
16
|
use constant DEFAULT_MODE => 'CBC'; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
1939
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub expose { |
13
|
4
|
|
|
4
|
0
|
8
|
my $self = shift; |
14
|
4
|
|
|
|
|
9
|
my $expose = {}; |
15
|
4
|
|
|
|
|
12
|
$expose->{aesKeyString} = $self->{aesKeyString}; |
16
|
4
|
|
|
|
|
22
|
$expose->{hmacKey} = $self->{hmacKey}->expose; |
17
|
4
|
|
|
|
|
10
|
$expose->{mode} = $self->{mode}; |
18
|
4
|
|
|
|
|
11
|
$expose->{size} = $self->{size}; |
19
|
4
|
|
|
|
|
20
|
return $expose; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
5
|
|
|
5
|
0
|
549
|
sub get_bytes { return Crypt::Keyczar::Util::decode($_[0]->{aesKeyString}) } |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub read { |
27
|
30
|
|
|
30
|
0
|
45
|
my $class = shift; |
28
|
30
|
|
|
|
|
35
|
my $json_string = shift; |
29
|
|
|
|
|
|
|
|
30
|
30
|
|
|
|
|
79
|
my $obj = Crypt::Keyczar::Util::decode_json($json_string); |
31
|
30
|
|
|
|
|
72
|
my $self = bless $obj, $class; |
32
|
30
|
|
|
|
|
99
|
$self->{hmacKey} = bless $self->{hmacKey}, 'Crypt::Keyczar::HmacKey'; |
33
|
30
|
|
|
|
|
98
|
$self->{hmacKey}->init(); |
34
|
30
|
|
|
|
|
69
|
$self->init(); |
35
|
30
|
|
|
|
|
95
|
return $self; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub init { |
40
|
33
|
|
|
33
|
0
|
38
|
my $self = shift; |
41
|
33
|
|
|
|
|
87
|
my $key = Crypt::Keyczar::Util::decode($self->{aesKeyString}); |
42
|
33
|
|
|
|
|
168
|
my $hash = Crypt::Keyczar::Util::hash(pack('N1', length $key), $key, $self->{hmacKey}->get_bytes()); |
43
|
33
|
|
|
|
|
173
|
$self->hash(substr $hash, 0, KEY_HASH_SIZE()); |
44
|
33
|
|
|
|
|
68
|
return $self; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub generate { |
49
|
3
|
|
|
3
|
0
|
7
|
my $class = shift; |
50
|
3
|
|
50
|
|
|
10
|
my $size = shift || 128; |
51
|
3
|
|
|
|
|
19
|
my $self = $class->new; |
52
|
3
|
|
|
|
|
16
|
$self->{size} = $size; |
53
|
3
|
|
|
|
|
48
|
my $raw = Crypt::Keyczar::Util::random($self->{size} / 8); |
54
|
3
|
|
|
|
|
12
|
$self->{aesKeyString} = Crypt::Keyczar::Util::encode($raw); |
55
|
3
|
|
|
|
|
9
|
$self->{mode} = DEFAULT_MODE; |
56
|
3
|
|
|
|
|
18
|
$self->{hmacKey} = Crypt::Keyczar::HmacKey->generate(); |
57
|
3
|
|
|
|
|
9
|
return $self->init; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub get_engine { |
62
|
4
|
|
|
4
|
0
|
4
|
my $self = shift; |
63
|
4
|
|
|
|
|
8
|
return Crypt::Keyczar::AesEngine->new($self->get_bytes); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub get_sign_engine { |
68
|
4
|
|
|
4
|
0
|
5
|
my $self = shift; |
69
|
4
|
|
|
|
|
11
|
return $self->{hmacKey}->get_engine; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
package Crypt::Keyczar::AesEngine; |
75
|
3
|
|
|
3
|
|
17
|
use base 'Exporter'; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
255
|
|
76
|
3
|
|
|
3
|
|
22
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
74
|
|
77
|
3
|
|
|
3
|
|
13
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
137
|
|
78
|
3
|
|
|
3
|
|
16
|
use Crypt::Keyczar::Engine; |
|
3
|
|
|
|
|
12
|
|
|
3
|
|
|
|
|
81
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |
82
|
|
|
|
|
|
|
__END__ |