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

filter: Statementstmt 0.0% 0 / 29 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 39 CC 1 SCAR 6.9
CC
1
Cov
0%
new
2.0
_encode_params
2.0
BEGIN
2.0
CRAP 2.0
1 package Crypt::Perl::X509::Extension::subjectDirectoryAttributes;
2  
3 use strict;
4 use warnings;
5  
6 =encoding utf-8
7  
8 =head1 NAME
9  
10 Crypt::Perl::X509::Extension::subjectDirectoryAttributes
11  
12 =head1 NOTES
13  
14 This module is B<EXPERIMENTAL>.
15  
16 Are you sure you need this extension? Because OpenSSL doesn’t
17 seem to pay it much regard: C<man 5 x509v3_config> doesn’t
18 mention it, and I can’t find any certificates that use it.
19 Also, despite the fact that this module, as best I can tell,
20 implements the extension as it’s consistently described everywhere
21 I’ve found, OpenSSL doesn’t render this module’s output cleanly.
22 (i.e., when using the C<-text> flag of C<openssl x509>). Maybe there’s
23 a mistake in this module’s ASN.1 logic? It’s not complicated, so
24 I’m not sure what would be wrong.
25  
26 In the absence of a parser against which to test this module’s
27 output, I’m a bit perplexed. Please drop me a line if you can shed
28 light on the situation.
29  
30 =head1 SEE ALSO
31  
32 L<https://tools.ietf.org/html/rfc5280#section-4.2.1.8>
33  
34 =cut
35  
36 use parent qw( Crypt::Perl::X509::Extension );
37  
38 use Crypt::Perl::X509::Name ();
39  
40 use constant {
41 OID => '2.5.29.9',
42 CRITICAL => 0,
43 };
44  
45 use constant ASN1 => <<END;
46 AttributeValue ::= ANY -- DEFINED BY AttributeType
47  
48 Attribute ::= SEQUENCE {
49 type OBJECT IDENTIFIER,
50 values SET OF AttributeValue -- at least one value is required
51 }
52  
53 subjectDirectoryAttributes ::= SEQUENCE OF Attribute
54 END
55  
56 sub new {
57 my ($class, @attrs) = @_;
58  
59 my @self;
60  
61 for my $a_ar (@attrs) {
62 my @cur = @$a_ar;
63  
64 my $type = shift @cur;
65  
66 $_ = Crypt::Perl::X509::Name::encode_string( $type, $_ ) for @cur;
67  
68 push @self, {
69 type => Crypt::Perl::X509::Name::get_OID($type),
70 values => \@cur,
71 };
72 }
73  
74 return bless \@self, $class;
75 }
76  
77 sub _encode_params {
78 my ($self) = @_;
79  
80 return [ @$self ];
81 }
82  
83 1;