Skip to main content

ScopeMaterial

Enum ScopeMaterial 

Source
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: Uuid

The asset / file id the key belongs to.

§file_key: [u8; 32]

The asset’s per-file key.

§

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.

Fields

§album_id: Uuid

The album id.

§amks: BTreeMap<u32, [u8; 32]>

AMK bytes keyed by epoch.

Implementations§

Source§

impl ScopeMaterial

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> ScopeMaterial

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 ScopeMaterial

Source§

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

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

impl<'de> Deserialize<'de> for ScopeMaterial

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 Eq for ScopeMaterial

Source§

impl PartialEq for ScopeMaterial

Source§

fn eq(&self, other: &ScopeMaterial) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for ScopeMaterial

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
Source§

impl StructuralPartialEq for ScopeMaterial

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more