blib/lib/Crypt/Perl/X509/GeneralName.pm untested

filter: Statementstmt 0.0% 0 / 27 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 42 CC 4 SCAR 22.2
CC
4
Cov
0%
new
20.0
_encode_params
2.0
BEGIN
2.0
CRAP 9.2
1 package Crypt::Perl::X509::GeneralName;
2  
3 use strict;
4 use warnings;
5  
6 use Crypt::Perl::X509::Name ();
7  
8 use parent qw( Crypt::Perl::ASN1::Encodee );
9  
10 use constant ASN1 => Crypt::Perl::X509::Name::ASN1() . <<END;
11 AnotherName ::= SEQUENCE {
12 type OBJECT IDENTIFIER,
13 value [0] EXPLICIT ANY
14 }
15  
16 EDIPartyName ::= SEQUENCE {
17 nameAssigner [0] DirectoryString OPTIONAL,
18 partyName [1] DirectoryString
19 }
20  
21 -- No support for “compound” values until there’s a use case
22 -- that can verify functionality. (OpenSSL’s parse doesn’t know
23 -- what to do with the compound values as of 1.0.1j.)
24 GeneralName ::= CHOICE {
25 -- otherName [0] AnotherName,
26 rfc822Name [1] IA5String,
27 dNSName [2] IA5String,
28 -- x400Address [3] ORAddress,
29 directoryName [4] EXPLICIT ANY,
30  
31 -- I’ve not figured out how to get OpenSSL to create this,
32 -- and OpenSSL 1.0.1j doesn’t parse output from the below correctly.
33 -- ediPartyName [5] EDIPartyName,
34  
35 uniformResourceIdentifier [6] IA5String,
36 iPAddress [7] OCTET STRING,
37 registeredID [8] OBJECT IDENTIFIER
38 }
39 END
40  
41 sub new {
42 my ($class, $type, $value) = @_;
43  
44 if ($type eq 'otherName') {
45 $value = {
46 type => $value->[0],
47 value => $value->[1],
48 };
49 }
50 elsif ($type eq 'directoryName') {
51 $value = Crypt::Perl::X509::Name->new(@$value)->encode();
52 #substr( $value, 0, 1 ) = "\xa4";
53 }
54 elsif ($type eq 'ediPartyName') {
55 $value = { %$value };
56 $_ = { utf8String => $_ } for values %$value;
57 }
58  
59 return bless [ $type => $value ], $class;
60 }
61  
62 sub _encode_params {
63 my ($self) = @_;
64  
65 return { @$self }; #“de-bless”
66 }
67  
68 1;