line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::Keyczar::RsaPrivateKey; |
2
|
5
|
|
|
5
|
|
2983
|
use base 'Crypt::Keyczar::Key'; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
1949
|
|
3
|
5
|
|
|
5
|
|
28
|
use strict; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
151
|
|
4
|
5
|
|
|
5
|
|
25
|
use warnings; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
215
|
|
5
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
26
|
use Crypt::Keyczar::Util; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
306
|
|
7
|
5
|
|
|
5
|
|
3428
|
use Crypt::Keyczar::RsaPublicKey; |
|
5
|
|
|
|
|
15
|
|
|
5
|
|
|
|
|
4067
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub expose { |
11
|
6
|
|
|
6
|
0
|
16
|
my $self = shift; |
12
|
6
|
|
|
|
|
14
|
my $expose = {}; |
13
|
6
|
|
|
|
|
25
|
$expose->{size} = $self->{size}; |
14
|
6
|
|
|
|
|
27
|
$expose->{publicKey} = $self->get_public->expose; |
15
|
6
|
|
|
|
|
17
|
$expose->{privateExponent} = $self->{privateExponent}; |
16
|
6
|
|
|
|
|
90
|
$expose->{primeP} = $self->{primeP}; |
17
|
6
|
|
|
|
|
15
|
$expose->{primeQ} = $self->{primeQ}; |
18
|
6
|
|
|
|
|
14
|
$expose->{primeExponentP} = $self->{primeExponentP}; |
19
|
6
|
|
|
|
|
12
|
$expose->{primeExponentQ} = $self->{primeExponentQ}; |
20
|
6
|
|
|
|
|
21
|
$expose->{crtCoefficient} = $self->{crtCoefficient}; |
21
|
6
|
|
|
|
|
33
|
return $expose; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub read { |
26
|
58
|
|
|
58
|
0
|
1304
|
my $class = shift; |
27
|
58
|
|
|
|
|
79
|
my $json_string = shift; |
28
|
|
|
|
|
|
|
|
29
|
58
|
|
|
|
|
180
|
my $obj = Crypt::Keyczar::Util::decode_json($json_string); |
30
|
58
|
|
|
|
|
170
|
my $self = bless $obj, $class; |
31
|
58
|
|
|
|
|
197
|
$self->{publicKey} = bless $self->{publicKey}, 'Crypt::Keyczar::RsaPublicKey'; |
32
|
58
|
|
|
|
|
382
|
$self->{publicKey}->init(); |
33
|
58
|
|
|
|
|
270
|
$self->init(); |
34
|
58
|
|
|
|
|
233
|
return $self; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub generate { |
39
|
6
|
|
|
6
|
0
|
12
|
my $class = shift; |
40
|
6
|
|
|
|
|
8
|
my $size = shift; |
41
|
|
|
|
|
|
|
|
42
|
6
|
|
|
|
|
7242217
|
my $key = Crypt::Keyczar::RsaPrivateKeyEngine->generate($size); |
43
|
6
|
|
|
|
|
43
|
my $priv = {}; |
44
|
6
|
|
|
|
|
31
|
$priv->{size} = $size; |
45
|
6
|
|
|
|
|
72
|
$priv->{privateExponent} = Crypt::Keyczar::Util::encode($key->{privateExponent}); |
46
|
6
|
|
|
|
|
29
|
$priv->{primeP} = Crypt::Keyczar::Util::encode($key->{primeP}); |
47
|
6
|
|
|
|
|
23
|
$priv->{primeQ} = Crypt::Keyczar::Util::encode($key->{primeQ}); |
48
|
6
|
|
|
|
|
28
|
$priv->{primeExponentP} = Crypt::Keyczar::Util::encode($key->{primeExponentP}); |
49
|
6
|
|
|
|
|
23
|
$priv->{primeExponentQ} = Crypt::Keyczar::Util::encode($key->{primeExponentQ}); |
50
|
6
|
|
|
|
|
28
|
$priv->{crtCoefficient} = Crypt::Keyczar::Util::encode($key->{crtCoefficient}); |
51
|
6
|
|
|
|
|
52
|
my $self = bless $priv, $class; |
52
|
|
|
|
|
|
|
|
53
|
6
|
|
|
|
|
14
|
my $pub = {}; |
54
|
6
|
|
|
|
|
23
|
$pub->{size} = $size; |
55
|
6
|
|
|
|
|
24
|
$pub->{modulus} = Crypt::Keyczar::Util::encode($key->{modulus}); |
56
|
6
|
50
|
|
|
|
42
|
if (length $key->{publicExponent} < 4) { |
57
|
|
|
|
|
|
|
# padding 32bit big-endian |
58
|
6
|
|
|
|
|
16
|
my $pad = ''; |
59
|
6
|
|
|
|
|
36
|
$pad .= "\x00" x (4 - length $key->{publicExponent}); |
60
|
6
|
|
|
|
|
26
|
$key->{publicExponent} = $pad . $key->{publicExponent}; |
61
|
|
|
|
|
|
|
} |
62
|
6
|
|
|
|
|
24
|
$pub->{publicExponent} = Crypt::Keyczar::Util::encode($key->{publicExponent}); |
63
|
6
|
|
|
|
|
54
|
$self->{publicKey} = bless $pub, 'Crypt::Keyczar::RsaPublicKey'; |
64
|
6
|
|
|
|
|
53
|
$self->{publicKey}->init(); |
65
|
6
|
|
|
|
|
58
|
$self->init(); |
66
|
|
|
|
|
|
|
|
67
|
6
|
|
|
|
|
65
|
return $self; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub get_engine { |
72
|
8
|
|
|
8
|
0
|
815
|
my $self = shift; |
73
|
8
|
|
|
|
|
33
|
my @args = map { Crypt::Keyczar::Util::decode($_) } ( |
|
64
|
|
|
|
|
152
|
|
74
|
|
|
|
|
|
|
$self->get_public->{modulus}, $self->get_public->{publicExponent}, |
75
|
|
|
|
|
|
|
$self->{privateExponent}, $self->{primeP}, $self->{primeQ}, |
76
|
|
|
|
|
|
|
$self->{primeExponentP}, $self->{primeExponentQ}, |
77
|
|
|
|
|
|
|
$self->{crtCoefficient} |
78
|
|
|
|
|
|
|
); |
79
|
8
|
|
|
|
|
71294
|
my $engine = Crypt::Keyczar::RsaPrivateKeyEngine->new(@args); |
80
|
8
|
|
|
|
|
170
|
$self->{_digest_size} = $engine->digest_size; |
81
|
8
|
|
|
|
|
3598
|
return $engine; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
71
|
|
|
71
|
0
|
316
|
sub hash { return $_[0]->get_public->hash(); } |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
2
|
|
|
2
|
0
|
35
|
sub digest_size { return $_[0]->{_digest_size}; } |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
97
|
|
|
97
|
0
|
391
|
sub get_public { return $_[0]->{publicKey}; } |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
package Crypt::Keyczar::RsaPrivateKeyEngine; |
96
|
5
|
|
|
5
|
|
40
|
use base 'Exporter'; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
356
|
|
97
|
5
|
|
|
5
|
|
26
|
use strict; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
158
|
|
98
|
5
|
|
|
5
|
|
24
|
use warnings; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
128
|
|
99
|
5
|
|
|
5
|
|
25
|
use Crypt::Keyczar::Engine; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
132
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |
103
|
|
|
|
|
|
|
__END__ |