Challenge Assignment
Write a Rust function using the aes-gcm crate:
fn encrypt(key: &[u8; 32], plaintext: &[u8]) -> (Vec<u8>, [u8; 12]);
fn decrypt(key: &[u8; 32], nonce: &[u8; 12], ciphertext: &[u8]) -> Result<Vec<u8>, Error>;
Requirements:
- Generate a random nonce using
rand crate (do not hardcode it)
- Verify that modifying one byte of ciphertext causes decryption to fail
- Verify that reusing a nonce with a different message produces different ciphertext
Add aes-gcm = "0.10" and rand = "0.8" to Cargo.toml.