pub struct PHashSalt(/* private fields */);Expand description
Perceptual hash of the container image, used as the Argon2id salt.
The bytes are wiped when the value is dropped. Like MasterKey, the type
implements neither Clone, Copy nor Debug: the salt is not a
secret in the sense a key is, but it is a deterministic function of the
container, and leaking it into a log would let an attacker confirm which
image a given payload belongs to.
§Why it compares and hashes, but still does not print
Two images that produce one salt produce one key and one nonce under any
given password, so a caller holding several containers has a question worth
asking about them: do any two of these collide? PartialEq, Eq and
Hash are derived to answer exactly that, and to answer it in linear time
— grouping by salt needs a hash-map key, and comparing every pair instead
would be quadratic in the size of a photo library.
Equality is the whole of what a caller gets. as_bytes stays
crate-private and there is no public path to the 64 hash bits, so an outside
program can learn that two of its own files collide and cannot learn the
value that made them collide, nor compute a fingerprint it could compare
against an image it does not hold.
The comparison is not constant time and does not need to be. Both operands are derived in-process from files the caller already has in front of them; there is no remote party feeding one side of it, and nothing timeable that the caller could not obtain by looking at the images.
Trait Implementations§
impl Eq for PHashSalt
impl StructuralPartialEq for PHashSalt
Auto Trait Implementations§
impl Freeze for PHashSalt
impl RefUnwindSafe for PHashSalt
impl Send for PHashSalt
impl Sync for PHashSalt
impl Unpin for PHashSalt
impl UnsafeUnpin for PHashSalt
impl UnwindSafe for PHashSalt
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> 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