pub enum ScopeMaterial {
Asset {
file_id: Uuid,
file_key: [u8; 32],
},
Album {
album_id: Uuid,
amks: BTreeMap<u32, [u8; 32]>,
},
}Expand description
The scope’s decryption material — the “decryption keys” that get encapsulated into the link. Serialized to canonical CBOR before sealing, so two implementations encapsulate byte-identically.
Variants§
Asset
A single asset: its per-file AES-256 key (already derived under the asset’s epoch AMK, so the recipient needs no album key).
Fields
file_id: UuidThe asset / file id the key belongs to.
Album
A whole album: the AMK for every epoch, so the recipient can derive any managed asset’s file key regardless of the epoch it was written under.
Implementations§
Source§impl ScopeMaterial
impl ScopeMaterial
Sourcepub fn file_key_for(
&self,
file_id: &Uuid,
amk_version: u32,
nonce_prefix: &[u8],
) -> Result<[u8; 32], SharingError>
pub fn file_key_for( &self, file_id: &Uuid, amk_version: u32, nonce_prefix: &[u8], ) -> Result<[u8; 32], SharingError>
Derive the per-file AES-256 key for file_id, written under epoch amk_version with
the manifest’s nonce_prefix.
For an Asset scope the key is returned directly (and the
file_id must match) — the grant was minted with the asset’s own nonce_prefix
already folded in, so the argument is unused. For an Album
scope it is derived from the requested epoch’s AMK with nonce_prefix folded into the
salt (the fold is what re-rolls the key per write). A file/epoch this material does not
cover is SharingError::ScopeUnavailable.
The album arm assumes key_mode = derived: the triple carries no wrapped_file_key,
so it cannot recover an adopted web-upload drop’s key. A caller holding the asset’s
manifest uses file_key_for_manifest, which honours
key_mode.
Sourcepub fn file_key_for_manifest(
&self,
core: &ManifestCore,
) -> Result<[u8; 32], SharingError>
pub fn file_key_for_manifest( &self, core: &ManifestCore, ) -> Result<[u8; 32], SharingError>
Recover the per-file key of the original core describes, honouring its key_mode.
For an Asset scope the carried key is returned (the issuer
already resolved the key mode when it minted the grant) and core.file_id must match.
For an Album scope the AMK of core.amk_version recovers it
through recover_file_key: a derived
original re-derives, a wrapped one (an adopted web-upload drop) unwraps
wrapped_file_key. A file, album, or epoch this material does not cover is
SharingError::ScopeUnavailable; a wrapped key that does not open, or is missing, is
SharingError::Crypto.
Sourcepub fn file_key_for_key_mode(
&self,
file_id: &Uuid,
amk_version: u32,
nonce_prefix: &[u8],
key_mode: KeyMode,
wrapped_file_key: Option<&WrappedFileKey>,
) -> Result<[u8; 32], SharingError>
pub fn file_key_for_key_mode( &self, file_id: &Uuid, amk_version: u32, nonce_prefix: &[u8], key_mode: KeyMode, wrapped_file_key: Option<&WrappedFileKey>, ) -> Result<[u8; 32], SharingError>
file_key_for_manifest over the four manifest fields it
reads, for a recipient that is served those fields rather than the signed manifest: the
browser share viewer, through capsule-wasm.
An Asset scope carries its key directly, as in
file_key_for. For an Album scope the
AMK of amk_version recovers it through
recover_file_key_parts, which
follows key_mode. There is no album id to check: the caller names no album, and a
grant’s material covers only its own. A wrapped key from another album does not open
under this grant’s AMK, and fails closed here.
Errors are those of file_key_for_manifest: an epoch the grant does not hold is
SharingError::ScopeUnavailable, and a wrapped key that is missing or does not open is
SharingError::Crypto.
Trait Implementations§
Source§impl Clone for ScopeMaterial
impl Clone for ScopeMaterial
Source§fn clone(&self) -> ScopeMaterial
fn clone(&self) -> ScopeMaterial
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 ScopeMaterial
impl Debug for ScopeMaterial
Source§impl<'de> Deserialize<'de> for ScopeMaterial
impl<'de> Deserialize<'de> for ScopeMaterial
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>,
impl Eq for ScopeMaterial
Source§impl PartialEq for ScopeMaterial
impl PartialEq for ScopeMaterial
Source§fn eq(&self, other: &ScopeMaterial) -> bool
fn eq(&self, other: &ScopeMaterial) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for ScopeMaterial
impl Serialize for ScopeMaterial
impl StructuralPartialEq for ScopeMaterial
Auto Trait Implementations§
impl Freeze for ScopeMaterial
impl RefUnwindSafe for ScopeMaterial
impl Send for ScopeMaterial
impl Sync for ScopeMaterial
impl Unpin for ScopeMaterial
impl UnsafeUnpin for ScopeMaterial
impl UnwindSafe for ScopeMaterial
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§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<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