1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
use {
bcder::{
decode::{Constructed, Source, Unimplemented},
BitString, Oid,
},
x509_certificate::{asn1time::*, rfc3280::*, rfc5280::*},
};
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct AttributeCertificate {
pub ac_info: AttributeCertificateInfo,
pub signature_algorithm: AlgorithmIdentifier,
pub signature_value: BitString,
}
impl AttributeCertificate {
pub fn take_from<S: Source>(cons: &mut Constructed<S>) -> Result<Self, S::Err> {
cons.take_sequence(|cons| {
let ac_info = AttributeCertificateInfo::take_from(cons)?;
let signature_algorithm = AlgorithmIdentifier::take_from(cons)?;
let signature_value = BitString::take_from(cons)?;
Ok(Self {
ac_info,
signature_algorithm,
signature_value,
})
})
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct AttributeCertificateInfo {
pub version: AttCertVersion,
pub holder: Holder,
pub issuer: AttCertIssuer,
pub signature: AlgorithmIdentifier,
pub serial_number: CertificateSerialNumber,
pub attr_cert_validity_period: AttCertValidityPeriod,
pub attributes: Vec<Attribute>,
pub issuer_unique_ud: Option<UniqueIdentifier>,
pub extensions: Option<Extensions>,
}
impl AttributeCertificateInfo {
pub fn take_from<S: Source>(_cons: &mut Constructed<S>) -> Result<Self, S::Err> {
Err(Unimplemented.into())
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum AttCertVersion {
V2 = 1,
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Holder {
pub base_certificate_id: Option<IssuerSerial>,
pub entity_name: Option<GeneralNames>,
pub object_digest_info: Option<ObjectDigestInfo>,
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum DigestedObjectType {
PublicKey = 0,
PublicKeyCert = 1,
OtherObjectTypes = 2,
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct ObjectDigestInfo {
pub digested_object_type: DigestedObjectType,
pub other_object_type_id: Oid,
pub digest_algorithm: AlgorithmIdentifier,
pub object_digest: BitString,
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum AttCertIssuer {
V1Form(GeneralNames),
V2Form(Box<V2Form>),
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct V2Form {
pub issuer_name: Option<GeneralNames>,
pub base_certificate_id: Option<IssuerSerial>,
pub object_digest_info: Option<ObjectDigestInfo>,
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct IssuerSerial {
pub issuer: GeneralNames,
pub serial: CertificateSerialNumber,
pub issuer_uid: Option<UniqueIdentifier>,
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct AttCertValidityPeriod {
pub not_before_time: GeneralizedTime,
pub not_after_time: GeneralizedTime,
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Attribute {
pub typ: AttributeType,
pub values: Vec<AttributeValue>,
}
pub type AttributeType = Oid;
pub type AttributeValue = Option<()>;