| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Crypt::OpenPGP::Config; |
|
2
|
7
|
|
|
7
|
|
33
|
use strict; |
|
|
7
|
|
|
|
|
10
|
|
|
|
7
|
|
|
|
|
221
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
7
|
|
|
7
|
|
35
|
use Crypt::OpenPGP::ErrorHandler; |
|
|
7
|
|
|
|
|
11
|
|
|
|
7
|
|
|
|
|
189
|
|
|
5
|
7
|
|
|
7
|
|
36
|
use base qw( Crypt::OpenPGP::ErrorHandler ); |
|
|
7
|
|
|
|
|
9
|
|
|
|
7
|
|
|
|
|
6726
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub new { |
|
8
|
8
|
|
|
8
|
0
|
5031
|
my $class = shift; |
|
9
|
8
|
|
|
|
|
43
|
my $cfg = bless { o => { @_ } }, $class; |
|
10
|
8
|
|
|
|
|
68
|
$cfg; |
|
11
|
|
|
|
|
|
|
} |
|
12
|
|
|
|
|
|
|
|
|
13
|
84
|
|
|
84
|
0
|
7170
|
sub get { $_[0]->{o}{ $_[1] } } |
|
14
|
|
|
|
|
|
|
sub set { |
|
15
|
4
|
|
|
4
|
0
|
8
|
my $cfg = shift; |
|
16
|
4
|
|
|
|
|
10
|
my($key, $val) = @_; |
|
17
|
4
|
|
|
|
|
13
|
$cfg->{o}{$key} = $val; |
|
18
|
|
|
|
|
|
|
} |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
{ |
|
21
|
|
|
|
|
|
|
my %STANDARD = ( |
|
22
|
|
|
|
|
|
|
str => \&_set_str, |
|
23
|
|
|
|
|
|
|
bool => \&_set_bool, |
|
24
|
|
|
|
|
|
|
); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub read_config { |
|
27
|
4
|
|
|
4
|
0
|
1650
|
my $cfg = shift; |
|
28
|
4
|
|
|
|
|
10
|
my($compat, $cfg_file) = @_; |
|
29
|
4
|
|
|
|
|
15
|
my $class = join '::', __PACKAGE__, $compat; |
|
30
|
4
|
|
|
|
|
29
|
my $directives = $class->directives; |
|
31
|
4
|
|
|
|
|
21
|
local(*FH, $_, $/); |
|
32
|
4
|
|
|
|
|
8
|
$/ = "\n"; |
|
33
|
4
|
50
|
|
|
|
193
|
open FH, $cfg_file or |
|
34
|
|
|
|
|
|
|
return $cfg->error("Error opening file '$cfg_file': $!"); |
|
35
|
4
|
|
|
|
|
78
|
while (<FH>) { |
|
36
|
12
|
|
|
|
|
17
|
chomp; |
|
37
|
12
|
50
|
33
|
|
|
91
|
next if !/\S/ || /^#/; |
|
38
|
12
|
50
|
|
|
|
63
|
if (/^\s*([^\s=]+)(?:(?:(?:\s*=\s*)|\s+)(.*))?/) { |
|
39
|
12
|
|
|
|
|
44
|
my($key, $val) = ($1, $2); |
|
40
|
12
|
|
|
|
|
26
|
my $ref = $directives->{lc $key}; |
|
41
|
12
|
50
|
|
|
|
28
|
next unless $ref; |
|
42
|
|
|
|
|
|
|
my $code = ref($ref->[0]) eq 'CODE' ? $ref->[0] : |
|
43
|
12
|
100
|
|
|
|
39
|
$STANDARD{$ref->[0]}; |
|
44
|
12
|
|
|
|
|
35
|
$code->($cfg, $ref->[1], $val); |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
} |
|
47
|
4
|
|
|
|
|
71
|
close FH; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
4
|
|
|
4
|
|
35
|
sub _set_str { $_[0]->{o}{$_[1]} = $_[2] } |
|
52
|
|
|
|
|
|
|
{ |
|
53
|
|
|
|
|
|
|
my %BOOL = ( off => 0, on => 1 ); |
|
54
|
|
|
|
|
|
|
sub _set_bool { |
|
55
|
4
|
|
|
4
|
|
10
|
my($cfg, $key, $val) = @_; |
|
56
|
4
|
100
|
|
|
|
11
|
$val = 1 unless defined $val; |
|
57
|
4
|
|
66
|
|
|
19
|
$val = $BOOL{$val} || $val; |
|
58
|
4
|
|
|
|
|
34
|
$cfg->{o}{$key} = $val; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
package Crypt::OpenPGP::Config::GnuPG; |
|
63
|
|
|
|
|
|
|
sub directives { |
|
64
|
|
|
|
|
|
|
{ |
|
65
|
2
|
|
|
2
|
|
68
|
armor => [ 'bool', 'Armour' ], |
|
66
|
|
|
|
|
|
|
'default-key' => [ 'str', 'DefaultKey' ], |
|
67
|
|
|
|
|
|
|
recipient => [ 'str', 'Recipient' ], |
|
68
|
|
|
|
|
|
|
'default-recipient' => [ 'str', 'DefaultRecipient' ], |
|
69
|
|
|
|
|
|
|
'default-recipient-self' => [ 'bool', 'DefaultSelfRecipient' ], |
|
70
|
|
|
|
|
|
|
'encrypt-to' => [ 'str', 'Recipient' ], |
|
71
|
|
|
|
|
|
|
verbose => [ 'bool', 'Verbose' ], |
|
72
|
|
|
|
|
|
|
textmode => [ 'bool', 'TextMode' ], |
|
73
|
|
|
|
|
|
|
keyring => [ 'str', 'PubRing' ], |
|
74
|
|
|
|
|
|
|
'secret-keyring' => [ 'str', 'SecRing' ], |
|
75
|
|
|
|
|
|
|
'cipher-algo' => [ \&_set_cipher ], |
|
76
|
|
|
|
|
|
|
'digest-algo' => [ 'str', 'Digest' ], |
|
77
|
|
|
|
|
|
|
'compress-algo' => [ \&_set_compress ], |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
{ |
|
82
|
|
|
|
|
|
|
my %Ciphers = ( |
|
83
|
|
|
|
|
|
|
'3DES' => 'DES3', BLOWFISH => 'Blowfish', |
|
84
|
|
|
|
|
|
|
RIJNDAEL => 'Rijndael', RIJNDAEL192 => 'Rijndael192', |
|
85
|
|
|
|
|
|
|
RIJNDAEL256 => 'Rijndael256', TWOFISH => 'Twofish', |
|
86
|
|
|
|
|
|
|
CAST5 => 'CAST5', |
|
87
|
|
|
|
|
|
|
); |
|
88
|
2
|
|
|
2
|
|
14
|
sub _set_cipher { $_[0]->{o}{Cipher} = $Ciphers{$_[2]} } |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
my %Compress = ( 1 => 'ZIP', 2 => 'Zlib' ); |
|
91
|
2
|
|
|
2
|
|
29
|
sub _set_compress { $_[0]->{o}{Compress} = $Compress{$_[2]} } |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
package Crypt::OpenPGP::Config::PGP2; |
|
95
|
|
|
|
|
|
|
sub directives { |
|
96
|
|
|
|
|
|
|
{ |
|
97
|
2
|
|
|
2
|
|
26
|
armor => [ 'bool', 'Armour' ], |
|
98
|
|
|
|
|
|
|
compress => [ 'bool', 'Compress' ], |
|
99
|
|
|
|
|
|
|
encrypttoself => [ 'bool', 'EncryptToSelf' ], |
|
100
|
|
|
|
|
|
|
myname => [ 'str', 'DefaultSelfRecipient' ], |
|
101
|
|
|
|
|
|
|
pubring => [ 'str', 'PubRing' ], |
|
102
|
|
|
|
|
|
|
secring => [ 'str', 'SecRing' ], |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
package Crypt::OpenPGP::Config::PGP5; |
|
107
|
|
|
|
|
|
|
*directives = \&Crypt::OpenPGP::Config::PGP2::directives; |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
1; |