| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Crypt::Perl::X509::RelativeDistinguishedName; |
|
2
|
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
39
|
use strict; |
|
|
5
|
|
|
|
|
20
|
|
|
|
5
|
|
|
|
|
146
|
|
|
4
|
5
|
|
|
5
|
|
25
|
use warnings; |
|
|
5
|
|
|
|
|
9
|
|
|
|
5
|
|
|
|
|
132
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
25
|
use parent qw( Crypt::Perl::ASN1::Encodee ); |
|
|
5
|
|
|
|
|
35
|
|
|
|
5
|
|
|
|
|
34
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
5
|
|
|
5
|
|
522
|
use constant ASN1 => <
|
|
|
5
|
|
|
|
|
12
|
|
|
|
5
|
|
|
|
|
681
|
|
|
9
|
|
|
|
|
|
|
RelativeDistinguishedName ::= SET OF AttributeTypeAndValue |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
AttributeTypeAndValue ::= SEQUENCE { |
|
12
|
|
|
|
|
|
|
type OBJECT IDENTIFIER, |
|
13
|
|
|
|
|
|
|
value DirectoryString |
|
14
|
|
|
|
|
|
|
} |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
DirectoryString ::= CHOICE { |
|
17
|
|
|
|
|
|
|
-- teletexString TeletexString, |
|
18
|
|
|
|
|
|
|
printableString PrintableString, |
|
19
|
|
|
|
|
|
|
-- bmpString BMPString, |
|
20
|
|
|
|
|
|
|
-- universalString UniversalString, |
|
21
|
|
|
|
|
|
|
utf8String UTF8String, |
|
22
|
|
|
|
|
|
|
ia5String IA5String, |
|
23
|
|
|
|
|
|
|
integer INTEGER -- probably unused?? |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
END |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
#Accessed from tests. |
|
28
|
|
|
|
|
|
|
#Anything missing? Please let me know. |
|
29
|
|
|
|
|
|
|
use constant { |
|
30
|
5
|
|
|
|
|
3517
|
Name_OID_emailAddress => '1.2.840.113549.1.9.1', |
|
31
|
|
|
|
|
|
|
Name_OID_commonName => '2.5.4.3', |
|
32
|
|
|
|
|
|
|
Name_OID_surname => '2.5.4.4', |
|
33
|
|
|
|
|
|
|
Name_OID_serialNumber => '2.5.4.5', |
|
34
|
|
|
|
|
|
|
Name_OID_countryName => '2.5.4.6', |
|
35
|
|
|
|
|
|
|
Name_OID_localityName => '2.5.4.7', |
|
36
|
|
|
|
|
|
|
Name_OID_stateOrProvinceName => '2.5.4.8', |
|
37
|
|
|
|
|
|
|
Name_OID_streetAddress => '2.5.4.9', |
|
38
|
|
|
|
|
|
|
Name_OID_organizationName => '2.5.4.10', |
|
39
|
|
|
|
|
|
|
Name_OID_organizationalUnitName => '2.5.4.11', |
|
40
|
|
|
|
|
|
|
Name_OID_title => '2.5.4.12', |
|
41
|
|
|
|
|
|
|
Name_OID_description => '2.5.4.13', |
|
42
|
|
|
|
|
|
|
Name_OID_searchGuide => '2.5.4.14', |
|
43
|
|
|
|
|
|
|
Name_OID_businessCategory => '2.5.4.15', |
|
44
|
|
|
|
|
|
|
Name_OID_postalAddress => '2.5.4.16', |
|
45
|
|
|
|
|
|
|
Name_OID_postalCode => '2.5.4.17', |
|
46
|
|
|
|
|
|
|
Name_OID_postOfficeBox => '2.5.4.18', |
|
47
|
|
|
|
|
|
|
Name_OID_physicalDeliveryOfficeName => '2.5.4.19', |
|
48
|
|
|
|
|
|
|
Name_OID_telephoneNumber => '2.5.4.20', |
|
49
|
|
|
|
|
|
|
Name_OID_facsimileTelephoneNumber => '2.5.4.23', |
|
50
|
|
|
|
|
|
|
Name_OID_name => '2.5.4.41', |
|
51
|
|
|
|
|
|
|
Name_OID_givenName => '2.5.4.42', |
|
52
|
|
|
|
|
|
|
Name_OID_initials => '2.5.4.43', |
|
53
|
|
|
|
|
|
|
Name_OID_generationQualifier => '2.5.4.44', |
|
54
|
|
|
|
|
|
|
Name_OID_dnQualifier => '2.5.4.46', |
|
55
|
|
|
|
|
|
|
Name_OID_pseudonym => '2.5.4.65', |
|
56
|
5
|
|
|
5
|
|
34
|
}; |
|
|
5
|
|
|
|
|
12
|
|
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
#cf. RFC 5280, around p. 114 |
|
59
|
|
|
|
|
|
|
my %_type = ( |
|
60
|
|
|
|
|
|
|
dnQualifier => 'printableString', |
|
61
|
|
|
|
|
|
|
countryName => 'printableString', |
|
62
|
|
|
|
|
|
|
serialNumber => 'printableString', |
|
63
|
|
|
|
|
|
|
emailAddress => 'ia5String', |
|
64
|
|
|
|
|
|
|
); |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub get_OID { |
|
67
|
104
|
|
|
104
|
0
|
262
|
my ($type) = @_; |
|
68
|
104
|
|
33
|
|
|
913
|
my $oid = __PACKAGE__->can("Name_OID_$type") || do { |
|
69
|
|
|
|
|
|
|
die "Unknown OID: “$type”"; |
|
70
|
|
|
|
|
|
|
}; |
|
71
|
|
|
|
|
|
|
|
|
72
|
104
|
|
|
|
|
430
|
return $oid->(); |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
#static function |
|
76
|
|
|
|
|
|
|
sub encode_string { |
|
77
|
0
|
|
|
0
|
0
|
0
|
my ($type, $value) = @_; |
|
78
|
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
0
|
$type = _string_type($type); |
|
80
|
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
0
|
return Crypt::Perl::ASN1->new()->prepare( ASN1() )->find('DirectoryString')->encode( { $type => $value } ); |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub _string_type { |
|
85
|
104
|
|
|
104
|
|
200
|
my ($attr_type) = @_; |
|
86
|
|
|
|
|
|
|
|
|
87
|
104
|
|
50
|
|
|
548
|
return $_type{$attr_type} || 'utf8String' |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub new { |
|
91
|
86
|
|
|
86
|
0
|
276
|
my ($class, @key_values) = @_; |
|
92
|
|
|
|
|
|
|
|
|
93
|
86
|
|
|
|
|
182
|
my @set; |
|
94
|
|
|
|
|
|
|
|
|
95
|
86
|
|
|
|
|
348
|
while ( my ($type, $val) = splice( @key_values, 0, 2 ) ) { |
|
96
|
104
|
|
|
|
|
289
|
my $oid = get_OID($type); |
|
97
|
|
|
|
|
|
|
|
|
98
|
104
|
|
|
|
|
259
|
my $type = _string_type($type); |
|
99
|
|
|
|
|
|
|
|
|
100
|
104
|
|
|
|
|
693
|
push @set, { type => $oid, value => { $type => $val } }; |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
86
|
|
|
|
|
520
|
return bless \@set, $class; |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub _encode_params { |
|
107
|
86
|
|
|
86
|
|
232
|
return [ @{ $_[0] } ]; #“de-bless” |
|
|
86
|
|
|
|
|
358
|
|
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
1; |