AES hardware accelerator (AES)
In ECB decrypt mode, the 128-bit ciphertext input data block C1 in the AES_DINR register
first goes through bit/byte/half-word swapping. The keying sequence is reversed compared
to that of the ECB encryption. The swap result I1 is processed with the AES core set in
decrypt mode, using the formerly prepared decryption key. The decryption result goes
through bit/byte/half-word swapping, then is stored in the AES_DOUTR register as 128-bit
plaintext output data block P1. The ECB decryption continues in this way until the last
complete ciphertext block is decrypted.
Figure 512
Legend
input
output
XOR
In CBC encrypt mode, the first plaintext input block, after bit/byte/half-word swapping (P1'),
is XOR-ed with a 128-bit IVI bitfield (initialization vector and counter), producing the I1 input
data for encrypt with the AES core, using a 128- or 256-bit key. The resulting 128-bit output
block O1, after swapping operation, is used as ciphertext C1. The O1 data is then XOR-ed
with the second-block plaintext data P2' to produce the I2 input data for the AES core to
produce the second block of ciphertext data. The chaining of data blocks continues in this
way until the last plaintext block in the message is encrypted.
If the message size is not a multiple of 128 bits, the final partial data block is encrypted in
the way explained in
Figure 513
Legend
input
output
XOR
1502/2126
illustrates the cipher block chaining (CBC) encryption.
Figure 512. CBC encryption
AES_DINR (plaintext P1)
DATATYPE[1:0]
management
AES_IVRx (init. vector)
IVI
AES_KEYRx (KEY)
DATATYPE[1:0]
management
AES_DOUTR (ciphertext C1)
Section 34.4.6: AES ciphertext stealing and data
illustrates the cipher block chaining (CBC) decryption.
Figure 513. CBC decryption
AES_DINR (ciphertext C1)
DATATYPE[1:0]
management
AES_KEYRx (KEY)
AES_IVRx (IV)
IVI
DATATYPE[1:0]
management
AES_DOUTR (plaintext P1)
RM0440 Rev 4
Block 1
Swap
P1'
I1
AES_KEYRx (KEY)
Block cipher
encryption
O1
Swap
Block 1
Swap
I1
AES_KEYRx (KEY)
Decrypt
O1
P1'
Swap
Block 2
AES_DINR (plaintext P2)
Swap
DATATYPE[1:0]
management
Block cipher
encryption
Swap
DATATYPE[1:0]
management
AES_DOUTR (ciphertext C2)
padding.
Block 2
AES_DINR (ciphertext C2)
Swap
DATATYPE[1:0]
management
Decrypt
Swap
DATATYPE[1:0]
management
AES_DOUTR (plaintext P2)
RM0440
P2'
I2
O2
MSv19107V2
I2
O2
P2'
MSv19104V2
Need help?
Do you have a question about the STM32G4 Series and is the answer not in the manual?
Questions and answers