Struct nrf52840_hal::Ccm
source · pub struct Ccm { /* private fields */ }
Expand description
A safe, blocking wrapper around the AES-CCM peripheral.
Implementations§
source§impl Ccm
impl Ccm
sourcepub fn init(regs: CCM, arr: AAR, data_rate: DataRate) -> Ccm
pub fn init(regs: CCM, arr: AAR, data_rate: DataRate) -> Ccm
Inits the CCM peripheral. This method also demands ownership of the AAR peripheral, because it shares registers with the CCM.
sourcepub fn encrypt_packet(
&mut self,
ccm_data: &mut CcmData,
clear_packet: &[u8],
cipher_packet: &mut [u8],
scratch: &mut [u8]
) -> Result<(), CcmError>
pub fn encrypt_packet( &mut self, ccm_data: &mut CcmData, clear_packet: &[u8], cipher_packet: &mut [u8], scratch: &mut [u8] ) -> Result<(), CcmError>
Encrypts a packet and generates a MIC.
The generated MIC will be placed after the payload in the cipher_packet
. The slices
passed to this method must have the correct size, for more information refer to the module
level documentation. The counter in ccm_data
will be incremented if the operation
succeeds. All parameters passed to this method must reside in RAM.
sourcepub fn decrypt_packet(
&mut self,
ccm_data: &mut CcmData,
clear_packet: &mut [u8],
cipher_packet: &[u8],
scratch: &mut [u8]
) -> Result<(), CcmError>
pub fn decrypt_packet( &mut self, ccm_data: &mut CcmData, clear_packet: &mut [u8], cipher_packet: &[u8], scratch: &mut [u8] ) -> Result<(), CcmError>
Decrypts a packet and checks its MIC.
This method will return an error if the MIC verification fails. The slices passed to this
method must have the correct size, for more information refer to the module level
documentation. The counter in ccm_data
will be incremented if the operation succeeds. All
parameters passed to this method must reside in RAM.