aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-stm32/src/cryp/mod.rs98
-rw-r--r--examples/stm32f7/src/bin/cryp.rs4
-rw-r--r--tests/stm32/src/bin/cryp.rs6
3 files changed, 66 insertions, 42 deletions
diff --git a/embassy-stm32/src/cryp/mod.rs b/embassy-stm32/src/cryp/mod.rs
index aa4c2a024..74b095b6f 100644
--- a/embassy-stm32/src/cryp/mod.rs
+++ b/embassy-stm32/src/cryp/mod.rs
@@ -60,11 +60,12 @@ pub trait Cipher<'c> {
60 fn init_phase_blocking<T: Instance, DmaIn, DmaOut>(&self, _p: &pac::cryp::Cryp, _cryp: &Cryp<T, DmaIn, DmaOut>) {} 60 fn init_phase_blocking<T: Instance, DmaIn, DmaOut>(&self, _p: &pac::cryp::Cryp, _cryp: &Cryp<T, DmaIn, DmaOut>) {}
61 61
62 /// Performs any cipher-specific initialization. 62 /// Performs any cipher-specific initialization.
63 async fn init_phase<T: Instance, DmaIn, DmaOut>(&self, _p: &pac::cryp::Cryp, _cryp: &mut Cryp<'_, T, DmaIn, DmaOut>) 63 async fn init_phase<T: Instance, DmaIn, DmaOut>(&self, _p: &pac::cryp::Cryp, _cryp: &mut Cryp<'_, T, DmaIn, DmaOut>)
64 where 64 where
65 DmaIn: crate::cryp::DmaIn<T>, 65 DmaIn: crate::cryp::DmaIn<T>,
66 DmaOut: crate::cryp::DmaOut<T>, 66 DmaOut: crate::cryp::DmaOut<T>,
67 {} 67 {
68 }
68 69
69 /// Called prior to processing the last data block for cipher-specific operations. 70 /// Called prior to processing the last data block for cipher-specific operations.
70 fn pre_final(&self, _p: &pac::cryp::Cryp, _dir: Direction, _padding_len: usize) -> [u32; 4] { 71 fn pre_final(&self, _p: &pac::cryp::Cryp, _dir: Direction, _padding_len: usize) -> [u32; 4] {
@@ -92,11 +93,11 @@ pub trait Cipher<'c> {
92 _int_data: &mut [u8; AES_BLOCK_SIZE], 93 _int_data: &mut [u8; AES_BLOCK_SIZE],
93 _temp1: [u32; 4], 94 _temp1: [u32; 4],
94 _padding_mask: [u8; 16], 95 _padding_mask: [u8; 16],
95 ) 96 ) where
96 where
97 DmaIn: crate::cryp::DmaIn<T>, 97 DmaIn: crate::cryp::DmaIn<T>,
98 DmaOut: crate::cryp::DmaOut<T>, 98 DmaOut: crate::cryp::DmaOut<T>,
99 {} 99 {
100 }
100 101
101 /// Returns the AAD header block as required by the cipher. 102 /// Returns the AAD header block as required by the cipher.
102 fn get_header_block(&self) -> &[u8] { 103 fn get_header_block(&self) -> &[u8] {
@@ -479,7 +480,11 @@ impl<'c, const KEY_SIZE: usize> Cipher<'c> for AesGcm<'c, KEY_SIZE> {
479 while p.cr().read().crypen() {} 480 while p.cr().read().crypen() {}
480 } 481 }
481 482
482 async fn init_phase<T: Instance, DmaIn, DmaOut>(&self, p: &pac::cryp::Cryp, _cryp: &mut Cryp<'_, T, DmaIn, DmaOut>) { 483 async fn init_phase<T: Instance, DmaIn, DmaOut>(
484 &self,
485 p: &pac::cryp::Cryp,
486 _cryp: &mut Cryp<'_, T, DmaIn, DmaOut>,
487 ) {
483 p.cr().modify(|w| w.set_gcm_ccmph(0)); 488 p.cr().modify(|w| w.set_gcm_ccmph(0));
484 p.cr().modify(|w| w.set_crypen(true)); 489 p.cr().modify(|w| w.set_crypen(true));
485 while p.cr().read().crypen() {} 490 while p.cr().read().crypen() {}
@@ -541,12 +546,10 @@ impl<'c, const KEY_SIZE: usize> Cipher<'c> for AesGcm<'c, KEY_SIZE> {
541 int_data: &mut [u8; AES_BLOCK_SIZE], 546 int_data: &mut [u8; AES_BLOCK_SIZE],
542 _temp1: [u32; 4], 547 _temp1: [u32; 4],
543 padding_mask: [u8; AES_BLOCK_SIZE], 548 padding_mask: [u8; AES_BLOCK_SIZE],
544 ) 549 ) where
545 where 550 DmaIn: crate::cryp::DmaIn<T>,
546 DmaIn: crate::cryp::DmaIn<T>,
547 DmaOut: crate::cryp::DmaOut<T>, 551 DmaOut: crate::cryp::DmaOut<T>,
548 { 552 {
549
550 if dir == Direction::Encrypt { 553 if dir == Direction::Encrypt {
551 // Handle special GCM partial block process. 554 // Handle special GCM partial block process.
552 p.cr().modify(|w| w.set_crypen(false)); 555 p.cr().modify(|w| w.set_crypen(false));
@@ -562,7 +565,7 @@ impl<'c, const KEY_SIZE: usize> Cipher<'c> for AesGcm<'c, KEY_SIZE> {
562 565
563 let read = Cryp::<T, DmaIn, DmaOut>::read_bytes(&mut cryp.outdma, Self::BLOCK_SIZE, &mut out_data); 566 let read = Cryp::<T, DmaIn, DmaOut>::read_bytes(&mut cryp.outdma, Self::BLOCK_SIZE, &mut out_data);
564 let write = Cryp::<T, DmaIn, DmaOut>::write_bytes(&mut cryp.indma, Self::BLOCK_SIZE, int_data); 567 let write = Cryp::<T, DmaIn, DmaOut>::write_bytes(&mut cryp.indma, Self::BLOCK_SIZE, int_data);
565 568
566 embassy_futures::join::join(read, write).await; 569 embassy_futures::join::join(read, write).await;
567 570
568 int_data.copy_from_slice(&out_data); 571 int_data.copy_from_slice(&out_data);
@@ -622,7 +625,11 @@ impl<'c, const KEY_SIZE: usize> Cipher<'c> for AesGmac<'c, KEY_SIZE> {
622 while p.cr().read().crypen() {} 625 while p.cr().read().crypen() {}
623 } 626 }
624 627
625 async fn init_phase<T: Instance, DmaIn, DmaOut>(&self, p: &pac::cryp::Cryp, _cryp: &mut Cryp<'_, T, DmaIn, DmaOut>) { 628 async fn init_phase<T: Instance, DmaIn, DmaOut>(
629 &self,
630 p: &pac::cryp::Cryp,
631 _cryp: &mut Cryp<'_, T, DmaIn, DmaOut>,
632 ) {
626 p.cr().modify(|w| w.set_gcm_ccmph(0)); 633 p.cr().modify(|w| w.set_gcm_ccmph(0));
627 p.cr().modify(|w| w.set_crypen(true)); 634 p.cr().modify(|w| w.set_crypen(true));
628 while p.cr().read().crypen() {} 635 while p.cr().read().crypen() {}
@@ -684,12 +691,10 @@ impl<'c, const KEY_SIZE: usize> Cipher<'c> for AesGmac<'c, KEY_SIZE> {
684 int_data: &mut [u8; AES_BLOCK_SIZE], 691 int_data: &mut [u8; AES_BLOCK_SIZE],
685 _temp1: [u32; 4], 692 _temp1: [u32; 4],
686 padding_mask: [u8; AES_BLOCK_SIZE], 693 padding_mask: [u8; AES_BLOCK_SIZE],
687 ) 694 ) where
688 where 695 DmaIn: crate::cryp::DmaIn<T>,
689 DmaIn: crate::cryp::DmaIn<T>,
690 DmaOut: crate::cryp::DmaOut<T>, 696 DmaOut: crate::cryp::DmaOut<T>,
691 { 697 {
692
693 if dir == Direction::Encrypt { 698 if dir == Direction::Encrypt {
694 // Handle special GCM partial block process. 699 // Handle special GCM partial block process.
695 p.cr().modify(|w| w.set_crypen(false)); 700 p.cr().modify(|w| w.set_crypen(false));
@@ -705,7 +710,7 @@ impl<'c, const KEY_SIZE: usize> Cipher<'c> for AesGmac<'c, KEY_SIZE> {
705 710
706 let read = Cryp::<T, DmaIn, DmaOut>::read_bytes(&mut cryp.outdma, Self::BLOCK_SIZE, &mut out_data); 711 let read = Cryp::<T, DmaIn, DmaOut>::read_bytes(&mut cryp.outdma, Self::BLOCK_SIZE, &mut out_data);
707 let write = Cryp::<T, DmaIn, DmaOut>::write_bytes(&mut cryp.indma, Self::BLOCK_SIZE, int_data); 712 let write = Cryp::<T, DmaIn, DmaOut>::write_bytes(&mut cryp.indma, Self::BLOCK_SIZE, int_data);
708 713
709 embassy_futures::join::join(read, write).await; 714 embassy_futures::join::join(read, write).await;
710 } 715 }
711 } 716 }
@@ -826,7 +831,7 @@ impl<'c, const KEY_SIZE: usize, const TAG_SIZE: usize, const IV_SIZE: usize> Cip
826 831
827 async fn init_phase<T: Instance, DmaIn, DmaOut>(&self, p: &pac::cryp::Cryp, cryp: &mut Cryp<'_, T, DmaIn, DmaOut>) 832 async fn init_phase<T: Instance, DmaIn, DmaOut>(&self, p: &pac::cryp::Cryp, cryp: &mut Cryp<'_, T, DmaIn, DmaOut>)
828 where 833 where
829 DmaIn: crate::cryp::DmaIn<T>, 834 DmaIn: crate::cryp::DmaIn<T>,
830 DmaOut: crate::cryp::DmaOut<T>, 835 DmaOut: crate::cryp::DmaOut<T>,
831 { 836 {
832 p.cr().modify(|w| w.set_gcm_ccmph(0)); 837 p.cr().modify(|w| w.set_gcm_ccmph(0));
@@ -913,8 +918,7 @@ impl<'c, const KEY_SIZE: usize, const TAG_SIZE: usize, const IV_SIZE: usize> Cip
913 int_data: &mut [u8; AES_BLOCK_SIZE], 918 int_data: &mut [u8; AES_BLOCK_SIZE],
914 temp1: [u32; 4], 919 temp1: [u32; 4],
915 padding_mask: [u8; 16], 920 padding_mask: [u8; 16],
916 ) 921 ) where
917 where
918 DmaIn: crate::cryp::DmaIn<T>, 922 DmaIn: crate::cryp::DmaIn<T>,
919 DmaOut: crate::cryp::DmaOut<T>, 923 DmaOut: crate::cryp::DmaOut<T>,
920 { 924 {
@@ -1040,7 +1044,11 @@ impl<'d, T: Instance, DmaIn, DmaOut> Cryp<'d, T, DmaIn, DmaOut> {
1040 } 1044 }
1041 1045
1042 /// Start a new encrypt or decrypt operation for the given cipher. 1046 /// Start a new encrypt or decrypt operation for the given cipher.
1043 pub fn start_blocking<'c, C: Cipher<'c> + CipherSized + IVSized>(&self, cipher: &'c C, dir: Direction) -> Context<'c, C> { 1047 pub fn start_blocking<'c, C: Cipher<'c> + CipherSized + IVSized>(
1048 &self,
1049 cipher: &'c C,
1050 dir: Direction,
1051 ) -> Context<'c, C> {
1044 let mut ctx: Context<'c, C> = Context { 1052 let mut ctx: Context<'c, C> = Context {
1045 dir, 1053 dir,
1046 last_block_processed: false, 1054 last_block_processed: false,
@@ -1115,7 +1123,11 @@ impl<'d, T: Instance, DmaIn, DmaOut> Cryp<'d, T, DmaIn, DmaOut> {
1115 } 1123 }
1116 1124
1117 /// Start a new encrypt or decrypt operation for the given cipher. 1125 /// Start a new encrypt or decrypt operation for the given cipher.
1118 pub async fn start<'c, C: Cipher<'c> + CipherSized + IVSized>(&mut self, cipher: &'c C, dir: Direction) -> Context<'c, C> 1126 pub async fn start<'c, C: Cipher<'c> + CipherSized + IVSized>(
1127 &mut self,
1128 cipher: &'c C,
1129 dir: Direction,
1130 ) -> Context<'c, C>
1119 where 1131 where
1120 DmaIn: crate::cryp::DmaIn<T>, 1132 DmaIn: crate::cryp::DmaIn<T>,
1121 DmaOut: crate::cryp::DmaOut<T>, 1133 DmaOut: crate::cryp::DmaOut<T>,
@@ -1296,17 +1308,12 @@ impl<'d, T: Instance, DmaIn, DmaOut> Cryp<'d, T, DmaIn, DmaOut> {
1296 /// All additional associated data (AAD) must be supplied to this function prior to starting the payload phase with `payload`. 1308 /// All additional associated data (AAD) must be supplied to this function prior to starting the payload phase with `payload`.
1297 /// The AAD must be supplied in multiples of the block size (128-bits for AES, 64-bits for DES), except when supplying the last block. 1309 /// The AAD must be supplied in multiples of the block size (128-bits for AES, 64-bits for DES), except when supplying the last block.
1298 /// When supplying the last block of AAD, `last_aad_block` must be `true`. 1310 /// When supplying the last block of AAD, `last_aad_block` must be `true`.
1299 pub async fn aad< 1311 pub async fn aad<'c, const TAG_SIZE: usize, C: Cipher<'c> + CipherSized + IVSized + CipherAuthenticated<TAG_SIZE>>(
1300 'c,
1301 const TAG_SIZE: usize,
1302 C: Cipher<'c> + CipherSized + IVSized + CipherAuthenticated<TAG_SIZE>,
1303 >(
1304 &mut self, 1312 &mut self,
1305 ctx: &mut Context<'c, C>, 1313 ctx: &mut Context<'c, C>,
1306 aad: &[u8], 1314 aad: &[u8],
1307 last_aad_block: bool, 1315 last_aad_block: bool,
1308 ) 1316 ) where
1309 where
1310 DmaIn: crate::cryp::DmaIn<T>, 1317 DmaIn: crate::cryp::DmaIn<T>,
1311 DmaOut: crate::cryp::DmaOut<T>, 1318 DmaOut: crate::cryp::DmaOut<T>,
1312 { 1319 {
@@ -1493,8 +1500,7 @@ impl<'d, T: Instance, DmaIn, DmaOut> Cryp<'d, T, DmaIn, DmaOut> {
1493 input: &[u8], 1500 input: &[u8],
1494 output: &mut [u8], 1501 output: &mut [u8],
1495 last_block: bool, 1502 last_block: bool,
1496 ) 1503 ) where
1497 where
1498 DmaIn: crate::cryp::DmaIn<T>, 1504 DmaIn: crate::cryp::DmaIn<T>,
1499 DmaOut: crate::cryp::DmaOut<T>, 1505 DmaOut: crate::cryp::DmaOut<T>,
1500 { 1506 {
@@ -1540,7 +1546,11 @@ impl<'d, T: Instance, DmaIn, DmaOut> Cryp<'d, T, DmaIn, DmaOut> {
1540 for block in 0..num_full_blocks { 1546 for block in 0..num_full_blocks {
1541 let index = block * C::BLOCK_SIZE; 1547 let index = block * C::BLOCK_SIZE;
1542 // Read block out 1548 // Read block out
1543 let read = Self::read_bytes(&mut self.outdma, C::BLOCK_SIZE, &mut output[index..index + C::BLOCK_SIZE]); 1549 let read = Self::read_bytes(
1550 &mut self.outdma,
1551 C::BLOCK_SIZE,
1552 &mut output[index..index + C::BLOCK_SIZE],
1553 );
1544 // Write block in 1554 // Write block in
1545 let write = Self::write_bytes(&mut self.indma, C::BLOCK_SIZE, &input[index..index + C::BLOCK_SIZE]); 1555 let write = Self::write_bytes(&mut self.indma, C::BLOCK_SIZE, &input[index..index + C::BLOCK_SIZE]);
1546 embassy_futures::join::join(read, write).await; 1556 embassy_futures::join::join(read, write).await;
@@ -1566,7 +1576,8 @@ impl<'d, T: Instance, DmaIn, DmaOut> Cryp<'d, T, DmaIn, DmaOut> {
1566 let mut mask: [u8; 16] = [0; 16]; 1576 let mut mask: [u8; 16] = [0; 16];
1567 mask[..last_block_remainder].fill(0xFF); 1577 mask[..last_block_remainder].fill(0xFF);
1568 ctx.cipher 1578 ctx.cipher
1569 .post_final(&T::regs(), self, ctx.dir, &mut intermediate_data, temp1, mask).await; 1579 .post_final(&T::regs(), self, ctx.dir, &mut intermediate_data, temp1, mask)
1580 .await;
1570 } 1581 }
1571 1582
1572 ctx.payload_len += input.len() as u64; 1583 ctx.payload_len += input.len() as u64;
@@ -1623,7 +1634,14 @@ impl<'d, T: Instance, DmaIn, DmaOut> Cryp<'d, T, DmaIn, DmaOut> {
1623 #[cfg(any(cryp_v2, cryp_v3))] 1634 #[cfg(any(cryp_v2, cryp_v3))]
1624 // Generates an authentication tag for authenticated ciphers including GCM, CCM, and GMAC. 1635 // Generates an authentication tag for authenticated ciphers including GCM, CCM, and GMAC.
1625 /// Called after the all data has been encrypted/decrypted by `payload`. 1636 /// Called after the all data has been encrypted/decrypted by `payload`.
1626 pub async fn finish<'c, const TAG_SIZE: usize, C: Cipher<'c> + CipherSized + IVSized + CipherAuthenticated<TAG_SIZE>>(&mut self, mut ctx: Context<'c, C>) -> [u8; TAG_SIZE] 1637 pub async fn finish<
1638 'c,
1639 const TAG_SIZE: usize,
1640 C: Cipher<'c> + CipherSized + IVSized + CipherAuthenticated<TAG_SIZE>,
1641 >(
1642 &mut self,
1643 mut ctx: Context<'c, C>,
1644 ) -> [u8; TAG_SIZE]
1627 where 1645 where
1628 DmaIn: crate::cryp::DmaIn<T>, 1646 DmaIn: crate::cryp::DmaIn<T>,
1629 DmaOut: crate::cryp::DmaOut<T>, 1647 DmaOut: crate::cryp::DmaOut<T>,
@@ -1663,7 +1681,7 @@ impl<'d, T: Instance, DmaIn, DmaOut> Cryp<'d, T, DmaIn, DmaOut> {
1663 1681
1664 tag 1682 tag
1665 } 1683 }
1666 1684
1667 fn load_key(&self, key: &[u8]) { 1685 fn load_key(&self, key: &[u8]) {
1668 // Load the key into the registers. 1686 // Load the key into the registers.
1669 let mut keyidx = 0; 1687 let mut keyidx = 0;
@@ -1766,7 +1784,7 @@ impl<'d, T: Instance, DmaIn, DmaOut> Cryp<'d, T, DmaIn, DmaOut> {
1766 1784
1767 async fn write_bytes(dma: &mut PeripheralRef<'_, DmaIn>, block_size: usize, blocks: &[u8]) 1785 async fn write_bytes(dma: &mut PeripheralRef<'_, DmaIn>, block_size: usize, blocks: &[u8])
1768 where 1786 where
1769 DmaIn: crate::cryp::DmaIn<T>, 1787 DmaIn: crate::cryp::DmaIn<T>,
1770 { 1788 {
1771 if blocks.len() == 0 { 1789 if blocks.len() == 0 {
1772 return; 1790 return;
@@ -1788,6 +1806,7 @@ impl<'d, T: Instance, DmaIn, DmaOut> Cryp<'d, T, DmaIn, DmaOut> {
1788 dma_transfer.await; 1806 dma_transfer.await;
1789 } 1807 }
1790 1808
1809 #[cfg(any(cryp_v2, cryp_v3))]
1791 fn write_words_blocking(&self, block_size: usize, blocks: &[u32]) { 1810 fn write_words_blocking(&self, block_size: usize, blocks: &[u32]) {
1792 assert_eq!((blocks.len() * 4) % block_size, 0); 1811 assert_eq!((blocks.len() * 4) % block_size, 0);
1793 let mut byte_counter: usize = 0; 1812 let mut byte_counter: usize = 0;
@@ -1801,10 +1820,11 @@ impl<'d, T: Instance, DmaIn, DmaOut> Cryp<'d, T, DmaIn, DmaOut> {
1801 } 1820 }
1802 } 1821 }
1803 1822
1823 #[cfg(any(cryp_v2, cryp_v3))]
1804 async fn write_words(dma: &mut PeripheralRef<'_, DmaIn>, block_size: usize, blocks: &[u32]) 1824 async fn write_words(dma: &mut PeripheralRef<'_, DmaIn>, block_size: usize, blocks: &[u32])
1805 where 1825 where
1806 DmaIn: crate::cryp::DmaIn<T>, 1826 DmaIn: crate::cryp::DmaIn<T>,
1807 { 1827 {
1808 if blocks.len() == 0 { 1828 if blocks.len() == 0 {
1809 return; 1829 return;
1810 } 1830 }
@@ -1840,7 +1860,7 @@ impl<'d, T: Instance, DmaIn, DmaOut> Cryp<'d, T, DmaIn, DmaOut> {
1840 } 1860 }
1841 } 1861 }
1842 1862
1843 async fn read_bytes(dma: &mut PeripheralRef<'_, DmaOut>, block_size: usize, blocks: &mut [u8]) 1863 async fn read_bytes(dma: &mut PeripheralRef<'_, DmaOut>, block_size: usize, blocks: &mut [u8])
1844 where 1864 where
1845 DmaOut: crate::cryp::DmaOut<T>, 1865 DmaOut: crate::cryp::DmaOut<T>,
1846 { 1866 {
@@ -1894,4 +1914,4 @@ foreach_interrupt!(
1894); 1914);
1895 1915
1896dma_trait!(DmaIn, Instance); 1916dma_trait!(DmaIn, Instance);
1897dma_trait!(DmaOut, Instance); \ No newline at end of file 1917dma_trait!(DmaOut, Instance);
diff --git a/examples/stm32f7/src/bin/cryp.rs b/examples/stm32f7/src/bin/cryp.rs
index a5418765b..ce2cf0489 100644
--- a/examples/stm32f7/src/bin/cryp.rs
+++ b/examples/stm32f7/src/bin/cryp.rs
@@ -44,7 +44,9 @@ async fn main(_spawner: Spawner) -> ! {
44 // Decrypt in hardware using AES-GCM 128-bit 44 // Decrypt in hardware using AES-GCM 128-bit
45 let mut gcm_decrypt = hw_cryp.start(&aes_gcm, Direction::Decrypt).await; 45 let mut gcm_decrypt = hw_cryp.start(&aes_gcm, Direction::Decrypt).await;
46 hw_cryp.aad(&mut gcm_decrypt, aad, true).await; 46 hw_cryp.aad(&mut gcm_decrypt, aad, true).await;
47 hw_cryp.payload(&mut gcm_decrypt, &ciphertext, &mut plaintext, true).await; 47 hw_cryp
48 .payload(&mut gcm_decrypt, &ciphertext, &mut plaintext, true)
49 .await;
48 let decrypt_tag = hw_cryp.finish(gcm_decrypt).await; 50 let decrypt_tag = hw_cryp.finish(gcm_decrypt).await;
49 51
50 let hw_end_time = Instant::now(); 52 let hw_end_time = Instant::now();
diff --git a/tests/stm32/src/bin/cryp.rs b/tests/stm32/src/bin/cryp.rs
index 6bca55f55..cc317f625 100644
--- a/tests/stm32/src/bin/cryp.rs
+++ b/tests/stm32/src/bin/cryp.rs
@@ -13,7 +13,7 @@ use embassy_executor::Spawner;
13use embassy_stm32::{ 13use embassy_stm32::{
14 bind_interrupts, 14 bind_interrupts,
15 cryp::{self, *}, 15 cryp::{self, *},
16 peripherals 16 peripherals,
17}; 17};
18use {defmt_rtt as _, panic_probe as _}; 18use {defmt_rtt as _, panic_probe as _};
19 19
@@ -52,7 +52,9 @@ async fn main(_spawner: Spawner) {
52 let mut gcm_decrypt = hw_cryp.start(&aes_gcm, Direction::Decrypt).await; 52 let mut gcm_decrypt = hw_cryp.start(&aes_gcm, Direction::Decrypt).await;
53 hw_cryp.aad(&mut gcm_decrypt, AAD1, false).await; 53 hw_cryp.aad(&mut gcm_decrypt, AAD1, false).await;
54 hw_cryp.aad(&mut gcm_decrypt, AAD2, true).await; 54 hw_cryp.aad(&mut gcm_decrypt, AAD2, true).await;
55 hw_cryp.payload(&mut gcm_decrypt, &ciphertext, &mut plaintext, true).await; 55 hw_cryp
56 .payload(&mut gcm_decrypt, &ciphertext, &mut plaintext, true)
57 .await;
56 let decrypt_tag = hw_cryp.finish(gcm_decrypt).await; 58 let decrypt_tag = hw_cryp.finish(gcm_decrypt).await;
57 59
58 info!("AES-GCM Ciphertext: {:?}", ciphertext); 60 info!("AES-GCM Ciphertext: {:?}", ciphertext);