diff options
| author | Caleb Garrett <[email protected]> | 2024-02-11 11:32:29 -0500 |
|---|---|---|
| committer | Caleb Garrett <[email protected]> | 2024-02-11 11:32:29 -0500 |
| commit | eb64d71247dd7c217c7ead98635610fdd8a104e3 (patch) | |
| tree | 3173d8df9f869b9a20ef91625b814a23801c6e36 /examples/stm32f7 | |
| parent | 0c9661a66164736aae9f4c9df250494c17379f5c (diff) | |
Consolidated hash drivers.
Diffstat (limited to 'examples/stm32f7')
| -rw-r--r-- | examples/stm32f7/src/bin/hash.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/examples/stm32f7/src/bin/hash.rs b/examples/stm32f7/src/bin/hash.rs index 7d96bd49c..31f8d32a7 100644 --- a/examples/stm32f7/src/bin/hash.rs +++ b/examples/stm32f7/src/bin/hash.rs | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::info; | 4 | use defmt::info; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::{bind_interrupts, Config, hash, hash::*, peripherals}; | 6 | use embassy_stm32::{bind_interrupts, hash, hash::*, peripherals, Config}; |
| 7 | use embassy_time::Instant; | 7 | use embassy_time::Instant; |
| 8 | use sha2::{Digest, Sha256}; | 8 | use sha2::{Digest, Sha256}; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| @@ -25,11 +25,11 @@ async fn main(_spawner: Spawner) -> ! { | |||
| 25 | let hw_start_time = Instant::now(); | 25 | let hw_start_time = Instant::now(); |
| 26 | 26 | ||
| 27 | // Compute a digest in hardware. | 27 | // Compute a digest in hardware. |
| 28 | let mut context = hw_hasher.start(Algorithm::SHA256, DataType::Width8).await; | 28 | let mut context = hw_hasher.start(Algorithm::SHA256, DataType::Width8); |
| 29 | hw_hasher.update(&mut context, test_1).await; | 29 | hw_hasher.update(&mut context, test_1).await; |
| 30 | hw_hasher.update(&mut context, test_2).await; | 30 | hw_hasher.update(&mut context, test_2).await; |
| 31 | let mut buffer: [u8; 64] = [0; 64]; | 31 | let mut hw_digest: [u8; 32] = [0; 32]; |
| 32 | let hw_digest = hw_hasher.finish(context, &mut buffer).await; | 32 | hw_hasher.finish(context, &mut hw_digest).await; |
| 33 | 33 | ||
| 34 | let hw_end_time = Instant::now(); | 34 | let hw_end_time = Instant::now(); |
| 35 | let hw_execution_time = hw_end_time - hw_start_time; | 35 | let hw_execution_time = hw_end_time - hw_start_time; |
| @@ -49,7 +49,7 @@ async fn main(_spawner: Spawner) -> ! { | |||
| 49 | info!("Software Digest: {:?}", sw_digest[..]); | 49 | info!("Software Digest: {:?}", sw_digest[..]); |
| 50 | info!("Hardware Execution Time: {:?}", hw_execution_time); | 50 | info!("Hardware Execution Time: {:?}", hw_execution_time); |
| 51 | info!("Software Execution Time: {:?}", sw_execution_time); | 51 | info!("Software Execution Time: {:?}", sw_execution_time); |
| 52 | assert_eq!(*hw_digest, sw_digest[..]); | 52 | assert_eq!(hw_digest, sw_digest[..]); |
| 53 | 53 | ||
| 54 | loop {} | 54 | loop {} |
| 55 | } | 55 | } |
