GD32W51x User Manual
940
2. Select and configure the key length with the KEYM bits in the CAU_CTL register if AES
algorithm is chosen.
3. Configure the CAU_KEY0..3(H/L) registers according to the algorithm.
4. Configure the DATAM bit in the CAU_CTL register to select the data swapping type.
5.
Configure the ALGM[3:0] bits to “0111” in the CAU_CTL register to complete the key
derivation.
6. Enable the CAU by set the CAUEN bit as 1.
7. Wait until the BUSY and CAUEN bit return to 0 to make sure that the decryption keys are
prepared.
8. Configure
the
algorithm
(DES/TDES/AES)
and
the
chaining
mode
(ECB/CBC/CTR/GCM/GMAC/CCM/CFB/OFB) by writing the ALGM[3:0] bit in the
CAU_CTL register.
9. Configure the decryption direction by writing 1 to the CAUDIR bit in the CAU_CTL register.
10. Configure the initialization vectors by writing the CAU_IV0..1 registers.
11. Flush the input FIFO and output FIFO by configure the FFLUSH bit in the CAU_CTL
register when CAUEN is 0.
12. Enable the CAU by set the CAUEN bit as 1 in the CAU_CTL register.
13. If the INF bit in the CAU_STAT0 register is 1, then write data blocks into the CAU_DI
register. The data can be transferred by DMA/CPU during interrupts/no DMA or interrupts.
14. Wait for ONE bit in the CAU_STAT0 register is 1, then read the CAU_DO registers. The
output data can also be transferred by DMA/CPU during interrupts/no DMA or interrupts.
15. Repeat steps 13, 14 until all data blocks has been decrypted.
27.6.
CAU DMA interface
The DMA can be used to transfer data blocks with the interface of the cryptographic
acceleration unit. The operations can be controlled by the CAU_DMAEN register. DMAIEN is
used to enable the DMA request during the input phase, then a word is written into CAU_DI
from DMA. DMAOEN is used to enable the DMA request during the output phase, then a
word is read from the CAU.
Single and Burst transfers are both supported to ensure the data transfer if the number of
words is not an integral multiple of burst size. Note the DMA controller should be configured
to perform burst of 4 words or less to make sure no data will be lost. DMA channel for output
data has a higher priority than that channel for input data so that the output FIFO can be
empty earlier than that the input FIFO is full.
27.7.
CAU interrupts
There are two types of interrupt registers in CAU, which are CAU_STAT1 and CAU_INTF. In
CAU, the interrupt is used to indicate the situation of the input and output FIFO.
Any of input and output FIFO interrupt can be enabled or disabled by configuring the Interrupt