| 1 | package Crypt::OpenPGP::Signature::SubPacket; | ||||||||||||||||||||||||||||
| 2 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 7 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 7 | our $VERSION = '1.21'; # VERSION | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 7 | ▶ | use parent qw( Crypt::OpenPGP::ErrorHandler ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | our %SUBPACKET_TYPES = ( | ||||||||||||||||||||||||||||
| 10 | 2 => { name => 'Signature creation time', | ||||||||||||||||||||||||||||
| 11 | 6 | ▶ | r => sub { $_[0]->get_int32 }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 3 | ▶ | w => sub { $_[0]->put_int32($_[1]) } }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 3 => { name => 'Signature expiration time', | ||||||||||||||||||||||||||||
| 15 | 0 | ▶ | r => sub { $_[0]->get_int32 }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 16 | 0 | ▶ | w => sub { $_[0]->put_int32($_[1]) } }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 4 => { name => 'Exportable certification', | ||||||||||||||||||||||||||||
| 19 | 0 | ▶ | r => sub { $_[0]->get_int8 }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 20 | 0 | ▶ | w => sub { $_[0]->put_int8($_[1]) } }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 5 => { name => 'Trust signature', | ||||||||||||||||||||||||||||
| 23 | 0 | ▶ | r => sub { $_[0]->get_int8 }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 24 | 0 | ▶ | w => sub { $_[0]->put_int8($_[1]) } }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 6 => { name => 'Regular expression', | ||||||||||||||||||||||||||||
| 27 | 0 | ▶ | r => sub { $_[0]->bytes }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 28 | 0 | ▶ | w => sub { $_[0]->append($_[1]) } }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 7 => { name => 'Revocable', | ||||||||||||||||||||||||||||
| 31 | 0 | ▶ | r => sub { $_[0]->get_int8 }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 32 | 0 | ▶ | w => sub { $_[0]->put_int8($_[1]) } }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 9 => { name => 'Key expiration time', | ||||||||||||||||||||||||||||
| 35 | 0 | ▶ | r => sub { $_[0]->get_int32 }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 36 | 0 | ▶ | w => sub { $_[0]->put_int32($_[1]) } }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 10 => { name => '(Unsupported placeholder', | ||||||||||||||||||||||||||||
| 39 | 0 | ▶ | r => sub { }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 40 | 0 | ▶ | w => sub { } }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 11 => { name => 'Preferred symmetric algorithms', | ||||||||||||||||||||||||||||
| 43 | 2 | ▶ | r => sub { [ unpack 'C*', $_[0]->bytes ] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 44 | 1 | ▶ | w => sub { $_[0]->append(pack 'C*', @{ $_[1] }) } }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 12 => { name => 'Revocation key', | ||||||||||||||||||||||||||||
| 47 | 0 | ▶ | r => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 48 | 0 | { class => $_[0]->get_int8, | |||||||||||||||||||||||||||
| 49 | alg_id => $_[0]->get_int8, | ||||||||||||||||||||||||||||
| 50 | fingerprint => $_[0]->get_bytes(20) } }, | ||||||||||||||||||||||||||||
| 51 | 0 | ▶ | w => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 52 | 0 | $_[0]->put_int8($_[1]->{class}); | |||||||||||||||||||||||||||
| 53 | 0 | $_[0]->put_int8($_[1]->{alg_id}); | |||||||||||||||||||||||||||
| 54 | 0 | $_[0]->put_bytes($_[1]->{fingerprint}, 20) } }, | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 16 => { name => 'Issuer key ID', | ||||||||||||||||||||||||||||
| 57 | 6 | ▶ | r => sub { $_[0]->get_bytes(8) }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 58 | 2 | ▶ | w => sub { $_[0]->put_bytes($_[1], 8) } }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 20 => { name => 'Notation data', | ||||||||||||||||||||||||||||
| 61 | 1 | ▶ | r => sub { my $flags = $_[0]->get_int32; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 62 | 1 | my $namelen = $_[0]->get_int16; | |||||||||||||||||||||||||||
| 63 | 1 | my $valuelen = $_[0]->get_int16; | |||||||||||||||||||||||||||
| 64 | 1 | { flags => $flags, | |||||||||||||||||||||||||||
| 65 | name => $_[0]->get_bytes($namelen), | ||||||||||||||||||||||||||||
| 66 | value => $_[0]->get_bytes($valuelen) } }, | ||||||||||||||||||||||||||||
| 67 | 1 | ▶ | w => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 68 | 1 | $_[0]->put_int32($_[1]->{flags}); | |||||||||||||||||||||||||||
| 69 | 1 | $_[0]->put_int16(length $_[1]->{name}); | |||||||||||||||||||||||||||
| 70 | 1 | $_[0]->put_int16(length $_[1]->{value}); | |||||||||||||||||||||||||||
| 71 | 1 | $_[0]->put_bytes($_[1]->{name}); | |||||||||||||||||||||||||||
| 72 | 1 | $_[0]->put_bytes($_[1]->{value}) } }, | |||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 21 => { name => 'Preferred hash algorithms', | ||||||||||||||||||||||||||||
| 75 | 2 | ▶ | r => sub { [ unpack 'C*', $_[0]->bytes ] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 76 | 1 | ▶ | w => sub { $_[0]->put_bytes(pack 'C*', @{ $_[1] }) } }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 22 => { name => 'Preferred compression algorithms', | ||||||||||||||||||||||||||||
| 79 | 2 | ▶ | r => sub { [ unpack 'C*', $_[0]->bytes ] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 80 | 1 | ▶ | w => sub { $_[0]->put_bytes(pack 'C*', @{ $_[1] }) } }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 23 => { name => 'Key server preferences', | ||||||||||||||||||||||||||||
| 83 | 2 | ▶ | r => sub { $_[0]->bytes }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 84 | 1 | ▶ | w => sub { $_[0]->append($_[1]) } }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 24 => { name => 'Preferred key server', | ||||||||||||||||||||||||||||
| 87 | 0 | ▶ | r => sub { $_[0]->bytes }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 88 | 0 | ▶ | w => sub { $_[0]->append($_[1]) } }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 25 => { name => 'Primary user ID', | ||||||||||||||||||||||||||||
| 91 | 0 | ▶ | r => sub { $_[0]->get_int8 }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 92 | 0 | ▶ | w => sub { $_[0]->put_int8($_[1]) } }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 26 => { name => 'Policy URL', | ||||||||||||||||||||||||||||
| 95 | 0 | ▶ | r => sub { $_[0]->bytes }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 96 | 0 | ▶ | w => sub { $_[0]->append($_[1]) } }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 27 => { name => 'Key flags', | ||||||||||||||||||||||||||||
| 99 | 3 | ▶ | r => sub { $_[0]->bytes }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 100 | 1 | ▶ | w => sub { $_[0]->append($_[1]) } }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 28 => { name => 'Signer\'s user ID', | ||||||||||||||||||||||||||||
| 103 | 0 | ▶ | r => sub { $_[0]->bytes }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 104 | 0 | ▶ | w => sub { $_[0]->append($_[1]) } }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 29 => { name => 'Reason for revocation', | ||||||||||||||||||||||||||||
| 107 | 0 | ▶ | r => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 108 | 0 | { code => $_[0]->get_int8, | |||||||||||||||||||||||||||
| 109 | reason => $_[0]->get_bytes($_[0]->length - | ||||||||||||||||||||||||||||
| 110 | $_[0]->offset) } }, | ||||||||||||||||||||||||||||
| 111 | 0 | ▶ | w => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 112 | 0 | $_[0]->put_int8($_[1]->{code}); | |||||||||||||||||||||||||||
| 113 | 0 | $_[0]->put_bytes($_[1]->{reason}) } }, | |||||||||||||||||||||||||||
| 114 | 7 | ); | |||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 26 | ▶ | sub new { bless { }, $_[0] } | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 26 | ▶ | sub parse { | ||||||||||||||||||||||||||
|
Subroutine
parse: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 119 | 26 | my $class = shift; | |||||||||||||||||||||||||||
| 120 | 26 | my($buf) = @_; | |||||||||||||||||||||||||||
| 121 | 26 | my $sp = $class->new; | |||||||||||||||||||||||||||
| 122 | 26 | my $tag = $buf->get_int8; | |||||||||||||||||||||||||||
| 123 | 26 | $sp->{critical} = $tag & 0x80; | |||||||||||||||||||||||||||
| 124 | 26 | $sp->{type} = $tag & 0x7f; | |||||||||||||||||||||||||||
| 125 | 26 | $buf->bytes(0, 1, ''); ## Cut off tag byte | |||||||||||||||||||||||||||
| 126 | 26 | $buf->{offset} = 0; | |||||||||||||||||||||||||||
| 127 | 26 | my $ref = $SUBPACKET_TYPES{$sp->{type}}; | |||||||||||||||||||||||||||
| 128 | 26 | ▶ | if( defined $ref ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 129 | 24 | ▶ | $sp->{data} = $ref->{r}->($buf) if $ref && $ref->{r}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$ref and $ref->{"r"}
MC/DC0%0/2
$ref and $ref->{"r"}
$ref
$ref->{"r"}
Truth table33%1/3
A and B
A= $refB= $ref->{"r"}
| |||||||||||||||||||||||||||||
| 130 | } else { | ||||||||||||||||||||||||||||
| 131 | 2 | $sp->{data} = $buf->bytes; | |||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||
| 133 | 26 | $sp; | |||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | 12 | ▶ | sub save { | ||||||||||||||||||||||||||
|
Subroutine
save: called CC=5 SCAR=16.6
Pod
undocumented
| |||||||||||||||||||||||||||||
| 137 | 12 | my $sp = shift; | |||||||||||||||||||||||||||
| 138 | 12 | my $buf = Crypt::OpenPGP::Buffer->new; | |||||||||||||||||||||||||||
| 139 | 12 | my $tag = $sp->{type}; | |||||||||||||||||||||||||||
| 140 | 12 | ▶ | $tag |= 0x80 if $sp->{critical}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 141 | 12 | $buf->put_int8($tag); | |||||||||||||||||||||||||||
| 142 | 12 | my $ref = $SUBPACKET_TYPES{$sp->{type}}; | |||||||||||||||||||||||||||
| 143 | 12 | ▶ | if( defined $ref ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 144 | 11 | ▶ | $ref->{w}->($buf, $sp->{data}) if $ref && $ref->{w}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$ref and $ref->{"w"}
MC/DC0%0/2
$ref and $ref->{"w"}
$ref
$ref->{"w"}
Truth table33%1/3
A and B
A= $refB= $ref->{"w"}
| |||||||||||||||||||||||||||||
| 145 | } else { | ||||||||||||||||||||||||||||
| 146 | 1 | $buf->put_bytes($sp->{data}); | |||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||
| 148 | 12 | $buf->bytes; | |||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | 7 | 1; | |||||||||||||||||||||||||||