line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::OpenPGP::Key::Secret::RSA; |
2
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
42
|
|
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
7
|
use Crypt::RSA::Key::Private; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
5
|
1
|
|
|
1
|
|
6
|
use Crypt::OpenPGP::Key::Public::RSA; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
45
|
|
6
|
1
|
|
|
1
|
|
6
|
use Crypt::OpenPGP::Key::Secret; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
7
|
1
|
|
|
1
|
|
5
|
use Crypt::OpenPGP::Util qw( bin2mp ); |
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
81
|
|
8
|
1
|
|
|
1
|
|
7
|
use Crypt::OpenPGP::ErrorHandler; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
36
|
|
9
|
1
|
|
|
1
|
|
7
|
use base qw( Crypt::OpenPGP::Key::Secret Crypt::OpenPGP::ErrorHandler ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
575
|
|
10
|
|
|
|
|
|
|
|
11
|
3
|
|
|
3
|
0
|
18
|
sub secret_props { qw( d p q u ) } |
12
|
|
|
|
|
|
|
*sig_props = \&Crypt::OpenPGP::Key::Public::RSA::sig_props; |
13
|
|
|
|
|
|
|
*public_props = \&Crypt::OpenPGP::Key::Public::RSA::public_props; |
14
|
|
|
|
|
|
|
*crypt_props = \&Crypt::OpenPGP::Key::Public::RSA::crypt_props; |
15
|
|
|
|
|
|
|
*size = \&Crypt::OpenPGP::Key::Public::RSA::size; |
16
|
|
|
|
|
|
|
*encode = \&Crypt::OpenPGP::Key::Public::RSA::encode; |
17
|
|
|
|
|
|
|
*keygen = \&Crypt::OpenPGP::Key::Public::RSA::keygen; |
18
|
|
|
|
|
|
|
*can_encrypt = \&Crypt::OpenPGP::Key::Public::RSA::can_encrypt; |
19
|
|
|
|
|
|
|
*can_sign = \&Crypt::OpenPGP::Key::Public::RSA::can_sign; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub init { |
22
|
1
|
|
|
1
|
0
|
2
|
my $key = shift; |
23
|
|
|
|
|
|
|
$key->{key_data} = shift || |
24
|
1
|
|
33
|
|
|
9
|
Crypt::RSA::Key::Private->new( Password => 'pgp' ); |
25
|
1
|
|
|
|
|
5
|
$key; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
*encrypt = \&Crypt::OpenPGP::Key::Public::RSA::encrypt; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub decrypt { |
31
|
0
|
|
|
0
|
0
|
0
|
my $key = shift; |
32
|
0
|
|
|
|
|
0
|
my($C) = @_; |
33
|
0
|
|
|
|
|
0
|
require Crypt::RSA::Primitives; |
34
|
0
|
|
|
|
|
0
|
my $prim = Crypt::RSA::Primitives->new; |
35
|
0
|
|
|
|
|
0
|
$prim->core_decrypt( Key => $key->{key_data}, Cyphertext => $C->{c} ); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub sign { |
39
|
1
|
|
|
1
|
0
|
2
|
my $key = shift; |
40
|
1
|
|
|
|
|
3
|
my($dgst, $hash_alg) = @_; |
41
|
1
|
|
|
|
|
12
|
my $m = encode($dgst, $hash_alg, $key->bytesize - 1); |
42
|
1
|
|
|
|
|
881
|
require Crypt::RSA::Primitives; |
43
|
1
|
|
|
|
|
3415
|
my $prim = Crypt::RSA::Primitives->new; |
44
|
1
|
|
|
|
|
11
|
$m = bin2mp($m); |
45
|
1
|
|
|
|
|
1995
|
my $c = $prim->core_sign( Key => $key->{key_data}, Message => $m ); |
46
|
1
|
|
|
|
|
1432117
|
{ c => $c } |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |