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: PeerMapPeer = {cid → W_c}, used by Phase III.3 for multi-credential rewrap.
aux: ValueDeployment-specific auxiliary state (vault metadata, deployment hints, …). Out-of-scope of the protocol; the crate just preserves it.
Implementations§
Source§impl ProtectedState
impl ProtectedState
Sourcepub fn target(&self, name: &str) -> Result<&[u8]>
pub fn target(&self, name: &str) -> Result<&[u8]>
Look up s_o := M[target]. Returns an error if the
target is absent.
Sourcepub fn put_target(&mut self, name: impl Into<String>, value: impl Into<Vec<u8>>)
pub fn put_target(&mut self, name: impl Into<String>, value: impl Into<Vec<u8>>)
Insert or replace a target value.
Sourcepub fn remove_target(&mut self, name: &str) -> Option<TargetValue>
pub fn remove_target(&mut self, name: &str) -> Option<TargetValue>
Remove a target.
Sourcepub fn to_canonical(&self) -> Result<Zeroizing<Vec<u8>>>
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.
Sourcepub fn from_canonical(bytes: &[u8]) -> Result<Self>
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
impl Clone for ProtectedState
Source§fn clone(&self) -> ProtectedState
fn clone(&self) -> ProtectedState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more