CFB mode decryption of N blocks of ciphertext into N blocks of ciphertext without CPU interaction is achieved through the use of 3 DMA channels (referred to as DMA_A, DMA_B, and DMA_C). To implement CFB decryption follow these steps:
- Configure the AESACTL0 register for block cipher decryption mode using OFB:
- Reset the AES module to clear the internal state memory (set SWRST in the AESCTL0 register)
- Set the CMEN to enable block cipher mode
- Set CMx to CFB mode (0x3)
- Set OPx to decryption mode (0x1)
- Load key as described in Section 23.2.2
- Load initialization vector IV into AESAXIN
- Loading to AESAXIN does not start any decryption
- The STATE must be reset (step 1a above) so that the IV is XORed with zeros when loaded
- Configure the DMA_A channel for loading ciphertext:
- Set the DMA channel trigger selection to AES0 trigger
- Set the DMA channel source address to the location where ciphertext is stored (for example, SRAM)
- Set the DMA channel destination address to AESAXIN
- Set the DMA channel transfer size to N∗4 words
- Set the DMA channel mode to single transfer mode
- Configure the DMA_B channel for reading plaintext:
- Set the DMA channel trigger selection for AES1 trigger
- Set the DMA channel source address to AESADOUT
- Set the DMA channel destination address to the location where plaintext is to be stored (for example, SRAM)
- Set the DMA channel transfer size to N∗4 words
- Set the DMA channel mode to single transfer mode
- In the AES event registers, unmask DMA1 in the IMASK register of DMA_TRIG
1
- Configure the DMA_C channel for loading ciphertext:
- Set the DMA channel trigger selection for AES2 trigger
- Set the DMA channel source address to the location where ciphertext is stored (for example, SRAM)
- Set the DMA channel destination address to AESADIN
- Set the DMA channel transfer size to N∗4 words
- Set the DMA channel mode to single transfer mode
- Configure and enable the DMA interrupt for the DMA_B channel in the DMA controller
- Start decryption by writing the block count N to BLKCNTx in the AESACTL1 register and setting the DINWR bit in the AESASTAT register
- Wait for the DMA_B channel interrupt which indicates completion of the operation. The plaintext output will be stored in the location configured in step 5c.