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
impl Clone for OtherSlots
impl Copy for OtherSlots
Source§impl Debug for OtherSlots
impl Debug for OtherSlots
impl Eq for OtherSlots
Source§impl PartialEq for OtherSlots
impl PartialEq for OtherSlots
impl StructuralPartialEq for OtherSlots
Auto Trait Implementations§
impl Forget for OtherSlots
impl Freeze for OtherSlots
impl RefUnwindSafe for OtherSlots
impl Send for OtherSlots
impl Sync for OtherSlots
impl Unpin for OtherSlots
impl UnsafeUnpin for OtherSlots
impl UnwindSafe for OtherSlots
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
Mutably borrows from an owned value. Read more