GD32F20x User Manual
204
Decryption
1. Disable the CAU by resetting the CAUEN bit in the CAU_CTL register
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 bits to “111” 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) by
writing the ALGM 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.
10.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.
Summary of Contents for GD32F20 Series
Page 191: ...GD32F20x User Manual 191 Bits Fields Descriptions 31 0 TRNDATA 31 0 32 Bit Random data ...
Page 290: ...GD32F20x User Manual 290 conversion is ongoing ...
Page 325: ...GD32F20x User Manual 325 15 0 ALRM 15 0 RTC alarm value low ...
Page 385: ...GD32F20x User Manual 385 ...
Page 523: ...GD32F20x User Manual 523 clears AERR bit by writing 0 to it ...