Skip to main content

structured_ltv/
baseline.rs

1//! Composition of source-bound long-term facts over a format's stage reports.
2//!
3//! Each format supplies its own basic stage and material reports through the
4//! traits here. [`timestamped`] joins the whole TSA-path census with every
5//! signature timestamp's static association; [`long_term`] links the X.509 and
6//! credential material reports to the SAME participant census; for each
7//! archive [`archive_material`] joins that archive's reports and [`archives`]
8//! requires one for every original archive. Additional reports never promote
9//! a requested level and no report here is a trust verdict.
10
11use crate::pki::{CounterReceipts, ParticipantRequirements, SignerReceipt};
12use crate::source::{Location, Snapshot};
13use crate::timestamp::TimestampScope;
14
15mod archive;
16mod material;
17mod timed;
18
19pub use archive::{
20    ArchiveCensusError, ArchiveMaterial, ArchiveMaterialResult, Archives, ArchivesResult,
21    archive_material, archives,
22};
23pub use material::{LongTerm, MaterialResult, long_term};
24pub use timed::{SignatureTimeFact, TimeError, TimeResult, Timed, timestamped};
25
26/// A format's basic stage: the signer and countersignature receipts it was
27/// built from, and whether every requirement of the format's basic level holds.
28pub trait BasicStage<'path, 'document> {
29    /// Original node identity.
30    type Id: Copy;
31    /// Stable document identity.
32    type Document: Copy;
33    /// Exact document generation.
34    type Generation: Copy;
35    /// The signing-certificate binding receipt.
36    type Signer: SignerReceipt<
37            'path,
38            'document,
39            Id = Self::Id,
40            Document = Self::Document,
41            Generation = Self::Generation,
42        >;
43    /// The complete countersignature census.
44    type Counters: CounterReceipts<
45            'path,
46            'document,
47            Id = Self::Id,
48            Document = Self::Document,
49            Generation = Self::Generation,
50        >;
51
52    /// Same signer receipt the stage checked.
53    fn signer(&self) -> &Self::Signer;
54    /// Same countersignature census the stage checked.
55    fn counters(&self) -> &Self::Counters;
56    /// Every condition of the format's basic level holds.
57    fn all_requirements_met(&self) -> bool;
58}
59
60/// A format's whole-signature X.509 material report.
61pub trait X509Material<'path, 'document> {
62    /// Original node identity.
63    type Id: Copy;
64    /// Stable document identity.
65    type Document: Copy;
66    /// Exact document generation.
67    type Generation: Copy;
68    /// Issuer of the receipts the report was derived from.
69    type Issuer;
70
71    /// The participant census the report was derived from.
72    fn requirements(
73        &self,
74    ) -> &ParticipantRequirements<
75        'path,
76        'document,
77        Self::Id,
78        Self::Document,
79        Self::Generation,
80        Self::Issuer,
81    >;
82    /// Every X.509 presence and placement requirement of the format holds.
83    fn all_x509_requirements_met(&self) -> bool;
84}
85
86/// A format's credential-material report for one validation-data scope.
87pub trait CredentialMaterial {
88    /// Original node identity.
89    type Id: Copy;
90    /// Stable document identity.
91    type Document: Copy;
92    /// Exact document generation.
93    type Generation: Copy;
94    /// The authenticated credential census the report checked.
95    type Credentials;
96
97    /// Whole-signature or preceding-archive scope of the report.
98    fn scope(&self) -> TimestampScope<Self::Id, Self::Document, Self::Generation>;
99    /// Source generation of the authenticated credential census.
100    fn snapshot(&self) -> Snapshot<Self::Document, Self::Generation>;
101    /// Same authenticated credential census, by reference.
102    fn credentials(&self) -> &Self::Credentials;
103    /// Every credential's own format material is present and interpreted.
104    fn all_requirements_met(&self) -> bool;
105}
106
107/// A format's census of one signature's timestamps, in original order.
108pub trait ArchiveCensus {
109    /// Original node identity.
110    type Id: Copy;
111    /// Stable document identity.
112    type Document: Copy;
113    /// Exact document generation.
114    type Generation: Copy;
115
116    /// The signature whose timestamps these are.
117    fn signature(&self) -> Location<Self::Id, Self::Document, Self::Generation>;
118    /// Number of timestamps of every kind.
119    fn timestamps(&self) -> usize;
120    /// The archive timestamp property at this ordinal, or `None` when that
121    /// timestamp covers another kind of input.
122    ///
123    /// # Panics
124    /// When `ordinal` is not below [`Self::timestamps`].
125    fn archive(&self, ordinal: usize) -> Option<Self::Id>;
126}