diff options
| author | Caleb Garrett <[email protected]> | 2024-02-23 16:05:18 -0500 |
|---|---|---|
| committer | Caleb Garrett <[email protected]> | 2024-02-25 20:59:07 -0500 |
| commit | 967b4927b002dbcdcfbe968bf9c15014fc1de2a0 (patch) | |
| tree | 9bec3b3a10c99085bec4166a26191e4f92ad9209 /examples/stm32f7/src | |
| parent | bf4cbd75779b230e9e33a9d2a849f67335a68cf9 (diff) | |
Correct tag generation.
Diffstat (limited to 'examples/stm32f7/src')
| -rw-r--r-- | examples/stm32f7/src/bin/cryp.rs | 9 |
1 files changed, 6 insertions, 3 deletions
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) -> ! { | |||
| 51 | 51 | ||
| 52 | let sw_start_time = Instant::now(); | 52 | let sw_start_time = Instant::now(); |
| 53 | 53 | ||
| 54 | //Encrypt in software using AES-GCM 128-bit | 54 | // Encrypt in software using AES-GCM 128-bit |
| 55 | let mut payload_vec: Vec<u8, 32> = Vec::from_slice(&payload).unwrap(); | 55 | let mut payload_vec: Vec<u8, 32> = Vec::from_slice(&payload).unwrap(); |
| 56 | let cipher = Aes128Gcm::new(&key.into()); | 56 | let cipher = Aes128Gcm::new(&key.into()); |
| 57 | let _ = cipher.encrypt_in_place(&iv.into(), aad.into(), &mut payload_vec); | 57 | let _ = cipher.encrypt_in_place(&iv.into(), aad.into(), &mut payload_vec); |
| 58 | |||
| 59 | assert_eq!(ciphertext, payload_vec[0..ciphertext.len()]); | ||
| 60 | assert_eq!(encrypt_tag, payload_vec[ciphertext.len()..ciphertext.len() + encrypt_tag.len()]); | ||
| 58 | 61 | ||
| 59 | //Decrypt in software using AES-GCM 128-bit | 62 | // Decrypt in software using AES-GCM 128-bit |
| 60 | let _ = cipher.encrypt_in_place(&iv.into(), aad.into(), &mut payload_vec); | 63 | let _ = cipher.decrypt_in_place(&iv.into(), aad.into(), &mut payload_vec); |
| 61 | 64 | ||
| 62 | let sw_end_time = Instant::now(); | 65 | let sw_end_time = Instant::now(); |
| 63 | let sw_execution_time = sw_end_time - sw_start_time; | 66 | let sw_execution_time = sw_end_time - sw_start_time; |
