diff options
| author | Caleb Garrett <[email protected]> | 2024-02-24 16:14:44 -0500 |
|---|---|---|
| committer | Caleb Garrett <[email protected]> | 2024-02-25 20:59:07 -0500 |
| commit | f352b6d68b17fee886af58494b7e793cea3ea383 (patch) | |
| tree | 13ccbc3bc16b29d2a39db405a6a891a5ecf5c778 /examples/stm32f7/src/bin | |
| parent | 25ec838af597cc2e39c530b44f1a101c80b24260 (diff) | |
Address CI build issues.
Diffstat (limited to 'examples/stm32f7/src/bin')
| -rw-r--r-- | examples/stm32f7/src/bin/cryp.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/examples/stm32f7/src/bin/cryp.rs b/examples/stm32f7/src/bin/cryp.rs index be41955c5..04927841a 100644 --- a/examples/stm32f7/src/bin/cryp.rs +++ b/examples/stm32f7/src/bin/cryp.rs | |||
| @@ -1,10 +1,9 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | 3 | ||
| 4 | use aes_gcm::{ | 4 | use aes_gcm::aead::heapless::Vec; |
| 5 | aead::{heapless::Vec, AeadInPlace, KeyInit}, | 5 | use aes_gcm::aead::{AeadInPlace, KeyInit}; |
| 6 | Aes128Gcm, | 6 | use aes_gcm::Aes128Gcm; |
| 7 | }; | ||
| 8 | use defmt::info; | 7 | use defmt::info; |
| 9 | use embassy_executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 10 | use embassy_stm32::cryp::*; | 9 | use embassy_stm32::cryp::*; |
| @@ -55,9 +54,12 @@ async fn main(_spawner: Spawner) -> ! { | |||
| 55 | let mut payload_vec: Vec<u8, 32> = Vec::from_slice(&payload).unwrap(); | 54 | let mut payload_vec: Vec<u8, 32> = Vec::from_slice(&payload).unwrap(); |
| 56 | let cipher = Aes128Gcm::new(&key.into()); | 55 | let cipher = Aes128Gcm::new(&key.into()); |
| 57 | let _ = cipher.encrypt_in_place(&iv.into(), aad.into(), &mut payload_vec); | 56 | let _ = cipher.encrypt_in_place(&iv.into(), aad.into(), &mut payload_vec); |
| 58 | 57 | ||
| 59 | assert_eq!(ciphertext, payload_vec[0..ciphertext.len()]); | 58 | assert_eq!(ciphertext, payload_vec[0..ciphertext.len()]); |
| 60 | assert_eq!(encrypt_tag, payload_vec[ciphertext.len()..ciphertext.len() + encrypt_tag.len()]); | 59 | assert_eq!( |
| 60 | encrypt_tag, | ||
| 61 | payload_vec[ciphertext.len()..ciphertext.len() + encrypt_tag.len()] | ||
| 62 | ); | ||
| 61 | 63 | ||
| 62 | // Decrypt in software using AES-GCM 128-bit | 64 | // Decrypt in software using AES-GCM 128-bit |
| 63 | let _ = cipher.decrypt_in_place(&iv.into(), aad.into(), &mut payload_vec); | 65 | let _ = cipher.decrypt_in_place(&iv.into(), aad.into(), &mut payload_vec); |
