line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::Keyczar::Manager; |
2
|
1
|
|
|
1
|
|
5
|
use base 'Crypt::Keyczar'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
78
|
|
3
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
24
|
|
5
|
1
|
|
|
1
|
|
4
|
use Crypt::Keyczar::FileReader; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
18
|
|
6
|
1
|
|
|
1
|
|
5
|
use Crypt::Keyczar::Key; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
41
|
|
7
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
644
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub promote { |
11
|
13
|
|
|
13
|
0
|
28
|
my $self = shift; |
12
|
13
|
|
|
|
|
19
|
my $version_number = shift; |
13
|
|
|
|
|
|
|
|
14
|
13
|
|
|
|
|
43
|
my $version = $self->get_version_by_number($version_number); |
15
|
13
|
50
|
|
|
|
45
|
if ($version->status eq 'PRIMARY') { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
16
|
0
|
|
|
|
|
0
|
croak "can't promote primary key#$version_number"; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
elsif ($version->status eq 'ACTIVE') { |
19
|
12
|
|
|
|
|
44
|
$version->status('PRIMARY'); |
20
|
12
|
50
|
|
|
|
31
|
if ($self->primary) { |
21
|
12
|
|
|
|
|
34
|
$self->primary->status('ACTIVE'); |
22
|
|
|
|
|
|
|
} |
23
|
12
|
|
|
|
|
38
|
$self->primary($version); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
elsif ($version->status eq 'INACTIVE') { |
26
|
1
|
|
|
|
|
8
|
$version->status('ACTIVE'); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub demote { |
32
|
17
|
|
|
17
|
0
|
35
|
my $self = shift; |
33
|
17
|
|
|
|
|
25
|
my $version_number = shift; |
34
|
|
|
|
|
|
|
|
35
|
17
|
|
|
|
|
55
|
my $version = $self->get_version_by_number($version_number); |
36
|
17
|
100
|
|
|
|
54
|
if ($version->status eq 'PRIMARY') { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
37
|
5
|
|
|
|
|
19
|
$version->status('ACTIVE'); |
38
|
5
|
|
|
|
|
14
|
$self->primary(undef); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
elsif ($version->status eq 'ACTIVE') { |
41
|
7
|
|
|
|
|
20
|
$version->status('INACTIVE'); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
elsif ($version->status eq 'INACTIVE') { |
44
|
5
|
|
|
|
|
1182
|
croak "can't demote inactive key#$version_number"; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub revoke { |
50
|
11
|
|
|
11
|
0
|
24
|
my $self = shift; |
51
|
11
|
|
|
|
|
20
|
my $version_number = shift; |
52
|
|
|
|
|
|
|
|
53
|
11
|
|
|
|
|
42
|
my $version = $self->get_version_by_number($version_number); |
54
|
11
|
100
|
|
|
|
43
|
if ($version->status eq 'INACTIVE') { |
55
|
6
|
|
|
|
|
21
|
$self->metadata->remove_version($version_number); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
else { |
58
|
5
|
|
|
|
|
1534
|
croak "can't revoke active or primary key#$version_number"; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub add_version { |
64
|
17
|
|
|
17
|
0
|
30
|
my $self = shift; |
65
|
17
|
|
|
|
|
31
|
my ($status, $size) = @_; |
66
|
17
|
|
50
|
|
|
133
|
$status ||= 'ACTIVE'; |
67
|
|
|
|
|
|
|
|
68
|
17
|
|
|
|
|
52
|
my $num = scalar($self->metadata->get_versions) + 1; |
69
|
17
|
|
|
|
|
108
|
my $version = Crypt::Keyczar::KeyVersion->new($num, $status, undef); |
70
|
17
|
100
|
|
|
|
51
|
if (uc $status eq 'PRIMARY') { |
71
|
6
|
50
|
|
|
|
29
|
if ($self->primary) { |
72
|
0
|
|
|
|
|
0
|
$self->primary->status('ACTIVE'); |
73
|
|
|
|
|
|
|
} |
74
|
6
|
|
|
|
|
21
|
$self->primary($version); |
75
|
|
|
|
|
|
|
} |
76
|
17
|
100
|
|
|
|
47
|
if (!$size) { |
77
|
|
|
|
|
|
|
# find default size $self->metadata->get_type; |
78
|
|
|
|
|
|
|
} |
79
|
17
|
|
|
|
|
24
|
my $key; |
80
|
17
|
|
|
|
|
24
|
do { |
81
|
17
|
|
|
|
|
54
|
$key = Crypt::Keyczar::Key->generate_key($self->metadata->get_type, $size); |
82
|
|
|
|
|
|
|
} while ($self->get_key($key->hash)); |
83
|
17
|
|
|
|
|
85
|
$self->add_key($version, $key); |
84
|
17
|
|
|
|
|
330
|
return $version; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub get_version_by_number { |
89
|
41
|
|
|
41
|
0
|
64
|
my $self = shift; |
90
|
41
|
|
|
|
|
55
|
my $version_number = shift; |
91
|
41
|
|
|
|
|
111
|
my $version = $self->metadata->get_version($version_number); |
92
|
41
|
50
|
|
|
|
117
|
if (!defined $version) { |
93
|
0
|
|
|
|
|
0
|
croak "no such key version#$version_number"; |
94
|
|
|
|
|
|
|
} |
95
|
41
|
|
|
|
|
72
|
return $version; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
1; |
100
|
|
|
|
|
|
|
__END__ |