| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# Copyright (c) 2002 Robert Joop |
|
2
|
|
|
|
|
|
|
# All rights reserved. |
|
3
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package X500::DN; |
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
20516
|
use 5.6.1; # the "our" keyword below needs it |
|
|
1
|
|
|
|
|
6
|
|
|
|
1
|
|
|
|
|
50
|
|
|
8
|
1
|
|
|
1
|
|
87
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
39
|
|
|
9
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
|
1
|
|
|
|
|
7
|
|
|
|
1
|
|
|
|
|
93
|
|
|
10
|
1
|
|
|
1
|
|
7348
|
use Parse::RecDescent 1.80; |
|
|
1
|
|
|
|
|
62175
|
|
|
|
1
|
|
|
|
|
7
|
|
|
11
|
1
|
|
|
1
|
|
652
|
use X500::RDN; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
415
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.29'; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $rfc2253_grammar = q { |
|
16
|
|
|
|
|
|
|
startrule: DistinguishedName /^\\Z/ { new X500::DN (reverse (@{$item[1]})); } |
|
17
|
|
|
|
|
|
|
DistinguishedName: name(?) { @{$item[1]} > 0 ? $item[1][0] : []; } |
|
18
|
|
|
|
|
|
|
name: nameComponent(s /[,;]\\s*/) |
|
19
|
|
|
|
|
|
|
nameComponent: attributeTypeAndValue(s /\\s*\\+\\s*/) { new X500::RDN (map { @$_ } @{$item[1]}); } |
|
20
|
|
|
|
|
|
|
attributeTypeAndValue: attributeType /\\s*=\\s*/ attributeValue { [ @item[1,3] ]; } |
|
21
|
|
|
|
|
|
|
attributeType: Alpha keychar(s?) { join ('', $item[1], @{$item[2]}); } |
|
22
|
|
|
|
|
|
|
| oid |
|
23
|
|
|
|
|
|
|
keychar: Alpha | Digit | '-' |
|
24
|
|
|
|
|
|
|
#oid: rfc1779oidprefix(?) Digits(s /\\./) { join ('.', @{$item[2]}) } |
|
25
|
|
|
|
|
|
|
#rfc1779oidprefix: /oid\\./i |
|
26
|
|
|
|
|
|
|
oid: Digits(s /\\./) { join ('.', @{$item[1]}) } |
|
27
|
|
|
|
|
|
|
Digits: Digit(s) { join ('', @{$item[1]}); } |
|
28
|
|
|
|
|
|
|
attributeValue: string |
|
29
|
|
|
|
|
|
|
string: (stringchar | pair)(s) { join ('', @{$item[1]}); } |
|
30
|
|
|
|
|
|
|
| '#' hexstring { $item[2] } |
|
31
|
|
|
|
|
|
|
| '"' (pair | quotechar)(s) '"' { join ('', @{$item[2]}); } |
|
32
|
|
|
|
|
|
|
quotechar: /[^"]/ |
|
33
|
|
|
|
|
|
|
special: /[,=+<>#; ]/ |
|
34
|
|
|
|
|
|
|
pair: '\\\\' ( special | '\\\\' | '"' | hexpair ) { $item[2] } |
|
35
|
|
|
|
|
|
|
stringchar: /[^,=+<>#;\\\\"]/ |
|
36
|
|
|
|
|
|
|
hexstring: hexpair(s) { join ('', @{$item[1]}); } |
|
37
|
|
|
|
|
|
|
hexpair: /[0-9A-Fa-f]{2}/ { chr (hex ($item[1])) } |
|
38
|
|
|
|
|
|
|
Alpha: /[A-Za-z]/ |
|
39
|
|
|
|
|
|
|
Digit: /[0-9]/ |
|
40
|
|
|
|
|
|
|
}; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
#$::RD_TRACE = 1; |
|
43
|
|
|
|
|
|
|
#$::RD_HINT = 1; |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
local $::RD_AUTOACTION = q{ $item[1] }; |
|
46
|
|
|
|
|
|
|
local $Parse::RecDescent::skip = undef; |
|
47
|
|
|
|
|
|
|
my $parser = new Parse::RecDescent ($rfc2253_grammar) or die "Bad RFC 2253 grammar!\n"; |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub new |
|
50
|
|
|
|
|
|
|
{ |
|
51
|
22
|
|
|
22
|
1
|
7243
|
my $class = shift; |
|
52
|
22
|
|
|
|
|
53
|
my $self = [ @_ ]; |
|
53
|
22
|
|
|
|
|
56
|
bless $self, $class; |
|
54
|
22
|
|
|
|
|
444
|
return $self; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub hasMultivaluedRDNs |
|
58
|
|
|
|
|
|
|
{ |
|
59
|
2
|
|
|
2
|
1
|
12
|
my $self = shift; |
|
60
|
2
|
|
|
|
|
5
|
return grep { $_->isMultivalued } @$self; |
|
|
4
|
|
|
|
|
17
|
|
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub getRDN |
|
64
|
|
|
|
|
|
|
{ |
|
65
|
17
|
|
|
17
|
1
|
78
|
my $self = shift; |
|
66
|
17
|
|
|
|
|
70
|
my $i = shift; |
|
67
|
17
|
|
|
|
|
79
|
return $self->[$i]; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub getRDNs |
|
71
|
|
|
|
|
|
|
{ |
|
72
|
10
|
|
|
10
|
1
|
78
|
my $self = shift; |
|
73
|
10
|
|
|
|
|
105
|
return @$self; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub ParseRFC2253 |
|
77
|
|
|
|
|
|
|
{ |
|
78
|
21
|
|
|
21
|
1
|
137
|
my $class = shift; |
|
79
|
21
|
|
|
|
|
35
|
my $text = shift; |
|
80
|
21
|
|
|
|
|
153
|
my $self = $parser->startrule ($text); |
|
81
|
21
|
|
|
|
|
4142
|
return $self; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub ParseOpenSSL |
|
85
|
|
|
|
|
|
|
{ |
|
86
|
1
|
|
|
1
|
0
|
450
|
croak "use 'openssl -nameopt RFC2253' and ParseRFC2253()"; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub getRFC2253String |
|
90
|
|
|
|
|
|
|
{ |
|
91
|
4
|
|
|
4
|
1
|
8
|
my $self = shift; |
|
92
|
4
|
|
|
|
|
7
|
return join (', ', map { $_->getRFC2253String } reverse (@{$self})); |
|
|
6
|
|
|
|
|
23
|
|
|
|
4
|
|
|
|
|
21
|
|
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub getX500String |
|
96
|
|
|
|
|
|
|
{ |
|
97
|
1
|
|
|
1
|
1
|
3
|
my $self = shift; |
|
98
|
1
|
|
|
|
|
3
|
return '{' . join (',', map { $_->getX500String } @{$self}) . '}'; |
|
|
0
|
|
|
|
|
0
|
|
|
|
1
|
|
|
|
|
7
|
|
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub getOpenSSLString |
|
102
|
|
|
|
|
|
|
{ |
|
103
|
2
|
|
|
2
|
1
|
10
|
my $self = shift; |
|
104
|
2
|
|
|
|
|
3
|
return join ('/', '', map { $_->getOpenSSLString } @{$self}); |
|
|
2
|
|
|
|
|
15
|
|
|
|
2
|
|
|
|
|
5
|
|
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
1; |