1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
package Crypt::OpenPGP::Constants;
use strict;
use vars qw( %CONSTANTS );
%CONSTANTS = (
'PGP_PKT_PUBKEY_ENC' => 1,
'PGP_PKT_SIGNATURE' => 2,
'PGP_PKT_SYMKEY_ENC' => 3,
'PGP_PKT_ONEPASS_SIG' => 4,
'PGP_PKT_SECRET_KEY' => 5,
'PGP_PKT_PUBLIC_KEY' => 6,
'PGP_PKT_SECRET_SUBKEY' => 7,
'PGP_PKT_COMPRESSED' => 8,
'PGP_PKT_ENCRYPTED' => 9,
'PGP_PKT_MARKER' => 10,
'PGP_PKT_PLAINTEXT' => 11,
'PGP_PKT_RING_TRUST' => 12,
'PGP_PKT_USER_ID' => 13,
'PGP_PKT_PUBLIC_SUBKEY' => 14,
'PGP_PKT_ENCRYPTED_MDC' => 18,
'PGP_PKT_MDC' => 19,
'DEFAULT_CIPHER' => 2,
'DEFAULT_DIGEST' => 2,
'DEFAULT_COMPRESS' => 1,
);
use vars qw( %TAGS );
my %RULES = (
'^PGP_PKT' => 'packet',
);
for my $re (keys %RULES) {
$TAGS{ $RULES{$re} } = [ grep /$re/, keys %CONSTANTS ];
}
sub import {
my $class = shift;
my @to_export;
my @args = @_;
for my $item (@args) {
push @to_export,
$item =~ s/^:// ? @{ $TAGS{$item} } : $item;
}
no strict 'refs';
my $pkg = caller;
for my $con (@to_export) {
warn __PACKAGE__, " does not export the constant '$con'"
unless exists $CONSTANTS{$con};
*{"${pkg}::$con"} = sub () { $CONSTANTS{$con} }
}
}
1;
__END__
=head1 NAME
Crypt::OpenPGP::Constants - Exportable constants
=head1 DESCRIPTION
I<Crypt::OpenPGP::Constants> provides a list of common and useful
constants for use in I<Crypt::OpenPGP>.
=head1 USAGE
None of the constants are exported by default; you have to ask for
them explicitly. Some of the constants are grouped into bundles that
you can grab all at once; alternatively you can just take the
individual constants, one by one.
If you wish to import a group, your I<use> statement should look
something like this:
use Crypt::OpenPGP::Constants qw( :group );
Here are the groups:
=over 4
=item * packet
All of the I<PGP_PKT_*> constants. These are constants that define
packet types.
=back
Other exportable constants, not belonging to a group, are:
=over 4
=item * DEFAULT_CIPHER
=item * DEFAULT_DIGEST
=item * DEFAULT_COMPRESS
Default cipher, digest, and compression algorithms, to be used if no
specific cipher, digest, or compression algorithm is otherwise
specified.
=back
=head1 AUTHOR & COPYRIGHTS
Please see the Crypt::OpenPGP manpage for author, copyright, and
license information.
=cut
|