Skip to main content

structured_cms/attribute_certificate/validation/
revocation.rs

1//! AC profile projection into the shared PKIX CRL and OCSP processors.
2use super::{Profile, Revocation};
3use structured_asn1::{Integer, Parser, Span};
4use structured_pkix::general_name::GeneralName;
5use structured_pkix::revocation::{RevocationScheme, RevocationTarget, TargetKind};
6use structured_pkix::{Extensions, Name};
7
8impl<'a> RevocationTarget<'a> for Profile<'_, 'a> {
9    fn source_parser(&self) -> &'a Parser {
10        self.certificate().parser
11    }
12    fn issuer(&self) -> &Name<'a> {
13        // Profile construction established exactly one directoryName issuer.
14        match self.certificate().information().issuer.names.as_deref() {
15            Some([GeneralName::Directory(name)]) => name,
16            _ => unreachable!("checked AC profile has one directory issuer"),
17        }
18    }
19    fn serial(&self) -> Integer<'a> {
20        self.certificate().information().serial
21    }
22    fn extensions(&self) -> Option<&Extensions<'a>> {
23        self.certificate().information().extensions.as_ref()
24    }
25    fn kind(&self) -> TargetKind {
26        TargetKind::Attribute
27    }
28    fn revocation_scheme(&self) -> RevocationScheme {
29        match self.revocation() {
30            Revocation::Required => RevocationScheme::Available,
31            Revocation::NoRevAvailable => RevocationScheme::NoRevAvail,
32        }
33    }
34    fn encoded(&self) -> &'a [u8] {
35        self.certificate().element().as_bytes()
36    }
37    fn span(&self) -> Span {
38        self.certificate().element().span()
39    }
40}