line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::Perl::PKCS10::Attributes; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=encoding utf-8 |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Crypt::Perl::PKCS10::Attributes - CSR “attributes” collection |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
#Each object passed should be an instance of a subclass of |
15
|
|
|
|
|
|
|
#Crypt::Perl::PKCS10::Attribute (NB: not this class!) |
16
|
|
|
|
|
|
|
my $attrs = Crypt::Perl::PKCS10::Attributes->new( @ATTR_OBJS ); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
#...or: |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $attrs = Crypt::Perl::PKCS10::Attributes->new( |
21
|
|
|
|
|
|
|
[ $attr_type1 => \@args1 ], |
22
|
|
|
|
|
|
|
[ $attr_type2 => \@args2 ], |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
#...for example: |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $attrs = Crypt::Perl::PKCS10::Attributes->new( |
28
|
|
|
|
|
|
|
[ challengePassword => 'iNsEcUrE' ], |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 DESCRIPTION |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Instances of this class represent the “attributes” collection in a |
34
|
|
|
|
|
|
|
PKCS #10 Certificate Signing Request. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
You probably don’t need to |
37
|
|
|
|
|
|
|
instantiate this class directly; instead, you can instantiate it |
38
|
|
|
|
|
|
|
implicitly by listing out arguments to |
39
|
|
|
|
|
|
|
L’s constructor. See that module’s |
40
|
|
|
|
|
|
|
L for an example. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
The following X.509 extensions are supported: |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=over 4 |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=item * L |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=item * L |
49
|
|
|
|
|
|
|
(Note that this attribute does B encrypt anything; don’t encode any |
50
|
|
|
|
|
|
|
values that are sensitive data!) |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=back |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
55
|
|
|
|
|
|
|
|
56
|
1
|
|
|
1
|
|
4
|
use Try::Tiny; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
34
|
|
57
|
|
|
|
|
|
|
|
58
|
1
|
|
|
1
|
|
5
|
use Crypt::Perl::X (); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
14
|
|
59
|
|
|
|
|
|
|
|
60
|
1
|
|
|
|
|
4
|
use parent qw( |
61
|
|
|
|
|
|
|
Crypt::Perl::ASN1::Encodee |
62
|
1
|
|
|
1
|
|
3
|
); |
|
1
|
|
|
|
|
2
|
|
63
|
|
|
|
|
|
|
|
64
|
1
|
|
|
1
|
|
63
|
use constant ASN1 => <
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
326
|
|
65
|
|
|
|
|
|
|
Attributes ::= SET OF Attribute |
66
|
|
|
|
|
|
|
Attribute ::= SEQUENCE { |
67
|
|
|
|
|
|
|
type OBJECT IDENTIFIER, |
68
|
|
|
|
|
|
|
values SET OF ANY |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
END |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
my $ATTR_BASE = 'Crypt::Perl::PCKS10::Attribute'; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub new { |
75
|
9
|
|
|
9
|
0
|
46
|
my ($class, @attrs) = @_; |
76
|
|
|
|
|
|
|
|
77
|
9
|
|
|
|
|
60
|
for my $attr (@attrs) { |
78
|
18
|
50
|
|
18
|
|
177
|
if (!try { $attr->isa($ATTR_BASE) }) { |
|
18
|
|
|
|
|
926
|
|
79
|
18
|
50
|
|
|
|
274
|
if ( 'ARRAY' eq ref $attr ) { |
80
|
18
|
|
|
|
|
41
|
my $module = $attr->[0]; |
81
|
18
|
|
|
|
|
83
|
my $class = "Crypt::Perl::PKCS10::Attribute::$module"; |
82
|
18
|
|
|
|
|
113
|
Module::Load::load($class); |
83
|
18
|
|
|
|
|
1930
|
$attr = $class->new( @{$attr}[ 1 .. $#$attr ] ); |
|
18
|
|
|
|
|
394
|
|
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
else { |
86
|
0
|
|
|
|
|
0
|
die Crypt::Perl::X::create('Generic', "Attribute must be ARRAY reference or instance of $ATTR_BASE, not “$attr”!"); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
9
|
|
|
|
|
44
|
return bless \@attrs, $class; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
*structure = \&_encode_params; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub _encode_params { |
97
|
9
|
|
|
9
|
|
25
|
my ($self) = @_; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
return [ |
100
|
|
|
|
|
|
|
map { |
101
|
9
|
|
|
|
|
34
|
{ |
102
|
18
|
|
|
|
|
970
|
type => $_->OID(), |
103
|
|
|
|
|
|
|
values => [ $_->encode() ], |
104
|
|
|
|
|
|
|
}, |
105
|
|
|
|
|
|
|
} @$self |
106
|
|
|
|
|
|
|
]; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
1; |