Struct atsamd_hal::aes::Aes
source · [−]pub struct Aes { /* private fields */ }
Expand description
AES Peripheral
Encapsulates the PAC which acts as a token and provides an interface to the AES hardware
Implementations
sourceimpl Aes
impl Aes
sourcepub fn new(aes: AES) -> Self
pub fn new(aes: AES) -> Self
Create the interface for the AES peripheral
Don’t forget to enable the APB
bus for AES
AHB
bus is on by default at reset
Clock::v1
mclk.apbcmask.modify(|_, w| w.aes_().set_bit());
Clock::v2
tokens.apbs.aes.enable();
sourcepub fn set_aesmode(self, mode: AESMODE_A)
pub fn set_aesmode(self, mode: AESMODE_A)
Set AES Mode
sourcepub fn set_keysize(self, keysize: KEYSIZE_A)
pub fn set_keysize(self, keysize: KEYSIZE_A)
Set Encryption Key Size
sourcepub fn set_cipher(self, mode: CIPHER_A)
pub fn set_cipher(self, mode: CIPHER_A)
Set Cipher Mode
sourcepub fn set_startmode(self, mode: STARTMODE_A)
pub fn set_startmode(self, mode: STARTMODE_A)
Set Start Mode
sourcepub fn set_keygen(self, keygen_start: bool)
pub fn set_keygen(self, keygen_start: bool)
Start Last Key Generation
Compute last NK words of expanded key
sourcepub fn set_xorkey(self, mode: XORKEY_A)
pub fn set_xorkey(self, mode: XORKEY_A)
XOR Key Generation
The user keyword gets XORed with the previous keyword register content
sourcepub fn newmsg(&self)
pub fn newmsg(&self)
New Message Used in cipher block chaining (CBC), cipher feedback (CFB) and output feedback (OFB), counter (CTR) modes to indicate that the hardware should use Initialization Vector for encrypting the first block of a message.
sourcepub fn eom(&self)
pub fn eom(&self)
End of Message (GCM mode only)
This triggers generation of final GHASH
value for the message
sourcepub fn gfmul(&self)
pub fn gfmul(&self)
GF Multiplication (GCM mode only)
This triggers GF multiplication of data buffer content and hashkey register content.
sourcepub fn disable_enccmp(&self)
pub fn disable_enccmp(&self)
Disable Encryption Complete Interrupt
sourcepub fn disable_gfmcmp(&self)
pub fn disable_gfmcmp(&self)
Disable GF Multiplication Complete Interrupt
sourcepub fn enable_enccmp(&self)
pub fn enable_enccmp(&self)
Enable Encryption Complete Interrupt
sourcepub fn enable_gfmcmp(&self)
pub fn enable_gfmcmp(&self)
Enable GF Multiplication Complete Interrupt
sourcepub fn clear_enccmp(&self)
pub fn clear_enccmp(&self)
Clear Encryption Complete Interrupt
Also automatically cleared if
- Manual encryption/decryption occurs (via CTRLB.START)
- Reading from GHASHx register
sourcepub fn clear_gfmcmp(&self)
pub fn clear_gfmcmp(&self)
Clear GF Multiplication Complete Interrupt
Also automatically cleared if
- Manual encryption/decryption occurs (via CTRLB.START)
- Reading from data register
INDATAx
whenLOD = 0
- Writing into the data register
INDATAx
whenLOD = 1
- Reading from Hash Key register (
HASHKEYx
)
sourcepub fn read_enccmp(&self) -> bool
pub fn read_enccmp(&self) -> bool
Read Encryption Complete Interrupt
sourcepub fn read_gfmcmp(&self) -> bool
pub fn read_gfmcmp(&self) -> bool
Read GF Multiplication Complete Interrupt
sourcepub fn set_databufptr(&self, dataptr: u8)
pub fn set_databufptr(&self, dataptr: u8)
Set the Data Buffer Pointer
sourcepub fn set_debug(&self, run_during_debug: bool)
pub fn set_debug(&self, run_during_debug: bool)
Control if AES is active during debugging
Enable protected, only possible to change when AES is disabled
sourcepub fn set_keyword<const N: usize>(&self, keyword: &[u8; N])
pub fn set_keyword<const N: usize>(&self, keyword: &[u8; N])
Set keyword / cryptographic key
Consists of four/six/eight Key Word registers for setting the cryptographic key
sourcepub fn set_initialization_vector(&self, iv: [u32; 4])
pub fn set_initialization_vector(&self, iv: [u32; 4])
Set initialization vector
The four 32-bit Initialization Vector registers INTVECTVn set the 128-bit Initialization Vector data block that is used by some modes of operation as an additional initial input. INTVECTV0.INTVECTV corresponds to the first word of the Initialization Vector, INTVECTV3.INTVECTV to the last one.
These registers are write-only to prevent the Initialization Vector from being read by another application. For CBC, OFB, and CFB modes, the Initialization Vector corresponds to the initialization vector. For CTR mode, it corresponds to the counter value.
sourcepub fn set_hashkey(&self, hashkey: [u32; 4])
pub fn set_hashkey(&self, hashkey: [u32; 4])
Set GCM hash key value (GCM mode only)
pub fn get_hashkey(&self) -> [u32; 4]
sourcepub fn set_ghash(&self, ghash: [u32; 4])
pub fn set_ghash(&self, ghash: [u32; 4])
Set Galois Hash value (GCM mode only)
Writing a new key to keyword clears GHASH
sourcepub fn set_ciplen(&self, ciplen: u32)
pub fn set_ciplen(&self, ciplen: u32)
Set cipher length (GCM mode only)
sourcepub fn get_ciplen(&self) -> u32
pub fn get_ciplen(&self) -> u32
Read Cipher Length (GCM mode only)
sourcepub fn set_randseed(&self, seed: u32)
pub fn set_randseed(&self, seed: u32)
Set a new seed for the AES random number generator