xchacha20: Avoid reallocation on subkey-generation using From impl.
@@ -116,13 +116,13 @@ pub fn encrypt(
dst_out: &mut [u8],
) -> Result<(), UnknownCryptoError> {
let subkey: SecretKey =
- SecretKey::from_slice(&chacha20::hchacha20(secret_key, &nonce.as_ref()[0..16])?)?;
+ SecretKey::from(chacha20::hchacha20(secret_key, &nonce.as_ref()[0..16])?);
let mut prefixed_nonce = [0u8; IETF_CHACHA_NONCESIZE];
prefixed_nonce[4..IETF_CHACHA_NONCESIZE].copy_from_slice(&nonce.as_ref()[16..24]);
chacha20::encrypt(
&subkey,
- &IETFNonce::from_slice(&prefixed_nonce)?,
+ &IETFNonce::from(prefixed_nonce),
initial_counter,
plaintext,
dst_out,
