lib/Crypt/Perl/X509/Extension/cRLDistributionPoints.pm

filter: Statementstmt 96.2% 51 / 53 Branchbran 80.0% 8 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 1 totaltotal 93.2% 69 / 74 CC 7 SCAR 13.0
CC
7
Cov
94%
new
7.1
BEGIN
1.0
BEGIN
1.0
CRAP 3.7
« lib/Crypt/Perl/ECDSA/EncodedPoint.pm ↑ Summary blib/lib/Crypt/Perl/ToDER.pm »
1 package Crypt::Perl::X509::Extension::cRLDistributionPoints;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 =encoding utf-8
7  
8 =head1 NAME
9  
10 Crypt::Perl::X509::Extension::cRLDistributionPoints
11  
12 =head1 SEE ALSO
13  
14 L<https://tools.ietf.org/html/rfc5280#section-4.2.1.13>
15  
16 =cut
17  
18 1 ▶use parent qw( Crypt::Perl::X509::Extension );
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 1 ▶use Crypt::Perl::ASN1::BitString ();
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use Crypt::Perl::X509::GeneralNames ();
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use Crypt::Perl::X509::RelativeDistinguishedName ();
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 use constant {
25 1 OID => '2.5.29.31',
26 CRITICAL => 0,
27 1 ▶};
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 1 ▶use constant ASN1 => Crypt::Perl::X509::GeneralNames::ASN1() . <<END;
Subroutine BEGIN: called CC=1 SCAR=0.0
30  
31 DistributionPointName ::= CHOICE {
32 fullName ANY, -- [0] GeneralNames
33 nameRelativeToCRLIssuer ANY -- [1] RelativeDistinguishedName
34 }
35  
36 DistributionPoint ::= SEQUENCE {
37 distributionPoint [0] DistributionPointName OPTIONAL,
38 reasons [1] BIT STRING OPTIONAL,
39 cRLIssuer ANY OPTIONAL -- [2] GeneralNames OPTIONAL
40 }
41  
42 cRLDistributionPoints ::= SEQUENCE OF DistributionPoint
43 END
44  
45 1 my @_ReasonFlags = qw(
46 unused
47 keyCompromise
48 cACompromise
49 affiliationChanged
50 superseded
51 cessationOfOperation
52 certificateHold
53 privilegeWithdrawn
54 aACompromise
55 );
56  
57 sub new {
58 12 ▶ my ($class, @points) = @_;
Subroutine new: called CC=7 SCAR=19.6
Pod undocumented
59  
60 12 my @self;
61  
62 12 for my $p (@points) {
63 24 my %pp = %$p;
64 24 push @self, \%pp;
65  
66 24 ▶ if ( $pp{'distributionPoint'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pp{"distributionPoint"}) 24 0 24
67 24 my $dp = $pp{'distributionPoint'};
68  
69 24 ▶ if ($dp->{'fullName'}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($dp->{'fullName'}) { } 12 12 24
elsif ($dp->{'nameRelativeToCRLIssuer'}) { } 12 0 12
70 12 my $gns = Crypt::Perl::X509::GeneralNames->new( @{ $pp{'distributionPoint'}{'fullName'} } );
71  
72 12 $pp{'distributionPoint'} = {
73 fullName => $gns->encode(),
74 };
75  
76 12 substr( $pp{'distributionPoint'}{'fullName'}, 0, 1, "\xa0" );
77 }
78 elsif ($dp->{'nameRelativeToCRLIssuer'}) {
79 12 my $rdn = Crypt::Perl::X509::RelativeDistinguishedName->new( @{ $dp->{'nameRelativeToCRLIssuer'} } );
80  
81 12 $pp{'distributionPoint'} = {
82 nameRelativeToCRLIssuer => $rdn->encode(),
83 };
84  
85 12 substr( $pp{'distributionPoint'}{'nameRelativeToCRLIssuer'}, 0, 1, "\xa1" );
86 }
87 else {
88 0 my @keys = keys %$dp;
89 0 die Crypt::Perl::X::create('Generic', "Unrecognized “distributionPoint” hash! (@keys)");
90 }
91 }
92  
93 24 ▶ if ( $pp{'reasons'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pp{"reasons"}) 12 12 24
94 $pp{'reasons'} = Crypt::Perl::ASN1::BitString::encode(
95 \@_ReasonFlags,
96 12 $pp{'reasons'},
97 );
98 }
99  
100 24 ▶ if ( $pp{'cRLIssuer'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pp{"cRLIssuer"}) 12 12 24
101 12 $pp{'cRLIssuer'} = Crypt::Perl::X509::GeneralNames->new( @{ $pp{'cRLIssuer'} } )->encode();
102 12 substr( $pp{'cRLIssuer'}, 0, 1, "\xa2" );
103 }
104 }
105  
106 12 return bless \@self, $class;
107 }
108  
109 sub _encode_params {
110 12 ▶ my ($self) = @_;
Subroutine _encode_params: called CC=1 SCAR=0.0
111  
112 12 return [ @$self ];
113 }
114  
115 1 1;
« lib/Crypt/Perl/ECDSA/EncodedPoint.pm ↑ Summary blib/lib/Crypt/Perl/ToDER.pm »