GD32W51x User Manual
936
Figure 27-13. AES CTR encryption/decryption
SWAP
CAU_DI
DATAM
AEA, encrypt/
decryp
CAU_KEY0..3
SWAP
CAU_DO
Plaintext/
Ciphertext
Ciphertext
/
Plaintext
+
CAU_IV0..1(H/L)
+1
AES-GCM mode
The AES Galois/counter mode (GCM) can be used to encrypt or authenticate message, then
ciphertext and tag can be obtained. This algorithm is based on AES CTR mode to ensure
confidentiality. A multiplier over a fixed finite field is used to generate the tag.
In this mode, four steps are required to perform an encryption/decryption:
1. GCM prepare phase
The hash key is calculated and saved internally to be used later.
(a) Clear the CAUEN bit to make sure CAU is disabled.
(b)
Configure the ALGM[3:0] bits to ‘1000’.
(c)
Configure GCM_CCMPH[1:0] bits to ‘00’.
(d) Configure key registers and initialization vectors.
(e) Enable CAU by writing 1 to CAUEN bit.
(f) Wait until CAUEN bit is cleared by hardware, and then enable CAU again for
following phases.
2. GCM AAD (additional authenticated data) phase
This phase must be performed after GCM prepare phase and also precede the
encryption/decryption phase. In this phase, data is authenticated but not protected.
(g)
Configure GCM_CCMPH[1:0] bits to ‘01’.
(h) Write data into CAU_DI register, INF and IEM flags can be used to determine if the
input FIFO can receive data. The size of the AAD must be a multiple of 128bits. DMA
can also be used.