Function psa_crypto::operations::cipher::decrypt
source · pub fn decrypt(
key_id: Id,
alg: Cipher,
ciphertext: &[u8],
iv: &[u8],
plaintext: &mut [u8]
) -> Result<usize>
Expand description
Decrypt a short message with a key
The decrypted message is written in plaintext
. The function returns the number of bytes written.
Example
psa_crypto::init().unwrap();
let my_key = generate(attributes, None).unwrap();
let alg = Cipher::Ctr;
let iv = vec![0; 16];
let mut decrypted_message = vec![0; MESSAGE.len()];
let size = decrypt(my_key, alg, &MESSAGE, &iv, &mut decrypted_message).unwrap();