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

filter: Statementstmt 96.9% 32 / 33 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 1 totaltotal 93.4% 43 / 46 CC 3 SCAR 4.4
CC
3
Cov
94%
new
3.2
BEGIN
1.0
BEGIN
1.0
CRAP 1.6
« lib/Crypt/Perl/X509/Extension/tlsFeature.pm ↑ Summary lib/Crypt/Perl/X/ECDSA/CharacteristicTwoUnsupported.pm »
1 package Crypt::Perl::X509::Extension::keyUsage;
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::keyUsage
11  
12 =head1 SYNOPSIS
13  
14 my $usage_obj = Crypt::Perl::X509::Extension::keyUsage->new(
15 qw(
16 digitalSignature
17 contentCommitment
18 keyEncipherment
19 dataEncipherment
20 keyAgreement
21 keyCertSign
22 cRLSign
23 encipherOnly
24 decipherOnly
25 )
26 );
27  
28 =head1 SEE ALSO
29  
30 L<https://tools.ietf.org/html/rfc5280#section-4.2.1.3>
31  
32 =cut
33  
34 1 ▶use parent qw( Crypt::Perl::X509::Extension );
Subroutine BEGIN: called CC=1 SCAR=0.0
35  
36 1 ▶use Crypt::Perl::ASN1::BitString ();
Subroutine BEGIN: called CC=1 SCAR=0.0
37 1 ▶use Crypt::Perl::X ();
Subroutine BEGIN: called CC=1 SCAR=0.0
38  
39 1 ▶use constant OID => '2.5.29.15';
Subroutine BEGIN: called CC=1 SCAR=0.0
40  
41 1 ▶use constant ASN1 => <<END;
Subroutine BEGIN: called CC=1 SCAR=0.0
42 keyUsage ::= BIT STRING
43 END
44  
45 1 ▶use constant CRITICAL => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
46  
47 #The original bit values are “little-endian”.
48 #We might as well transmogrify these values for ease of use here.
49 1 my @_bits = qw(
50 digitalSignature
51 contentCommitment
52 keyEncipherment
53 dataEncipherment
54 keyAgreement
55 keyCertSign
56 cRLSign
57 encipherOnly
58 decipherOnly
59 );
60  
61 sub new {
62 6 ▶ my ($class, @usages) = @_;
Subroutine new: called CC=3 SCAR=11.7
Pod undocumented
63  
64 #Use the modern name
65 6 $_ =~ s<\AnonRepudiation\z><contentCommitment> for @usages;
66  
67 6 ▶ if (!@usages) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@usages) 0 6 6
68 0 die Crypt::Perl::X::create('Generic', 'Need usages!');
69 }
70  
71 6 return bless \@usages, $class;
72 }
73  
74 sub _encode_params {
75 6 ▶ my ($self) = @_;
Subroutine _encode_params: called CC=1 SCAR=0.0
76  
77 6 return Crypt::Perl::ASN1::BitString::encode( \@_bits, [ @$self ] );
78 }
79  
80 1 1;
« lib/Crypt/Perl/X509/Extension/tlsFeature.pm ↑ Summary lib/Crypt/Perl/X/ECDSA/CharacteristicTwoUnsupported.pm »