GD32W51x User Manual
938
1. CCM prepare phase
In this phase, B0 packet (the first packet) is programmed into the CAU_DI register.
CAU_DO never contain data in this phase.
(a) Clear the CAUEN bit to make sure CAU is disabled.
(b)
Configure the ALGM[3:0] bits to ‘1001’.
(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) Program the B0 packet into the CAU_DI.
(g) Wait until CAUEN is cleared by hardware, and then enable CAU again for following
phases.
2. CCM AAD (additional authenticated data) phase
This phase must be performed after CCM prepare phase and also precede the
encryption/decryption phase. In this phase, CAU_DO never contain data in this phase.
This phase can be by-passed if there is no additional authenticated data.
(h) Configure GCM_CCMPH[1:0]
bits to ‘01’
(i) 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 128 bits. DMA
can also be used.
(j) Repeat (i) until all AAD data are supplied, wait until BUSY bit is cleared
3. CCM encryption/decryption phase
This phase must be performed after CCM AAD phase. In this phase, the message is
authenticated and encrypted/decrypted.
Like GCM, the CCM chaining mode can be applied on a message composed only by
plaintext authenticated data (that is, only AAD, no payload). Note that this way of using
CCM is not called CMAC (it is not similar to GCM/GMAC).
(k)
Configure GCM_CCMPH[1:0] bits to ‘10’
(l) Configure the computation direction in CAUDIR
(m) Write data into CAU_DI register, INF and IEM flags can be used to determine if the
input FIFO can receive data. ONE and OFU flags can be used to check if the output
FIFO is not empty. If so, read the CAU_DO register. DMA can also be used.
(n) Repeat (m) step until all payload blocks are processed.
4. CCM tag phase
In this phase, the final authentication tag is generated.
(o)
Configure GCM_CCMPH[1:0] bits to ‘11’
(p) Write the 128 bit input into the CAU_DI register, 4 times of write operation to CAU_DI
is needed. The input is the A0 value.