line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::OpenPGP::Signature::SubPacket; |
2
|
4
|
|
|
4
|
|
20
|
use strict; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
249
|
|
3
|
|
|
|
|
|
|
|
4
|
4
|
|
|
4
|
|
23
|
use Crypt::OpenPGP::ErrorHandler; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
119
|
|
5
|
4
|
|
|
4
|
|
20
|
use base qw( Crypt::OpenPGP::ErrorHandler ); |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
371
|
|
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
25
|
use vars qw( %SUBPACKET_TYPES ); |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
7712
|
|
8
|
|
|
|
|
|
|
%SUBPACKET_TYPES = ( |
9
|
|
|
|
|
|
|
2 => { name => 'Signature creation time', |
10
|
|
|
|
|
|
|
r => sub { $_[0]->get_int32 }, |
11
|
|
|
|
|
|
|
w => sub { $_[0]->put_int32($_[1]) } }, |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
3 => { name => 'Signature expiration time', |
14
|
|
|
|
|
|
|
r => sub { $_[0]->get_int32 }, |
15
|
|
|
|
|
|
|
w => sub { $_[0]->put_int32($_[1]) } }, |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
4 => { name => 'Exportable certification', |
18
|
|
|
|
|
|
|
r => sub { $_[0]->get_int8 }, |
19
|
|
|
|
|
|
|
w => sub { $_[0]->put_int8($_[1]) } }, |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
5 => { name => 'Trust signature', |
22
|
|
|
|
|
|
|
r => sub { $_[0]->get_int8 }, |
23
|
|
|
|
|
|
|
w => sub { $_[0]->put_int8($_[1]) } }, |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
6 => { name => 'Regular expression', |
26
|
|
|
|
|
|
|
r => sub { $_[0]->bytes }, |
27
|
|
|
|
|
|
|
w => sub { $_[0]->append($_[1]) } }, |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
7 => { name => 'Revocable', |
30
|
|
|
|
|
|
|
r => sub { $_[0]->get_int8 }, |
31
|
|
|
|
|
|
|
w => sub { $_[0]->put_int8($_[1]) } }, |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
9 => { name => 'Key expiration time', |
34
|
|
|
|
|
|
|
r => sub { $_[0]->get_int32 }, |
35
|
|
|
|
|
|
|
w => sub { $_[0]->put_int32($_[1]) } }, |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
10 => { name => '(Unsupported placeholder', |
38
|
|
|
|
|
|
|
r => sub { }, |
39
|
|
|
|
|
|
|
w => sub { } }, |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
11 => { name => 'Preferred symmetric algorithms', |
42
|
|
|
|
|
|
|
r => sub { [ unpack 'C*', $_[0]->bytes ] }, |
43
|
|
|
|
|
|
|
w => sub { $_[0]->append(pack 'C*', @{ $_[1] }) } }, |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
12 => { name => 'Revocation key', |
46
|
|
|
|
|
|
|
r => sub { |
47
|
|
|
|
|
|
|
{ class => $_[0]->get_int8, |
48
|
|
|
|
|
|
|
alg_id => $_[0]->get_int8, |
49
|
|
|
|
|
|
|
fingerprint => $_[0]->get_bytes(20) } }, |
50
|
|
|
|
|
|
|
w => sub { |
51
|
|
|
|
|
|
|
$_[0]->put_int8($_[1]->{class}); |
52
|
|
|
|
|
|
|
$_[0]->put_int8($_[1]->{alg_id}); |
53
|
|
|
|
|
|
|
$_[0]->put_bytes($_[1]->{fingerprint}, 20) } }, |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
16 => { name => 'Issuer key ID', |
56
|
|
|
|
|
|
|
r => sub { $_[0]->get_bytes(8) }, |
57
|
|
|
|
|
|
|
w => sub { $_[0]->put_bytes($_[1], 8) } }, |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
20 => { name => 'Notation data', |
60
|
|
|
|
|
|
|
r => sub { |
61
|
|
|
|
|
|
|
{ flags => $_[0]->get_int32, |
62
|
|
|
|
|
|
|
name => $_[0]->get_bytes($_[0]->get_int16), |
63
|
|
|
|
|
|
|
value => $_[0]->get_bytes($_[0]->get_int16) } }, |
64
|
|
|
|
|
|
|
w => sub { |
65
|
|
|
|
|
|
|
$_[0]->put_int32($_[1]->{flags}); |
66
|
|
|
|
|
|
|
$_[0]->put_int16(length $_[1]->{name}); |
67
|
|
|
|
|
|
|
$_[0]->put_bytes($_[1]->{name}); |
68
|
|
|
|
|
|
|
$_[0]->put_int16(length $_[1]->{value}); |
69
|
|
|
|
|
|
|
$_[0]->put_bytes($_[1]->{value}) } }, |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
21 => { name => 'Preferred hash algorithms', |
72
|
|
|
|
|
|
|
r => sub { [ unpack 'C', $_[0]->bytes ] }, |
73
|
|
|
|
|
|
|
w => sub { $_[0]->put_bytes(pack 'C*', @{ $_[1] }) } }, |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
22 => { name => 'Preferred compression algorithms', |
76
|
|
|
|
|
|
|
r => sub { [ unpack 'C', $_[0]->bytes ] }, |
77
|
|
|
|
|
|
|
w => sub { $_[0]->put_bytes(pack 'C*', @{ $_[1] }) } }, |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
23 => { name => 'Key server preferences', |
80
|
|
|
|
|
|
|
r => sub { $_[0]->bytes }, |
81
|
|
|
|
|
|
|
w => sub { $_[0]->append($_[1]) } }, |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
24 => { name => 'Preferred key server', |
84
|
|
|
|
|
|
|
r => sub { $_[0]->bytes }, |
85
|
|
|
|
|
|
|
w => sub { $_[0]->append($_[1]) } }, |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
25 => { name => 'Primary user ID', |
88
|
|
|
|
|
|
|
r => sub { $_[0]->get_int8 }, |
89
|
|
|
|
|
|
|
w => sub { $_[0]->put_int8($_[1]) } }, |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
26 => { name => 'Policy URL', |
92
|
|
|
|
|
|
|
r => sub { $_[0]->bytes }, |
93
|
|
|
|
|
|
|
w => sub { $_[0]->append($_[1]) } }, |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
27 => { name => 'Key flags', |
96
|
|
|
|
|
|
|
r => sub { $_[0]->bytes }, |
97
|
|
|
|
|
|
|
w => sub { $_[0]->append($_[1]) } }, |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
28 => { name => 'Signer\'s user ID', |
100
|
|
|
|
|
|
|
r => sub { $_[0]->bytes }, |
101
|
|
|
|
|
|
|
w => sub { $_[0]->append($_[1]) } }, |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
29 => { name => 'Reason for revocation', |
104
|
|
|
|
|
|
|
r => sub { |
105
|
|
|
|
|
|
|
{ code => $_[0]->get_int8, |
106
|
|
|
|
|
|
|
reason => $_[0]->get_bytes($_[0]->length - |
107
|
|
|
|
|
|
|
$_[0]->offset) } }, |
108
|
|
|
|
|
|
|
w => sub { |
109
|
|
|
|
|
|
|
$_[0]->put_int8($_[1]->{code}); |
110
|
|
|
|
|
|
|
$_[0]->put_bytes($_[1]->{reason}) } }, |
111
|
|
|
|
|
|
|
); |
112
|
|
|
|
|
|
|
|
113
|
168
|
|
|
168
|
0
|
360
|
sub new { bless { }, $_[0] } |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub parse { |
116
|
154
|
|
|
154
|
0
|
213
|
my $class = shift; |
117
|
154
|
|
|
|
|
185
|
my($buf) = @_; |
118
|
154
|
|
|
|
|
304
|
my $sp = $class->new; |
119
|
154
|
|
|
|
|
351
|
my $tag = $buf->get_int8; |
120
|
154
|
|
|
|
|
1644
|
$sp->{critical} = $tag & 0x80; |
121
|
154
|
|
|
|
|
230
|
$sp->{type} = $tag & 0x7f; |
122
|
154
|
|
|
|
|
346
|
$buf->bytes(0, 1, ''); ## Cut off tag byte |
123
|
154
|
|
|
|
|
969
|
$buf->{offset} = 0; |
124
|
154
|
|
|
|
|
414
|
my $ref = $SUBPACKET_TYPES{$sp->{type}}; |
125
|
154
|
50
|
33
|
|
|
932
|
$sp->{data} = $ref->{r}->($buf) if $ref && $ref->{r}; |
126
|
154
|
|
|
|
|
1817
|
$sp; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub save { |
130
|
28
|
|
|
28
|
0
|
39
|
my $sp = shift; |
131
|
28
|
|
|
|
|
88
|
my $buf = Crypt::OpenPGP::Buffer->new; |
132
|
28
|
|
|
|
|
185
|
my $tag = $sp->{type}; |
133
|
28
|
50
|
|
|
|
103
|
$tag |= 0x80 if $sp->{critical}; |
134
|
28
|
|
|
|
|
77
|
$buf->put_int8($tag); |
135
|
28
|
|
|
|
|
198
|
my $ref = $SUBPACKET_TYPES{$sp->{type}}; |
136
|
28
|
50
|
33
|
|
|
209
|
$ref->{w}->($buf, $sp->{data}) if $ref && $ref->{w}; |
137
|
28
|
|
|
|
|
232
|
$buf->bytes; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
1; |