CBC-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 CBC encryption follow these steps:
- Configure the AESACTL0 register for block cipher encryption mode using CBC:
- Reset AES module to clear internal state memory (set SWRST in the AESACTL0 register)
- Set CMEN to enable block cipher mode
- Set CMx to CBC mode
- Set OPx to 0x0 (encryption mode)
- Load key as described in Section 23.2.2
- Load initialization vector (IV) into AESAXIN
- Loading to AESAXIN does not start any encryption
- The STATE must be reset (step 1a above) so that the IV is XORed with zeros when loaded
- Configure DMA_A channel for saving ciphertext:
- Set DMA channel trigger selection to AES0 trigger
- Set DMA channel source address to AESADOUT
- Set DMA channel destination address to location where ciphertext is to be stored (for example, SRAM)
- Set DMA channel transfer size to N∗4 words
- Set DMA channel mode to single transfer mode
- In the AES event registers, unmask DMA0 in the IMASK register of DMA_TRIG
0
- Configure DMA_B channel for loading plaintext:
- Set DMA channel trigger selection to AES1 trigger
- Set DMA channel source address to location where plaintext is stored (for example, SRAM)
- Set DMA channel destination address to AESAXDIN
- Set DMA channel transfer size to N∗4 words
- Set DMA channel mode to single transfer mode
- In the AES event registers, unmask DMA1 in the IMASK register of DMA_TRIG
1
- Configure and enable the DMA interrupt for the DMA_A channel in the DMA controller
- Start encryption by writing the block count N to BLKCNTx in the AESACTL1 register
- Wait for the DMA_A channel interrupt which indicates completion of the operation. The ciphertext output will be stored in the location configured in step 4c.