AES workflow

Workflow
Mode 1: Encryption
⚫ Reset EN Reset AES module
⚫ Set mode register mode[1:0]=00, set stream data processing mode register CHMOD[1:0]
⚫ Write AES_KEYRx register, write AES_IVRx in CTR and CBC mode Register
⚫ Write EN=1 to enable AES
⚫ Write AES_DINR register 4 times
⚫ Wait for the CCF flag to be set
⚫ Read the encrypted result from AES_DOUTR 4 times
⚫ For the same key, repeat steps 5, 6, 7 for the next 128bit block encrypt

Mode 2: Key extension
⚫ Reset EN Reset AES module
⚫ Set mode register mode[1:0]=01, the value of CHMOD[1:0] register is not concerned.
⚫ Write AES_KEYRx register.
⚫ Write EN=1 to enable AES
⚫ Wait for the CCF flag to be set
⚫ Clear the CCF flag, and the expanded key will be automatically written back to the AES_KEYRx register. The AES_KEYRx register can be read to get the result if needed. To recalculate the extended key, repeat steps 3, 4, 5, and 6.

Mode 3: decrypt
⚫ reset EN reset AES module
⚫ set mode register mode[1:0]=10, set stream data processing mode register CHMOD[1:0]
⚫ write AES_KEYRx register (if it has been extended by mode 2 calculation Key can skip this step), write AES_IVRx register in CTR and CBC mode.
⚫ Write EN=1 to enable AES
⚫ Write AES_DINR register 4 times
⚫ Wait for the CCF flag to be set
⚫ Read the decryption result from AES_DOUTR in 4 times
⚫ For the same key, repeat steps 5, 6, 7 for the next 128bit block decrypt

9.5.4 Mode 4: Key expansion + decryption
⚫ Reset EN Reset AES module
⚫ Set mode register mode[1:0]=11, set stream data processing mode register CHMOD[1:0]. This mode is disabled in CTR mode. If you set mode[1:0]=11 and CHMOD[1:0]=10, it will force to enter the CTR decryption mode.
⚫ Write AES_KEYRx register, write AES_IVRx register in CBC mode.
⚫ Write EN=1 to enable AES
⚫ Write AES_DINR register 4 times
⚫ Wait for the CCF flag to be set
⚫ Read the decryption result from AES_DOUTR in 4 times
⚫ For the same key, repeat steps 5, 6, 7 for the next 128bit block Decryption Note: In this mode, the AES_KEYRx register is always stored in the encryption key, and the extended key will be recalculated internally every time and will not be stored in the AES_KEYRx register.

Guess you like

Origin blog.csdn.net/qq_43359615/article/details/130436588