Skip to main content

OtherSlots

Enum OtherSlots 

Source
pub enum OtherSlots {
    Carry,
    Discard,
}
Expand description

未被 keep 覆盖的那些槽怎么处理。

§为什么要做成显式选择,而不是默认某一种

两种处理方式的后果都不可逆,且方向相反:一个会永久丢失用户可能 依赖的恢复码,另一个会让用户以为「删掉的密码」其实还留着。调用方必须 明确表态,不能靠一个容易漏看的布尔默认值。

Variants§

§

Carry

原样搬运:把不属于 keep 的槽逐字节复制过去。

用于 add / change——用户只想动自己这一个密码,不该殃及 这个文件上的恢复码或别人的密码。

§为什么不需要先认出那些槽

每个 slot 的密文由 (KEK, file_uuid, slot_index) 唯一确定, 与相邻槽无关;而本函数保留原 FEK,所以旧槽里包的还是同一个 FEK。 头部 MAC 的密钥同样由 FEK 派生,搬完重算一次即自洽。

「保住某个槽」与「知道某个槽是什么」是两件事,前者不需要后者。

代价是保留只能无差别:当初给同事配的临时密码也会一起留下。 想清掉特定密码,本模式做不到(格式上分不清谁是谁),只能整体 OtherSlots::Discard 或换 FEK 重新加密。

§边界:keep 增长时仍会顶掉靠前的槽

keep 占据 slot 0..n,搬运只能从 n 开始。所以 add 一个新密码时, 原本在 slot n 上的槽会被新密码盖掉。实测:slot0=主密码、 slot1=恢复码的文件,add 一个新密码后恢复码没了。

这个边界绕不开:包裹密钥绑定 slot_index,新密码必须写在它 自己的下标上;而我们又分不清哪个下标是空的,没有「找个真空位」 这种操作可用。调用方应根据 RewriteOutcome::may_have_evicted 提醒用户。

§

Discard

全部丢弃,填随机字节——即「只留下 keep 里这些」。

用于 remove。UI 文案必须点明这会作废包括恢复码在内的其它 全部密码,否则用户以为只是删掉了某个协作者。

Trait Implementations§

Source§

impl Clone for OtherSlots

Source§

fn clone(&self) -> Self

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 Copy for OtherSlots

Source§

impl Debug for OtherSlots

Source§

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

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

impl Eq for OtherSlots

Source§

impl PartialEq for OtherSlots

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for OtherSlots

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.