From 967b4927b002dbcdcfbe968bf9c15014fc1de2a0 Mon Sep 17 00:00:00 2001 From: Caleb Garrett <47389035+caleb-garrett@users.noreply.github.com> Date: Fri, 23 Feb 2024 16:05:18 -0500 Subject: Correct tag generation. --- examples/stm32f7/src/bin/cryp.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'examples') diff --git a/examples/stm32f7/src/bin/cryp.rs b/examples/stm32f7/src/bin/cryp.rs index c1b80ddc3..be41955c5 100644 --- a/examples/stm32f7/src/bin/cryp.rs +++ b/examples/stm32f7/src/bin/cryp.rs @@ -51,13 +51,16 @@ async fn main(_spawner: Spawner) -> ! { let sw_start_time = Instant::now(); - //Encrypt in software using AES-GCM 128-bit + // Encrypt in software using AES-GCM 128-bit let mut payload_vec: Vec = Vec::from_slice(&payload).unwrap(); let cipher = Aes128Gcm::new(&key.into()); let _ = cipher.encrypt_in_place(&iv.into(), aad.into(), &mut payload_vec); + + assert_eq!(ciphertext, payload_vec[0..ciphertext.len()]); + assert_eq!(encrypt_tag, payload_vec[ciphertext.len()..ciphertext.len() + encrypt_tag.len()]); - //Decrypt in software using AES-GCM 128-bit - let _ = cipher.encrypt_in_place(&iv.into(), aad.into(), &mut payload_vec); + // Decrypt in software using AES-GCM 128-bit + let _ = cipher.decrypt_in_place(&iv.into(), aad.into(), &mut payload_vec); let sw_end_time = Instant::now(); let sw_execution_time = sw_end_time - sw_start_time; -- cgit