INNER CODE UNIT · Rust
decrypt_pickle
matrix-org/vodozemac · src/cipher/mod.rs:286
pub fn decrypt_pickle(&self, ciphertext: &[u8]) -> Result<Vec<u8>, DecryptionError> {
if ciphertext.len() < Mac::TRUNCATED_LEN + 1 {
Err(DecryptionError::MacMissing)
} else {
let (ciphertext, mac) = ciphertext.split_at(ciphertext.len() - Mac::TRUNCATED_LEN);
self.verify_truncated_mac(ciphertext, mac)?;
Ok(self.decrypt(ciphertext)?)
}
}
}
#[cfg(test)]
mod test {
use assert_matches2::assert_matches;
use super::{Cipher, Mac};
use crate::cipher::DecryptionError;