|
| 1 | +//! `CertificateChoices` [RFC 5652 10.2.2](https://datatracker.ietf.org/doc/html/rfc5652#section-10.2.2) |
| 2 | +
|
| 3 | +use der::{asn1::BitStringRef, AnyRef, Choice, Sequence, ValueOrd}; |
| 4 | +use spki::ObjectIdentifier; |
| 5 | +use x509_cert::Certificate; |
| 6 | + |
| 7 | +// TODO (smndtrl): Should come from x509 - for now I haven't found a test case in real world |
| 8 | +type AttributeCertificateV1<'a> = BitStringRef<'a>; |
| 9 | +type AttributeCertificateV2<'a> = BitStringRef<'a>; |
| 10 | +type ExtendedCertificate<'a> = BitStringRef<'a>; |
| 11 | + |
| 12 | +/// ```text |
| 13 | +/// OtherCertificateFormat ::= SEQUENCE { |
| 14 | +/// otherCertFormat OBJECT IDENTIFIER, |
| 15 | +/// otherCert ANY DEFINED BY otherCertFormat } |
| 16 | +/// ``` |
| 17 | +#[derive(Clone, Debug, PartialEq, Eq, Sequence, ValueOrd)] |
| 18 | +pub struct OtherCertificateFormat<'a> { |
| 19 | + other_cert_format: ObjectIdentifier, |
| 20 | + other_cert: AnyRef<'a>, |
| 21 | +} |
| 22 | + |
| 23 | +/// ```text |
| 24 | +/// CertificateChoices ::= CHOICE { |
| 25 | +/// certificate Certificate, |
| 26 | +/// extendedCertificate [0] IMPLICIT ExtendedCertificate, -- Obsolete |
| 27 | +/// v1AttrCert [1] IMPLICIT AttributeCertificateV1, -- Obsolete |
| 28 | +/// v2AttrCert [2] IMPLICIT AttributeCertificateV2, |
| 29 | +/// other [3] IMPLICIT OtherCertificateFormat } |
| 30 | +/// |
| 31 | +/// OtherCertificateFormat ::= SEQUENCE { |
| 32 | +/// otherCertFormat OBJECT IDENTIFIER, |
| 33 | +/// otherCert ANY DEFINED BY otherCertFormat } |
| 34 | +/// ``` |
| 35 | +#[derive(Clone, Debug, PartialEq, Eq, Choice, ValueOrd)] |
| 36 | +#[allow(clippy::large_enum_variant)] |
| 37 | +pub enum CertificateChoices<'a> { |
| 38 | + /// X.509 certificate |
| 39 | + Certificate(Certificate<'a>), |
| 40 | + |
| 41 | + /// PKCS #6 extended certificate (obsolete) |
| 42 | + #[deprecated] |
| 43 | + #[asn1(context_specific = "0", tag_mode = "IMPLICIT")] |
| 44 | + ExtendedCertificate(ExtendedCertificate<'a>), |
| 45 | + |
| 46 | + /// version 1 X.509 attribute certificate (ACv1) X.509-97 (obsolete) |
| 47 | + #[deprecated] |
| 48 | + #[asn1(context_specific = "1", tag_mode = "IMPLICIT")] |
| 49 | + V1AttrCert(AttributeCertificateV1<'a>), |
| 50 | + |
| 51 | + /// version 2 X.509 attribute certificate (ACv2) X.509-00 |
| 52 | + #[asn1(context_specific = "2", tag_mode = "IMPLICIT")] |
| 53 | + V2AttrCert(AttributeCertificateV2<'a>), |
| 54 | + |
| 55 | + /// any other certificate forma |
| 56 | + #[asn1(context_specific = "3", tag_mode = "IMPLICIT")] |
| 57 | + Other(OtherCertificateFormat<'a>), |
| 58 | +} |
0 commit comments