Figure 510. Cbc Encryption; Figure 511. Cbc Decryption - ST STM32G4 Series Reference Manual

Advanced arm-based 32-bit mcus
Hide thumbs Also See for STM32G4 Series:
Table of Contents

Advertisement

AES hardware accelerator (AES)
Figure 510
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 511
Legend
input
output
XOR
In CBC decrypt mode, like in ECB decrypt mode, the secret key must be prepared to
perform an AES decryption.
After the key preparation process, the decryption goes as follows: the first 128-bit ciphertext
block (after the swap operation) is used directly as the AES core input block I1 for decrypt
operation, using the 128-bit or 256-bit key. Its output O1 is XOR-ed with the 128-bit IVI field
(that must be identical to that used during encryption) to produce the first plaintext block P1.
1458/2083
illustrates the cipher block chaining (CBC) encryption mode.

Figure 510. 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 33.4.6: AES ciphertext stealing and data
illustrates the cipher block chaining (CBC) decryption.

Figure 511. 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 1
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

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the STM32G4 Series and is the answer not in the manual?

Table of Contents

Save PDF