OpenPGP/KeyBlock.pm

filter: Statementstmt 72.0% 36 / 50 Branchbran 28.5% 4 / 14 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 73.3% 11 / 15 Podpod 50.0% 6 / 12 totaltotal 56.4% 57 / 101 CC 12 SCAR 25.2
CC
12
Cov
57%
encrypting_key
30.0
signing_key
30.0
primary_uid
2.1
CRAP 12.5
« OpenPGP/KeyRing.pm ↑ Summary OpenPGP/SessionKey.pm »
1 package Crypt::OpenPGP::KeyBlock;
2 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 12 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 12 our $VERSION = '1.21'; # VERSION
6  
7 12 ▶use Crypt::OpenPGP::PacketFactory;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 3 ▶sub primary_uid {
Subroutine primary_uid: called CC=2 SCAR=7.6
Pod undocumented
10 $_[0]->{pkt}{ 'Crypt::OpenPGP::UserID' } ?
11 3 ▶ $_[0]->{pkt}{ 'Crypt::OpenPGP::UserID' }->[0]->id : undef;
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{'pkt'}{'Crypt::OpenPGP::UserID'} ? : 3 0 3
12 }
13  
14 10 ▶sub key { $_[0]->get('Crypt::OpenPGP::Certificate')->[0] }
Subroutine key: called CC=1 SCAR=0.0
Pod undocumented
15 0 ▶sub subkey { $_[0]->get('Crypt::OpenPGP::Certificate')->[1] }
Subroutine subkey: not called CC=1 SCAR=6.9
Pod undocumented
16  
17 0 ▶sub encrypting_key {
Subroutine encrypting_key: not called CC=5 SCAR=34.0
Pod documented
18 0 my $kb = shift;
19 0 my $keys = $kb->get('Crypt::OpenPGP::Certificate');
20 0 ▶ return unless $keys && @$keys;
Branch: 1 branch
BranchTrueFalseTotal
unless $keys and @$keys 0 0 0
Condition0%0/3
$keys and @$keys
!ll&&!rl&&r
000
MC/DC0%0/2
$keys and @$keys
$keys @$keys
Truth table0%0/3
A and B
A= $keysB= @$keys
ABresult
0X0
100
111
21 0 for my $key (@$keys) {
22 0 ▶ return $key if $key->can_encrypt;
Branch: 1 branch
BranchTrueFalseTotal
if $key->can_encrypt 0 0 0
23 }
24 }
25  
26 0 ▶sub signing_key {
Subroutine signing_key: not called CC=5 SCAR=34.0
Pod documented
27 0 my $kb = shift;
28 0 my $keys = $kb->get('Crypt::OpenPGP::Certificate');
29 0 ▶ return unless $keys && @$keys;
Branch: 1 branch
BranchTrueFalseTotal
unless $keys and @$keys 0 0 0
Condition0%0/3
$keys and @$keys
!ll&&!rl&&r
000
MC/DC0%0/2
$keys and @$keys
$keys @$keys
Truth table0%0/3
A and B
A= $keysB= @$keys
ABresult
0X0
100
111
30 0 for my $key (@$keys) {
31 0 ▶ return $key if $key->can_sign;
Branch: 1 branch
BranchTrueFalseTotal
if $key->can_sign 0 0 0
32 }
33 }
34  
35 1 ▶sub key_by_id { $_[0]->{keys_by_id}->{$_[1]} ||
Subroutine key_by_id: called CC=2 SCAR=7.6
Pod undocumented
36 1 ▶ $_[0]->{keys_by_short_id}->{$_[1]} }
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{"keys_by_id"}{$_[1]} or $_[0]{"keys_by_short_id"}{$_[1]} 1 0 1
37  
38 6 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
39 6 my $class = shift;
40 6 my $kb = bless { }, $class;
41 6 $kb->init(@_);
42 }
43  
44 6 ▶sub init {
Subroutine init: called CC=1 SCAR=0.0
Pod undocumented
45 6 my $kb = shift;
46 6 $kb->{pkt} = { };
47 6 $kb->{order} = [ ];
48 6 $kb->{keys_by_id} = { };
49 6 $kb;
50 }
51  
52 12 ▶sub add {
Subroutine add: called CC=2 SCAR=6.9
Pod documented
53 12 my $kb = shift;
54 12 my($pkt) = @_;
55 12 push @{ $kb->{pkt}->{ ref($pkt) } }, $pkt;
56 12 push @{ $kb->{order} }, $pkt;
57 12 ▶ if (ref($pkt) eq 'Crypt::OpenPGP::Certificate') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $pkt eq "Crypt::OpenPGP::Certificate") 5 7 12
58 5 my $kid = $pkt->key_id;
59 4 $kb->{keys_by_id}{ $kid } = $pkt;
60 4 $kb->{keys_by_short_id}{ substr $kid, -4, 4 } = $pkt;
61 }
62 }
63  
64 12 ▶sub get { $_[0]->{pkt}->{ $_[1] } }
Subroutine get: called CC=1 SCAR=0.0
Pod undocumented
65  
66 1 ▶sub save {
Subroutine save: called CC=1 SCAR=0.0
Pod documented
67 1 my $kb = shift;
68 1 Crypt::OpenPGP::PacketFactory->save( @{ $kb->{order} } );
69 }
70  
71 0 ▶sub save_armoured {
Subroutine save_armoured: not called CC=1 SCAR=6.9
Pod documented
72 0 my $kb = shift;
73 0 require Crypt::OpenPGP::Armour;
74 0 Crypt::OpenPGP::Armour->armour(
75 Data => $kb->save,
76 Object => 'PUBLIC KEY BLOCK'
77 );
78 }
79  
80 12 1;
81 __END__
« OpenPGP/KeyRing.pm ↑ Summary OpenPGP/SessionKey.pm »