Add comments
This commit is contained in:
parent
ae19a16531
commit
56db45cbad
1 changed files with 5 additions and 0 deletions
|
@ -42,12 +42,17 @@ pub(crate) fn xchacha20poly1305_decrypt(
|
|||
encrypted_data: &EncryptedData,
|
||||
aad: &str,
|
||||
) -> Result<Vec<u8>> {
|
||||
// Adapt the key and nonce
|
||||
let key = Key::from_slice(key);
|
||||
let nonce = XNonce::from_slice(&encrypted_data.nonce);
|
||||
|
||||
// Prepare the payload
|
||||
let payload = Payload {
|
||||
msg: &encrypted_data.ciphertext,
|
||||
aad: aad.as_bytes(),
|
||||
};
|
||||
|
||||
// Decrypt the payload and return
|
||||
let cipher = XChaCha20Poly1305::new(key);
|
||||
Ok(cipher.decrypt(nonce, payload)?)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue