blib/lib/Crypt/Perl/X509/Extension/extKeyUsage.pm untested

filter: Statementstmt 0.0% 0 / 32 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 47 CC 3 SCAR 12.4
CC
3
Cov
0%
new
6.0
_encode_params
6.0
BEGIN
2.0
CRAP 3.5
1 package Crypt::Perl::X509::Extension::extKeyUsage;
2  
3 use strict;
4 use warnings;
5  
6 =encoding utf-8
7  
8 =head1 NAME
9  
10 Crypt::Perl::X509::Extension::extKeyUsage
11  
12 =cut
13  
14 use parent qw( Crypt::Perl::X509::Extension );
15  
16 use Crypt::Perl::X ();
17  
18 use constant OID => '2.5.29.37';
19  
20 use constant ASN1 => <<END;
21 extKeyUsage ::= SEQUENCE OF KeyPurposeId
22  
23 KeyPurposeId ::= OBJECT IDENTIFIER
24 END
25  
26 use constant {
27 OID_serverAuth => '1.3.6.1.5.5.7.3.1',
28 OID_clientAuth => '1.3.6.1.5.5.7.3.2',
29 OID_codeSigning => '1.3.6.1.5.5.7.3.3',
30 OID_emailProtection => '1.3.6.1.5.5.7.3.4',
31 OID_timeStamping => '1.3.6.1.5.5.7.3.8',
32 OID_OCSPSigning => '1.3.6.1.5.5.7.3.9',
33 };
34  
35 sub new {
36 my ($class, @purposes) = @_;
37  
38 if (!@purposes) {
39 die Crypt::Perl::X::create('Generic', 'Need purposes!');
40 }
41  
42 return bless \@purposes, $class;
43 }
44  
45 sub _encode_params {
46 my ($self) = @_;
47  
48 my $data = [
49 map {
50 if ( !$self->can("OID_$_") ) {
51 die( Crypt::Perl::X::create('Generic', "Unknown usage: “$_”") ),
52 }
53  
54 $self->can("OID_$_")->();
55 } @$self,
56 ];
57  
58 return $data;
59 }
60  
61 1;