pub trait PrfKeyInit: Prf {
type Key: Controlled;
type KeyError: Error + Send + Sync + 'static;
// Required methods
fn new(key: Self::Key) -> Self;
fn try_from_bytes(key: Protected<Vec<u8>>) -> Result<Self, Self::KeyError>;
}Expand description
Construction of a Prf backend from key material.
This is the one place the key changes hands. Both constructors take the
key by value, so the material moves into the backend rather than being
copied at the boundary, and the backend owns it for the rest of its life:
when the backend drops, the key is wiped. Backends must not hand out
shared handles to the key (for example behind an Arc), because that
turns “wiped when this backend drops” into “wiped when the last
outstanding handle drops”, which no call site can see.
The shape mirrors RustCrypto’s KeyInit, with the deliberate difference
that the key is owned rather than borrowed and copied in.
Prf is a supertrait, so P: PrfKeyInit alone says “a PRF I can
build from a key”; generic code does not need to spell out P: Prf as
well.
Required Associated Types§
Sourcetype Key: Controlled
type Key: Controlled
Fixed-size key type whose length is guaranteed by construction, so
new cannot fail. Always a controlled type; a
bare array cannot key a backend.
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".