pub(crate) fn generate_key<T: KeyInit, S: AsRef<[u8]>>(
secret: &S,
context: &str,
with_salt: Option<&[u8]>,
) -> Result<T>Expand description
Internal convenience function to generate key and IV from the given secret, that is cryptographically strong.
The secret must be at least 16 bytes long.
The function internally uses Blake2s256 based HKDF (see RFC 5869).
For extract_with_salt is given, the HKDF uses Extract with the given salt first
and then calls Expand to derive the key and IV.
Otherwise, only Expand is used to derive key and IV using the given info, but
the secret size must be exactly 32 bytes.