pub struct SecurityContext { /* private fields */ }Expand description
A verified subject’s security context = the clearance label the monitor compares against object labels.
Construction is deliberately gated: you build it from a clearance (level + compartments, authority-asserted) and verified key material (assurance, crypto-derived). The assurance axis of the resulting label is ALWAYS the derived one — a caller cannot pass in a higher assurance than the crypto supports.
Implementations§
Source§impl SecurityContext
impl SecurityContext
Sourcepub fn new(
level: Level,
compartments: CompartmentSet,
key_material: VerifiedKeyMaterial,
) -> Self
pub fn new( level: Level, compartments: CompartmentSet, key_material: VerifiedKeyMaterial, ) -> Self
Build a subject context from an authority-asserted clearance
(level + compartments) and crypto-derived key_material.
The resulting clearance’s assurance axis is clamped to the derived
assurance — a classical key can never carry a PqHybrid clearance even
if policy mistakenly assigned one. This is the load-bearing invariant of
#548: assurance is a property of the verified identity, not a grant.
Sourcepub fn from_clearance(
clearance: SecurityLabel,
key_material: VerifiedKeyMaterial,
) -> Self
pub fn from_clearance( clearance: SecurityLabel, key_material: VerifiedKeyMaterial, ) -> Self
Build from a pre-assembled clearance label and verified key material, clamping the assurance axis down to what the crypto supports.
min(clearance.assurance, derived) — clamp DOWN only, never up. If
policy assigned PqHybrid but the key is Classical, the effective
assurance is Classical (fail-closed/least-privilege).
Sourcepub fn derive_assurance(key_material: VerifiedKeyMaterial) -> Assurance
pub fn derive_assurance(key_material: VerifiedKeyMaterial) -> Assurance
Derive assurance directly from verified key material (#548). Thin forwarder kept as a named entry-point so the enforcement/PDP layers (S2/S4) have one obvious call site.
Sourcepub fn clearance(&self) -> &SecurityLabel
pub fn clearance(&self) -> &SecurityLabel
The clearance label. This is the subject.ctx the monitor feeds into
can_access(object_label).
Sourcepub fn can_access(&self, object_label: &SecurityLabel) -> bool
pub fn can_access(&self, object_label: &SecurityLabel) -> bool
self ⊒ object — does this subject context dominate the object’s
content-bound label? The per-op MAC floor (design §10). Pure forward to
the intrinsic lattice order.
Sourcepub fn can_write_to(&self, object_label: &SecurityLabel) -> bool
pub fn can_write_to(&self, object_label: &SecurityLabel) -> bool
object ⊒ self — Bell–LaPadula *-property (no-write-down): may this
subject write to the object? Write-direction IFC floor (#1269).
Forward to SecurityLabel::can_write_to.
pub fn level(&self) -> Level
pub fn assurance(&self) -> Assurance
pub fn compartments(&self) -> CompartmentSet
Sourcepub fn delegated_meet(
delegator: &SecurityContext,
actor: &SecurityContext,
) -> SecurityContext
pub fn delegated_meet( delegator: &SecurityContext, actor: &SecurityContext, ) -> SecurityContext
#681 two-principal composition for a delegated call. THE single shared derivation — both the S6 token-exchange gate (#680) and the downstream PDP call this; it is never re-implemented (a parallel impl would drift into the exact escalation hole this closes).
- Level + compartments = meet(delegator, actor) (
minlevel, compartment intersection). The effective clearance dominates an object only if both the authority source (delegator= UCAN chain root) and the acting receiver (actor= the presenter/MCP that signs the downstream envelope and receives the bytes) dominate it. Never either alone. - Assurance = the actor’s (the signer’s verified key material,
already clamped into
actor’s context per #548). The actor signs the downstream envelope and receives the object bytes, so the crypto floor that governs the read is the actor’s — not the delegator’s (who authorizes but never receives). AClassicalactor thus cannot reach aPqHybrid-labeled object even if the delegated clearance claimsPqHybrid.
meet(root, actor) is sufficient: intermediate delegation hops carry authority, not data (bounded by UCAN capability attenuation), and never receive the object bytes — so their clearances do not enter the read floor.
Sourcepub fn delegated(
delegator: Option<&SecurityContext>,
actor: Option<&SecurityContext>,
) -> Option<SecurityContext>
pub fn delegated( delegator: Option<&SecurityContext>, actor: Option<&SecurityContext>, ) -> Option<SecurityContext>
Fail-closed wrapper over Self::delegated_meet: None (→ deny) if
either principal’s clearance is unresolved (#681 AC — no default
clearance for a missing principal). This is the entry point the exchange
gate and the PDP both call.
Trait Implementations§
Source§impl Clone for SecurityContext
impl Clone for SecurityContext
Source§fn clone(&self) -> SecurityContext
fn clone(&self) -> SecurityContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SecurityContext
impl Debug for SecurityContext
Source§impl<'de> Deserialize<'de> for SecurityContext
impl<'de> Deserialize<'de> for SecurityContext
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for SecurityContext
impl PartialEq for SecurityContext
Source§fn eq(&self, other: &SecurityContext) -> bool
fn eq(&self, other: &SecurityContext) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for SecurityContext
impl Serialize for SecurityContext
impl Eq for SecurityContext
impl StructuralPartialEq for SecurityContext
Auto Trait Implementations§
impl Freeze for SecurityContext
impl RefUnwindSafe for SecurityContext
impl Send for SecurityContext
impl Sync for SecurityContext
impl Unpin for SecurityContext
impl UnsafeUnpin for SecurityContext
impl UnwindSafe for SecurityContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more