diff --git a/esp-hal/src/aes/mod.rs b/esp-hal/src/aes/mod.rs index 622462d2c2c..0580906249f 100644 --- a/esp-hal/src/aes/mod.rs +++ b/esp-hal/src/aes/mod.rs @@ -97,7 +97,7 @@ //! hw_encrypted, //! Mode::Encryption128, //! CipherMode::Ecb, -//! &keybuf, +//! keybuf.into(), //! ) //! .unwrap(); //! transfer.wait().unwrap(); @@ -307,7 +307,7 @@ pub mod dma { use embedded_dma::{ReadBuffer, WriteBuffer}; use crate::{ - aes::Mode, + aes::{Key, Mode}, dma::{ AesPeripheral, Channel, @@ -441,10 +441,10 @@ pub mod dma { { /// Writes the encryption key to the AES hardware, checking that its /// length matches expected constraints. - pub fn write_key(&mut self, key: &[u8]) { - debug_assert!(key.len() <= 8 * ALIGN_SIZE); - debug_assert_eq!(key.len() % ALIGN_SIZE, 0); - self.aes.write_key(key); + pub fn write_key(&mut self, key: Key) { + debug_assert!(key.as_slice().len() <= 8 * ALIGN_SIZE); + debug_assert_eq!(key.as_slice().len() % ALIGN_SIZE, 0); + self.aes.write_key(key.as_slice()); } /// Writes a block of data to the AES hardware, ensuring the block's @@ -465,7 +465,7 @@ pub mod dma { read_buffer: &'t mut RXBUF, mode: Mode, cipher_mode: CipherMode, - key: &[u8], + key: Key, ) -> Result, crate::dma::DmaError> where TXBUF: ReadBuffer, @@ -496,7 +496,7 @@ pub mod dma { read_buffer_len: usize, mode: Mode, cipher_mode: CipherMode, - key: &[u8], + key: Key, ) -> Result<(), crate::dma::DmaError> { // AES has to be restarted after each calculation self.reset_aes(); diff --git a/examples/src/bin/aes_dma.rs b/examples/src/bin/aes_dma.rs index 6e9c8e2387c..f64dac8d169 100644 --- a/examples/src/bin/aes_dma.rs +++ b/examples/src/bin/aes_dma.rs @@ -50,7 +50,7 @@ fn main() -> ! { &mut output, Mode::Encryption128, CipherMode::Ecb, - &keytext, + keytext.into(), ) .unwrap(); transfer.wait().unwrap(); @@ -72,7 +72,7 @@ fn main() -> ! { &mut output, Mode::Decryption128, CipherMode::Ecb, - &keytext, + keytext.into(), ) .unwrap(); transfer.wait().unwrap(); diff --git a/hil-test/tests/aes_dma.rs b/hil-test/tests/aes_dma.rs index 774d58732b6..e5fdd262abf 100644 --- a/hil-test/tests/aes_dma.rs +++ b/hil-test/tests/aes_dma.rs @@ -66,7 +66,7 @@ mod tests { &mut output, Mode::Encryption128, CipherMode::Ecb, - &keybuf, + keybuf.into(), ) .unwrap(); transfer.wait().unwrap(); @@ -111,7 +111,7 @@ mod tests { &mut output, Mode::Decryption128, CipherMode::Ecb, - &keybuf, + keybuf.into(), ) .unwrap(); transfer.wait().unwrap(); @@ -157,7 +157,7 @@ mod tests { &mut output, Mode::Encryption256, CipherMode::Ecb, - &keybuf, + keybuf.into(), ) .unwrap(); transfer.wait().unwrap(); @@ -202,7 +202,7 @@ mod tests { &mut output, Mode::Decryption256, CipherMode::Ecb, - &keybuf, + keybuf.into(), ) .unwrap(); transfer.wait().unwrap();