
GD32L23x User Manual
575
Decryption
1. Disable the CAU by resetting the CAUEN bit in the CAU_CTL register.
2. Enable CAU power domain by setting the CORE1WAKE bit in the PMU_CTL1 register,
and then enable CAU clock.
3. Select and configure the key length with the KEYM bits in the CAU_CTL register if AES
algorithm is chosen.
4. Configure the CAU_KEY0..3(H/L) registers according to the algorithm.
5. Configure the DATAM bit in the CAU_CTL register to select the data swapping type.
6.
Configure the ALGM[3:0] bits to “0111” in the CAU_CTL register to complete the key
derivation.
7. Enable the CAU by set the CAUEN bit as 1.
8. Wait until the BUSY and CAUEN bit return to 0 to make sure that the decryption keys are
prepared.
9. 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.
10. Configure the decryption direction by writing 1 to the CAUDIR bit in the CAU_CTL register.
11. Configure the initialization vectors by writing the CAU_IV0..1 registers.
12. Flush the input FIFO and output FIFO by configure the FFLUSH bit in the CAU_CTL
register when CAUEN is 0.
13. Enable the CAU by set the CAUEN bit as 1 in the CAU_CTL register.
14. 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.
15. 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.
16. Repeat steps 13, 14 until all data blocks has been decrypted.
Data append
For GCM payload encryption or CCM payload decryption, CAU supports non 128 bit integer
multiple data block processing. When the last data block is less than 128bit, use
‘0’ to fill the
remaining bits, and then configure the number of bytes to be filled in the NBPILB bitfield of
the CAU_CTL register. AES will automatically remove the the number of filled pads and
encrypt it. It should be noted that the NBPILB[3:0] bitfield should be configured after the
encryption of the penultimate data block is completed.
23.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