Skip to main content

ProtectedState

Struct ProtectedState 

Source
pub struct ProtectedState {
    pub targets: BTreeMap<String, TargetValue>,
    pub peers: PeerMap,
    pub aux: Value,
}
Expand description

M: the decrypted protected state, accessible only inside T’s trusted boundary.

Fields§

§targets: BTreeMap<String, TargetValue>

M[target] = s_o. Keys are target identifiers, values are raw secret bytes (e.g. an API key or signing key).

§peers: PeerMap

Peer = {cid → W_c}, used by Phase III.3 for multi-credential rewrap.

§aux: Value

Deployment-specific auxiliary state (vault metadata, deployment hints, …). Out-of-scope of the protocol; the crate just preserves it.

Implementations§

Source§

impl ProtectedState

Source

pub fn new() -> Self

New empty state. Used at Phase I.2 setup before any targets are added.

Source

pub fn target(&self, name: &str) -> Result<&[u8]>

Look up s_o := M[target]. Returns an error if the target is absent.

Source

pub fn put_target(&mut self, name: impl Into<String>, value: impl Into<Vec<u8>>)

Insert or replace a target value.

Source

pub fn remove_target(&mut self, name: &str) -> Option<TargetValue>

Remove a target.

Source

pub fn to_canonical(&self) -> Result<Zeroizing<Vec<u8>>>

Serialise to canonical JCS-style JSON bytes for sealing under K.

Returns a Zeroizing<Vec<u8>> so the canonical bytes (which contain base64-encoded target plaintexts and peer wrapping keys) are wiped on drop. The encoder writes directly into the zeroizing buffer without constructing an intermediate serde_json::Value tree — this avoids the prior leak path where target bytes’ base64 form lived in a non-zeroizing String inside Value.

The structurally fixed shape is {"aux":…?,"peers":{…},"targets":{…}} (keys sorted lexicographically per JCS). The optional aux field goes through crate::canonical::canonicalize which still uses serde_json::Value; deployments that put sensitive data in aux trade some zeroize guarantees and should encrypt-before-stuffing.

Source

pub fn from_canonical(bytes: &[u8]) -> Result<Self>

Parse from canonical bytes (after Phase III.0 decryption of C).

Goes directly from bytes to ProtectedState via the serde visitor pattern (no intermediate serde_json::Value). Target plaintexts and wrapping keys land in [TargetValue] / WrappingKey which both Zeroize on drop, so the deserialize path is already leak-free.

Trait Implementations§

Source§

impl Clone for ProtectedState

Source§

fn clone(&self) -> ProtectedState

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ProtectedState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ProtectedState

Source§

fn default() -> ProtectedState

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for ProtectedState

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for ProtectedState

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,