GD32W51x User Manual
934
AES-CBC mode encryption
The input data of the AEA block in CBC mode consists of two aspects: the input plaintext after
data swapping according to the data type, and the initialization vectors. The XOR result of the
swapped plaintext data block and the 128-bit initialization vector CAU_IV0..1 is read in the
AEA and encrypted using the 128-, 192-, 256-bit key. The result is then used as the next
initialization vector and exclusive-ORed with the next plaintext data block to process next
encryption. The above operations are repeated until the last plaintext block is encrypted. Note
if the plaintext message does not consist of an integral number of data blocks, the final partial
data block should be encrypted in a specified manner. At last, the output ciphertext is also
obtained after data swapping according to the data type. The procedure of AES CBC mode
encryption is illustrated in
Figure 27-10. AES CBC encryption
.
Figure 27-10. AES CBC encryption
SWAP
CAU_DI
DATAM
AEA, encrypt
CAU_KEY0..3
SWAP
CAU_DO
Plaintext
Ciphertext
+
CAU_IV0..1(H/L)
AES-CBC mode decryption
Similar to that in AES-ECB mode decryption, the key derivation also must be completed first
to prepare the decryption keys, the input of the key schedule should be the same to that used
in encryption. The last round key obtained from the above operation is then used as the first
round key in the decryption. After the key derivation, the 128-bit input ciphertext is first
obtained after data swapping according to the data type. The input data block is read in the
AEA and decrypted using keys prepared above. At the same time, the first ciphertext is then
used as the next initialization vector and exclusive-ORed with the next result after AEA blocks
(The first initialization is obtained directly from the CAU_IV0..1 registers). The above
operations are repeated until the last ciphertext block is decrypted. Note if the ciphertext
message does not consist of an integral number of data blocks, the final partial data block
should be decrypted in a specified manner same to that in encryption. At last, the output