line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::OpenPGP::Key::Secret::ElGamal; |
2
|
3
|
|
|
3
|
|
15
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
105
|
|
3
|
|
|
|
|
|
|
|
4
|
3
|
|
|
3
|
|
1173
|
use Crypt::OpenPGP::Key::Public::ElGamal; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
93
|
|
5
|
3
|
|
|
3
|
|
16
|
use Crypt::OpenPGP::Key::Secret; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
81
|
|
6
|
3
|
|
|
3
|
|
21
|
use Crypt::OpenPGP::ErrorHandler; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
78
|
|
7
|
3
|
|
|
3
|
|
13
|
use base qw( Crypt::OpenPGP::Key::Secret Crypt::OpenPGP::ErrorHandler ); |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
903
|
|
8
|
|
|
|
|
|
|
|
9
|
22
|
|
|
22
|
0
|
91
|
sub secret_props { qw( x ) } |
10
|
|
|
|
|
|
|
*public_props = \&Crypt::OpenPGP::Key::Public::ElGamal::public_props; |
11
|
|
|
|
|
|
|
*crypt_props = \&Crypt::OpenPGP::Key::Public::ElGamal::crypt_props; |
12
|
|
|
|
|
|
|
*size = \&Crypt::OpenPGP::Key::Public::ElGamal::size; |
13
|
|
|
|
|
|
|
*keygen = \&Crypt::OpenPGP::Key::Public::ElGamal::keygen; |
14
|
|
|
|
|
|
|
*can_encrypt = \&Crypt::OpenPGP::Key::Public::ElGamal::can_encrypt; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub init { |
17
|
18
|
|
|
18
|
0
|
32
|
my $key = shift; |
18
|
18
|
|
33
|
|
|
152
|
$key->{key_data} = shift || Crypt::OpenPGP::ElGamal::Private->new; |
19
|
18
|
|
|
|
|
128
|
$key; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
12
|
|
|
12
|
0
|
88
|
sub decrypt { $_[0]->{key_data}->decrypt(@_[1..$#_]) } |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
package Crypt::OpenPGP::ElGamal::Private; |
25
|
3
|
|
|
3
|
|
20
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
103
|
|
26
|
|
|
|
|
|
|
|
27
|
3
|
|
|
3
|
|
16
|
use Crypt::OpenPGP::Util qw( mod_exp mod_inverse ); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
200
|
|
28
|
3
|
|
|
3
|
|
15
|
use Math::BigInt; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
17
|
|
29
|
|
|
|
|
|
|
|
30
|
18
|
|
|
18
|
|
117
|
sub new { bless {}, $_[0] } |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub decrypt { |
33
|
12
|
|
|
12
|
|
25
|
my $key = shift; |
34
|
12
|
|
|
|
|
19
|
my($C) = @_; |
35
|
12
|
|
|
|
|
41
|
my $p = $key->p; |
36
|
12
|
|
|
|
|
50
|
my $t1 = mod_exp($C->{a}, $key->x, $p); |
37
|
12
|
|
|
|
|
21743217
|
$t1 = mod_inverse($t1, $p); |
38
|
12
|
|
|
|
|
1542522
|
my $n = Math::BigInt->new($C->{b} * $t1); |
39
|
12
|
|
|
|
|
49593
|
$n->bmod($p); |
40
|
12
|
|
|
|
|
74466
|
return $n; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub _getset { |
44
|
12
|
|
|
12
|
|
16
|
my $e = shift; |
45
|
|
|
|
|
|
|
sub { |
46
|
85
|
|
|
85
|
|
127
|
my $key = shift; |
47
|
85
|
100
|
|
|
|
325
|
$key->{$e} = shift if @_; |
48
|
85
|
|
|
|
|
365
|
$key->{$e}; |
49
|
|
|
|
|
|
|
} |
50
|
12
|
|
|
|
|
41
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
*p = _getset('p'); |
53
|
|
|
|
|
|
|
*g = _getset('g'); |
54
|
|
|
|
|
|
|
*y = _getset('y'); |
55
|
|
|
|
|
|
|
*x = _getset('x'); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |