INNER CODE UNIT · Rust
decrypt
matrix-org/vodozemac · src/cipher/mod.rs:202
pub fn decrypt(&self, ciphertext: &[u8]) -> Result<Vec<u8>, UnpadError> {
let cipher = Aes256CbcDec::new(self.keys.aes_key(), self.keys.iv());
cipher.decrypt_padded_vec::<Pkcs7>(ciphertext)
}
/// Verifies that the provided message authentication code (MAC) correctly
/// authenticates the given message.
///
/// **Warning**: This is a low-level function and must be called before
/// invoking the [`Cipher::decrypt()`] method.
#[cfg(all(not(fuzzing), feature = "experimental-session-config"))]
#[allow(unreachable_pub)]
pub fn verify_mac(&self, message: &[u8], tag: &Mac) -> Result<(), MacError> {
let mut hmac = self.get_hmac();
hmac.update(message);
hmac.verify_slice(tag.as_bytes())
}