at_cryptoauth/cert/ext.rs
1//! Standardized X.509 Certificate Extensions
2
3use der::{
4 Sequence, ValueOrd,
5 asn1::{OctetStringRef, SequenceOf},
6};
7use spki::ObjectIdentifier;
8
9/// Extension as defined in [RFC 5280 Section 4.1.2.9].
10///
11/// The ASN.1 definition for Extension objects is below. The extnValue type
12/// may be further parsed using a decoder corresponding to the extnID value.
13///
14/// ```text
15/// Extension ::= SEQUENCE {
16/// extnID OBJECT IDENTIFIER,
17/// critical BOOLEAN DEFAULT FALSE,
18/// extnValue OCTET STRING
19/// -- contains the DER encoding of an ASN.1 value
20/// -- corresponding to the extension type identified
21/// -- by extnID
22/// }
23/// ```
24///
25/// [RFC 5280 Section 4.1.2.9]: https://datatracker.ietf.org/doc/html/rfc5280#section-4.1.2.9
26#[derive(Clone, Debug, Eq, PartialEq, Sequence, ValueOrd)]
27#[allow(missing_docs)]
28pub struct Extension<'a> {
29 pub extn_id: ObjectIdentifier,
30
31 #[asn1(default = "Default::default")]
32 pub critical: bool,
33
34 pub extn_value: OctetStringRef<'a>,
35}
36
37/// Extensions as defined in [RFC 5280 Section 4.1.2.9].
38///
39/// ```text
40/// Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension
41/// ```
42///
43/// [RFC 5280 Section 4.1.2.9]: https://datatracker.ietf.org/doc/html/rfc5280#section-4.1.2.9
44pub type Extensions<'a, const N: usize> = SequenceOf<Extension<'a>, N>;