pub struct DualKeyCap<P>where
P: Permission,{ /* private fields */ }Expand description
A dual-authorization capability requiring two independent approvals.
Created via DualKeyCap::new, which consumes a Cap<P> and returns
a (DualKeyCap<P>, ApproverA, ApproverB) triple. Both approvers must call
approve() before try_cap()
will succeed.
Implements Saltzer & Schroeder’s Separation of Privilege principle: no single entity can exercise the capability alone.
!Send + !Sync by default — use make_send for
cross-thread transfer. Cloning shares the same approval state.
Implementations§
Source§impl<P> DualKeyCap<P>where
P: Permission,
impl<P> DualKeyCap<P>where
P: Permission,
Sourcepub fn new(_cap: Cap<P>) -> (DualKeyCap<P>, ApproverA, ApproverB)
pub fn new(_cap: Cap<P>) -> (DualKeyCap<P>, ApproverA, ApproverB)
Creates a dual-authorization capability by consuming a Cap<P>.
Returns a (DualKeyCap<P>, ApproverA, ApproverB) triple. Distribute
the approver handles to separate subsystems to enforce separation of
privilege.
Sourcepub fn try_cap(&self) -> Result<Cap<P>, CapSecError>
pub fn try_cap(&self) -> Result<Cap<P>, CapSecError>
Sourcepub fn is_active(&self) -> bool
pub fn is_active(&self) -> bool
Advisory check — returns true if both approvals have been granted.
Sourcepub fn make_send(self) -> DualKeySendCap<P>
pub fn make_send(self) -> DualKeySendCap<P>
Converts this capability into a DualKeySendCap that can cross thread boundaries.
Trait Implementations§
Source§impl<P> Clone for DualKeyCap<P>where
P: Permission,
impl<P> Clone for DualKeyCap<P>where
P: Permission,
Source§fn clone(&self) -> DualKeyCap<P>
fn clone(&self) -> DualKeyCap<P>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more