Skip to main content

structured_cades/properties/
values.rs

1//! Original Annex A validation values, retained at their first schema reading.
2
3use crate::source::Node;
4use structured_asn1::memory::{Memory, OwnedVec, Work};
5use structured_pkix::{Certificate, crl::CertificateList, ocsp::BasicResponse};
6
7/// OID-owned original revocation values. Syntax inspection does not recognize,
8/// authenticate or silently discard a format which needs its own handler.
9#[derive(Debug, Clone, Copy)]
10pub struct OtherRevocation<'document> {
11    /// Original containing revocation-values attribute.
12    pub property: Node,
13    /// Original open-format identifier.
14    pub kind: structured_asn1::Oid<'document>,
15    /// Original context wrapper, including the format OID and open values.
16    pub enclosure: structured_asn1::Element<'document>,
17    /// Whole original open values and producing parser/depth/encoding.
18    pub values: crate::source::Value<'document>,
19}
20
21/// One original member of an actual certificate/revocation-values attribute.
22pub struct Located<T> {
23    /// Original containing attribute, independent of the member's coordinates.
24    pub property: Node,
25    /// Whole actual certificate/revocation-values SEQUENCE. Its original bytes
26    /// are covered even when an early archive omits the outer Attribute header.
27    pub enclosure: Node,
28    /// Original ordinal within this attribute's applicable SEQUENCE OF.
29    pub ordinal: usize,
30    /// Parsed original model, with no re-encoding or payload copy.
31    pub value: T,
32}
33
34/// Format-defined legacy validation values. OCSP entries are ORIGINAL bare
35/// `BasicOCSPResponse` values (Annex A.1.4), never manufactured OCSP envelopes.
36/// Reading establishes neither authentication nor historical availability.
37pub struct Values<'document, W: Work = Memory> {
38    pub(crate) certificates: OwnedVec<Located<Certificate<'document>>, W>,
39    pub(crate) crls: OwnedVec<Located<CertificateList<'document>>, W>,
40    pub(crate) ocsp: OwnedVec<Located<BasicResponse<'document>>, W>,
41    pub(crate) other: OwnedVec<OtherRevocation<'document>, W>,
42}
43impl<'d, W: Work> Values<'d, W> {
44    pub(crate) fn new(work: &W) -> Self {
45        Self {
46            certificates: work.vector(),
47            crls: work.vector(),
48            ocsp: work.vector(),
49            other: work.vector(),
50        }
51    }
52    pub(crate) fn into_owned(self) -> Values<'d> {
53        Values {
54            certificates: self.certificates.into_owned(),
55            crls: self.crls.into_owned(),
56            ocsp: self.ocsp.into_owned(),
57            other: self.other.into_owned(),
58        }
59    }
60    /// Borrowed original certificate members; traversals must use current work.
61    pub fn certificates(&self) -> &[Located<Certificate<'d>>] {
62        &self.certificates
63    }
64    /// Borrowed original complete/delta CRLs; no status authentication implied.
65    pub fn crls(&self) -> &[Located<CertificateList<'d>>] {
66        &self.crls
67    }
68    /// Borrowed original bare OCSP basic bodies; no success envelope is invented.
69    pub fn ocsp_responses(&self) -> &[Located<BasicResponse<'d>>] {
70        &self.ocsp
71    }
72    /// Original OID-owned values, without an invented status/format fallback.
73    pub fn other_revocation(&self) -> &[OtherRevocation<'d>] {
74        &self.other
75    }
76}