pub struct MasterKey(/* private fields */);Expand description
A crypto_kdf master key. Always exactly 32 bytes - Kupyna256Kdf’s fixed key length (see
the module doc).
Implementations§
Source§impl MasterKey
impl MasterKey
Sourcepub fn generate() -> Result<Self, RandomError>
pub fn generate() -> Result<Self, RandomError>
Generates a fresh master key from the OS CSPRNG - libsodium’s crypto_kdf_keygen
equivalent.
§Errors
Returns crate::randombytes::RandomError if the OS CSPRNG fails.
pub fn from_bytes(bytes: [u8; 32]) -> Self
pub fn as_bytes(&self) -> &[u8; 32]
Sourcepub fn derive_subkey(&self, subkey_id: u64, context: &[u8; 8]) -> [u8; 32]
pub fn derive_subkey(&self, subkey_id: u64, context: &[u8; 8]) -> [u8; 32]
Derives a subkey - see Kupyna256Kdf::derive_subkey for the construction itself.
Different subkey_id/context values (holding the others fixed) produce different
subkeys.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MasterKey
impl RefUnwindSafe for MasterKey
impl Send for MasterKey
impl Sync for MasterKey
impl Unpin for MasterKey
impl UnsafeUnpin for MasterKey
impl UnwindSafe for MasterKey
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