pub struct SecretKey { /* private fields */ }
Expand description
A type to represent the SecretKey
that BLAKE2b uses for keyed mode.
Note:
SecretKey
pads the secret key for use with BLAKE2b, when initialized.
Exceptions:
An exception will be thrown if:
slice
is empty.slice
is greater than 64 bytes.- The
OsRng
fails to initialize or read from its source.
Security:
- Avoid using
unprotected_as_bytes()
whenever possible, as it breaks all protections that the type implements.
Implementations§
source§impl SecretKey
impl SecretKey
sourcepub fn from_slice(slice: &[u8]) -> Result<SecretKey, UnknownCryptoError>
pub fn from_slice(slice: &[u8]) -> Result<SecretKey, UnknownCryptoError>
Make an object from a given byte slice.
sourcepub fn get_original_length(&self) -> usize
pub fn get_original_length(&self) -> usize
Get the original size of the key, before padding.
sourcepub fn generate() -> Result<SecretKey, UnknownCryptoError>
pub fn generate() -> Result<SecretKey, UnknownCryptoError>
Randomly generate using a CSPRNG. Not available in no_std
context.
sourcepub fn unprotected_as_bytes(&self) -> &[u8] ⓘ
pub fn unprotected_as_bytes(&self) -> &[u8] ⓘ
Return the object as byte slice. Warning: Should not be used unless strictly needed. This breaks protections that the type implements.
sourcepub fn get_length(&self) -> usize
pub fn get_length(&self) -> usize
Return the length of the object.