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