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
//! PKIX distribution point types
use const_oid::{db::rfc5280::ID_PE_SUBJECT_INFO_ACCESS, AssociatedOid, ObjectIdentifier};
use der::flagset::{flags, FlagSet};
use der::{Sequence, ValueOrd};
use crate::ext::pkix::name::{DistributionPointName, GeneralNames};
/// IssuingDistributionPoint as defined in [RFC 5280 Section 5.2.5].
///
/// ```text
/// IssuingDistributionPoint ::= SEQUENCE {
/// distributionPoint [0] DistributionPointName OPTIONAL,
/// onlyContainsUserCerts [1] BOOLEAN DEFAULT FALSE,
/// onlyContainsCACerts [2] BOOLEAN DEFAULT FALSE,
/// onlySomeReasons [3] ReasonFlags OPTIONAL,
/// indirectCRL [4] BOOLEAN DEFAULT FALSE,
/// onlyContainsAttributeCerts [5] BOOLEAN DEFAULT FALSE
/// -- at most one of onlyContainsUserCerts, onlyContainsCACerts,
/// -- and onlyContainsAttributeCerts may be set to TRUE.
/// }
/// ```
///
/// [RFC 5280 Section 5.2.5]: https://datatracker.ietf.org/doc/html/rfc5280#section-5.2.5
#[derive(Clone, Debug, Eq, PartialEq, Sequence)]
#[allow(missing_docs)]
pub struct IssuingDistributionPoint {
#[asn1(context_specific = "0", tag_mode = "EXPLICIT", optional = "true")]
pub distribution_point: Option<DistributionPointName>,
#[asn1(
context_specific = "1",
tag_mode = "IMPLICIT",
default = "Default::default"
)]
pub only_contains_user_certs: bool,
#[asn1(
context_specific = "2",
tag_mode = "IMPLICIT",
default = "Default::default"
)]
pub only_contains_ca_certs: bool,
#[asn1(context_specific = "3", tag_mode = "IMPLICIT", optional = "true")]
pub only_some_reasons: Option<ReasonFlags>,
#[asn1(
context_specific = "4",
tag_mode = "IMPLICIT",
default = "Default::default"
)]
pub indirect_crl: bool,
#[asn1(
context_specific = "5",
tag_mode = "IMPLICIT",
default = "Default::default"
)]
pub only_contains_attribute_certs: bool,
}
impl AssociatedOid for IssuingDistributionPoint {
const OID: ObjectIdentifier = ID_PE_SUBJECT_INFO_ACCESS;
}
impl_extension!(IssuingDistributionPoint, critical = true);
/// DistributionPoint as defined in [RFC 5280 Section 4.2.1.13].
///
/// ```text
/// DistributionPoint ::= SEQUENCE {
/// distributionPoint [0] DistributionPointName OPTIONAL,
/// reasons [1] ReasonFlags OPTIONAL,
/// cRLIssuer [2] GeneralNames OPTIONAL }
/// ```
///
/// [RFC 5280 Section 4.2.1.13]: https://datatracker.ietf.org/doc/html/rfc5280#section-4.2.1.13
#[derive(Clone, Debug, PartialEq, Eq, Sequence, ValueOrd)]
#[allow(missing_docs)]
pub struct DistributionPoint {
#[asn1(context_specific = "0", tag_mode = "EXPLICIT", optional = "true")]
pub distribution_point: Option<DistributionPointName>,
#[asn1(context_specific = "1", tag_mode = "IMPLICIT", optional = "true")]
pub reasons: Option<ReasonFlags>,
#[asn1(context_specific = "2", tag_mode = "IMPLICIT", optional = "true")]
pub crl_issuer: Option<GeneralNames>,
}
/// ReasonFlags as defined in [RFC 5280 Section 4.2.1.13].
///
/// [RFC 5280 Section 4.2.1.13]: https://datatracker.ietf.org/doc/html/rfc5280#section-4.2.1.13
pub type ReasonFlags = FlagSet<Reasons>;
flags! {
/// ReasonFlags values as defined in [RFC 5280 Section 4.2.1.13].
///
/// ```text
/// ReasonFlags ::= BIT STRING {
/// unused (0),
/// keyCompromise (1),
/// cACompromise (2),
/// affiliationChanged (3),
/// superseded (4),
/// cessationOfOperation (5),
/// certificateHold (6),
/// privilegeWithdrawn (7),
/// aACompromise (8)
/// }
/// ```
///
/// [RFC 5280 Section 4.2.1.13]: https://datatracker.ietf.org/doc/html/rfc5280#section-4.2.1.13
#[allow(missing_docs)]
pub enum Reasons: u16 {
Unused = 1 << 0,
KeyCompromise = 1 << 1,
CaCompromise = 1 << 2,
AffiliationChanged = 1 << 3,
Superseded = 1 << 4,
CessationOfOperation = 1 << 5,
CertificateHold = 1 << 6,
PrivilegeWithdrawn = 1 << 7,
AaCompromise = 1 << 8,
}
}