ECB mode encryption of N blocks of plaintext into N blocks of ciphertext without CPU interaction is achieved through the use of 2 DMA channels (referred to as DMA_A and DMA_B). To implement ECB encryption follow these steps:
- Configure Output DMA channel for saving ciphertext:
- Set DMA channel trigger selection to AES Trig1
- Set DMA channel source address to DATA_OUT
- Set DMA channel destination address to location where ciphertext is to be stored (for example, SRAM)
- Set DMA channel transfer size to N∗4
- Set DMA channel mode to single transfer mode
- In the AESADV event registers, unmask Trig1 in the IMASK register of DMA_TRIG1
- Configure Input DMA channel for loading plaintext:
- Set DMA channel trigger selection to AES Trig0
- Set DMA channel source address to location where plaintext is stored (for example, SRAM)
- Set DMA channel destination address to DATA_IN
- Set DMA channel transfer size to N∗4
- Set DMA channel mode to single transfer mode
- In the AES event registers, unmask Trig0 in the IMASK register of DMA_TRIG0
- Configure and enable the DMA interrupt for the Output DMA channel in the DMA controller
- Configure DMA_HS for DMA based handshake: set DMA_HS[DMA_DATA_ACK] = 1
- Configure the CTRL register for block cipher encryption mode for ECB:
- Set key size in CTRL[KEY_SIZ]
- Select Direction for Encryption by CTRL[DIR] = 1
- Select ECB mode by setting rest of the bits in CTRL to 0
- Load key as described in Section 11.2.1.
- Start encryption by writing the number of bytes N×4 to AES C_LENGTH_0 and C_LENGTH_1 registers
- Wait for the DMA channel interrupt which indicates completion of the entire operation. The ciphertext output will be stored in the location configured in step 1c.