48. Cryptographic processor (SAES)
48.1 SAES introduction
The cryptographic processor (SAES) encrypts or decrypts data in compliance with the advanced encryption standard (AES) defined by NIST. It incorporates a protection against side-channel attacks (SCA), including differential power analysis (DPA), certified SESIP, and PSA security assurance level 3.
SAES supports ECB, CBC, CTR, GCM, GMAC, and CCM chaining modes for key sizes of 128, 192, or 256 bits.
The key wrap feature is also available, decrypting AES keys to use in SAES or in the faster CRYP1 or CRYP2 peripheral.
SAES can load, by hardware, STM32 hardware secret keys (boot hardware key BHK, and derived hardware unique key DHUK), usable but not readable by the application.
SAES supports DMA single transfers for incoming and outgoing data (two DMA channels are required).
SAES is hardware-linked with the true random number generator (TRNG) and with the CRYP1 and CRYP2 peripherals.
48.2 SAES main features
- • Compliance with NIST “Advanced encryption standard (AES), FIPS publication 197” from November 2001
- • Multiple AES symmetric key block cipher operating modes:
- – Electronic codebook (ECB) mode
- – Cipher block chaining (CBC) mode
- – Counter (CTR) mode
- – Galois counter mode (GCM)
- – Galois message authentication code (GMAC) mode
- – Counter with CBC-MAC (CCM) mode
- • Protection against side-channel attacks (SCA), including differential power analysis (DPA), certified SESIP and PSA security assurance level 3
- • 16-byte data block processing, supporting cipher key lengths of 128, 192 and 256 bits
- – 82 or 102 clock cycle latency in ECB mode for processing one 128-bit block with, respectively, 128-bit or 256-bit key
- • Hardware secret key encryption/ decryption (wrapped-key mode)
- • Using dedicated key bus; under SAES control, optional key sharing with the faster CRYP1 or CRYP2 peripheral
- • Integrated key scheduler to compute the last round key for ECB/CBC decryption
- • Eight 32-bit write-only registers (256 bits of information) for storing cryptographic keys
- • Optional hardware loading of hardware secret keys DHUK, BHK or their XOR combination
- • Security context enforcement for keys
- • Four 32-bit registers for storing initialization vectors
- • 32-bit buffer for data input and output
- • Automatic data flow control supporting two direct memory access (DMA) channels, one for incoming data, one for processed data. Only single transfers are supported.
- • Data-swapping logic to support 1-, 8-, 16-, or 32-bit data
- • AMBA AHB target peripheral, accessible only via 32-bit single-word write accesses (other write accesses generate bus errors and are ignored); no restrictions on reads
- • Ability to suspend a message by software (in CPU mode) and later resume it, except in GCM/GMAC modes. This allows SAES to process a higher-priority message.
48.3 SAES implementation
The devices have one SAES peripheral, implemented as per the following table. For comparison, the SAES key share target CRYP1 and CRYP2 peripherals are also presented.
Table 438. CRYP1 versus SAES features
| Modes or features(1) | CRYP1 and CRYP2 | SAES |
|---|---|---|
| ECB, CBC chaining | X | X |
| CTR, CCM, and GCM chaining | X | X |
| AES 128-bit ECB encryption latency in cycles | 14 | 82 |
| DHUK, BHK or their XOR combination hardware secret key selection | - | X |
| Resistance to side-channel attacks | - | X |
| Shared key between SAES and CRYP1 or CRYP2 | X | X |
| Key sizes in bits | 128, 192, 256 | 128, 192, 256 |
1. X = supported.
Figure 398. SAES usage in the device

graph TD; BackupRegisters[Backup registers] -- BHK --> SAES["SAES(1)
DHUK"]; TRNG[TRNG] -.-> SAES; NVM[NVM] -- RHUK --> SAES; SAES -- "wrapid=0x2(2)" --> CryptoPeripheral1["Crypto peripheral 1(3)"]; SAES -- "wrapid=0x1(2)" --> CryptoPeripheral2["Crypto peripheral 2(3)"];
MSv72616V2
1. Protected against side-channel attack.
2. Configuration bits when WRAPEN is set.
3. Refer to Table 438 for information on instances of crypto peripherals on the device and their names.
48.4 SAES functional description
48.4.1 SAES block diagram
Figure 399 shows the SAES block diagram.
Figure 399. SAES block diagram

- 1. AES represents the CRYP1 or CRYP2 peripheral.
48.4.2 SAES internal signals
Table 439 describes the user relevant internal signals interfacing the SAES peripheral.
Table 439. SAES internal input/output signals
| Signal name | Signal type | Description |
|---|---|---|
| saes_hclk | Input | AHB bus clock |
| saes_it | Output | SAES interrupt request |
| saes_in_dma | Input/Output | SAES incoming data DMA single request/acknowledge |
| saes_out_dma | Input/Output | SAES processed data DMA single request/acknowledge |
| saes_itamp_out | Output | Tamper event signal to TAMP (XOR-ed), triggered when an unexpected hardware fault occurs. When this signal is triggered, SAES automatically clears key registers. A reset is required before SAES can be used again. |
| Signal name | Signal type | Description |
|---|---|---|
| RHUK | Input | Root hardware unique key (256-bit, nonvolatile, unique per device and secret to software), used to internally compute the derived hardware unique key (DHUK) |
| BHK(1) | Input | Boot hardware 256-bit key (BHK) stored in tamper-resistant backup registers and written during boot. Once written, this key cannot be read nor written by any application until the next product reset. |
- 1. Connected to a set of backup registers in the TAMP peripheral that are written, then read/write locked, by the application software (see Section 48.4.17 for details).
48.4.3 SAES reset and clocks
The SAES peripheral is clocked by the AHB bus clock. It also has a dedicated kernel clock controlled through the RCC.
The SAES has a dedicated reset bit in the RCC.
48.4.4 SAES symmetric cipher implementation
The cryptographic processor (SAES) is a 32-bit AHB peripheral that encrypts or decrypts 16-byte blocks of data using the advanced encryption standard (AES). It also implements a set of approved AES symmetric key security functions summarized in Table 440. Those functions can be certified NIST PUB 140-3.
Table 440. SAES approved AES symmetric key functions| Operations | Algorithm | Specification | Key bit lengths | Chaining modes |
|---|---|---|---|---|
| Encryption, decryption | AES | FIPS PUB 197 NIST SP800-38A | 128, 192, 256 | ECB, CBC, CTR |
| Authenticated encryption or decryption | NIST SP800-38C NIST SP800-38D | GCM, CCM | ||
| Cipher-based message authentication code | NIST SP800-38D | GMAC |
SAES can be used directly by the CPU, or indirectly using two DMA channels (one for the plaintext, one for the ciphertext).
When the CPU is used, it is possible to suspend then resume any processing by SAES (except in GCM and GMAC operating modes), following the sequence described in Section 48.4.8.
48.4.5 SAES encryption or decryption typical usage
The following figure shows a typical operation for encryption or decryption.
Figure 400. Encryption/ decryption typical usage

graph TD
Start([Start]) --> Init([Initialization])
Init --> Decryption{ECB or CBC decryption?}
Decryption -- Yes --> RKP([Round key preparation])
Decryption -- No --> DA([Data append])
RKP --> DA
DA --> LastBlock{Last block?}
LastBlock -- No --> DA
LastBlock -- Yes --> Valid{All bytes valid?}
Valid -- Yes --> Finalize([Finalize])
Valid -- No --> Chaining{ECB or CBC chaining?}
Chaining -- No --> DP([Data padding])
Chaining -- Yes --> DS([Data stealing])
DP --> Finalize
DS --> Finalize
Finalize --> End([End])
MSv66120V1
Initialization
The SAES peripheral is initialized according to the operating (chaining) mode. Refer to the sections describing the operating modes.
Data append
This section describes different ways of appending data for processing. For ECB or CBC chaining modes, refer to Section 48.4.7: SAES ciphertext stealing and data padding if the size of data to process is not a multiple of 16 bytes. The last block management in these cases is more complex than what is described in this section.
General conditions for data processing
For information on how to suspend a message processing to process a higher priority message, refer to Section 48.4.8: SAES suspend and resume operations.
Appending data via CPU polling
This method uses the CCF flag polling to control data appending through the following sequence:
- 1. When KEYVALID is set, enable the SAES peripheral, by setting the EN bit of the SAES_CR register (if not already done).
- 2. Repeat the following subsequence until the payload is entirely processed:
- a) Write one block of data (four words) into the SAES_DINR register.
- b) Wait until the status flag CCF is set in the SAES_ISR register, then read one block of data (four words) from the SAES_DOUTR register.
- c) Clear the CCF flag, by setting the CCF bit of the SAES_ICR register.
- d) If the next processing block is the last block, pad (when applicable) the data with zeros to obtain a complete block, and specify the number of nonvalid bytes (using NPBLB[3:0]) in case of GCM payload encryption or CCM payload decryption (otherwise the tag computation is wrong).
- 3. As the data block just processed is the last block of the message, optionally discard the data that is not part of the message/payload, then disable the SAES peripheral by clearing EN.
Note: The NPBLB[3:0] bitfield is not used in a header phase of GCM, GMAC, and CCM chaining modes.
Appending data via CPU in interrupt mode
The method uses an interrupt from the SAES peripheral to control the data append, through the following sequence:
- 1. Enable interrupts from SAES, by setting the CCFIE bit of the SAES_IER register.
- 2. When KEYVALID is set, enable the SAES peripheral, by setting EN (if not already done).
- 3. Write the first four input data words into the SAES_DINR register.
- 4. Handle the data in the SAES interrupt service routine. Upon each interrupt:
- a) Read four output data words from the SAES_DOUTR register.
- b) Clear the CCF flag and thus the pending interrupt, by setting the CCF bit of the SAES_ICR register.
- c) If the next processing block is the last block of the message, pad (when applicable) the data with zeros to obtain a complete block, and specify the number of non-valid bytes (through NPBLB[3:0]) in case of GCM payload encryption or CCM payload decryption (otherwise the tag computation is wrong). Then proceed with point 4e).
- d) If the data block just processed is the last block of the message, optionally discard the data that are not part of the message/payload, then disable the SAES peripheral by clearing EN and quit the interrupt service routine.
- e) Write the next four input data words into the SAES_DINR register and quit the interrupt service routine.
SAES tolerates delays between consecutive read or write operations, allowing, for example, the system to serve an interrupt from another peripheral between two SAES computations.
Note: The NPBLB[3:0] bitfield is not used during the header phase of the GCM, GMAC, and CCM chaining modes.
Appending data via DMA
With this method, all the transfers and processing are managed by DMA and SAES. Proceed as follows:
- 1. If the last block of the message to process is shorter than 16 bytes, prepare the last four-word data block by padding the remainder of the block with zeros.
- 2. Configure the DMA controller so as to transfer the data to process from the memory to the SAES peripheral input and the processed data from the SAES peripheral output to the memory, as described in Section 48.6: SAES DMA requests. Configure the DMA controller so as to generate an interrupt on transfer completion. For GCM payload encryption or CCM payload decryption, the DMA transfer must not include the last four-word block if padded with zeros. The sequence described in Appending data via
- CPU polling must be used instead for this last block, because the NPBLB[3:0] bitfield must be set up before processing the block, for SAES to compute a correct tag.
- When KEYVALID is set, enable the SAES peripheral, by setting EN (if not already done).
- Enable DMA requests, by setting DMAINEN and DMAOUTEN.
- Upon DMA interrupt indicating the outgoing transfer completion, get the SAES-processed data from the memory.
When this method is used, suspend/resume operations are not supported (see Section 48.4.8).
The CCF flag has no use with this method because the reading of the SAES_DOUTR register is managed by DMA automatically, without any software action, at the end of the computation phase.
The NPBLB[3:0] bitfield is not used in the header phase of GCM, GMAC, and CCM chaining modes.
Aborting data appending process
To abort the process of appending data, set then clear the IPRST bit of the SAES_CR register.
48.4.6 SAES authenticated encryption, decryption, and cipher-based message authentication
The following figure shows a typical operation for authenticated encryption or decryption, and for cipher-based message authentication.
Figure 401. Typical operation with authentication

graph TD
Start([Start]) --> Init([Initialization])
Init --> HeaderInit([Header phase init])
HeaderInit --> HeaderAppend([Header data append])
HeaderAppend --> LastBlock1{Last block?}
LastBlock1 -- No --> HeaderAppend
LastBlock1 -- Yes --> AllValid1{All bytes valid?}
AllValid1 -- No --> DataPadding1([Data padding])
AllValid1 -- Yes --> CipherAuth{cipher-based* authentication?}
CipherAuth -- No --> PayloadInit([Payload phase init])
CipherAuth -- Yes --> Finalization([Finalization])
DataPadding1 --> Finalization
PayloadInit --> PayloadAppend([Payload data append])
PayloadAppend --> LastBlock2{Last block?}
LastBlock2 -- No --> PayloadAppend
LastBlock2 -- Yes --> AllValid2{All bytes valid?}
AllValid2 -- No --> DataPadding2([Data padding])
AllValid2 -- Yes --> Finalization
DataPadding2 --> Finalization
Finalization --> End([End])
MSv66121V1
Section 48.4.11: SAES Galois/counter mode (GCM) and Section 48.4.13: SAES counter with CBC-MAC (CCM) describe detailed sequences supported by SAES.
Cipher-based message authentication flow omits the payload phase, as shown in the above figure. The detailed sequence supported by SAES is described in Section 48.4.12: SAES Galois message authentication code (GMAC).
48.4.7 SAES ciphertext stealing and data padding
When using SAES in ECB or CBC modes to manage messages the size of which is not a multiple of the block size (16 bytes), the application must use ciphertext stealing techniques such as those described in NIST Special Publication 800-38A, Recommendation for Block Cipher Modes of Operation: Three Variants of Ciphertext Stealing for CBC Mode. Since SAES does not implement such techniques, the application must complete the last block of input data using data from the second last block.
Note: Ciphertext stealing techniques are not documented in this reference manual.
For modes other than ECB or CBC, since SAES does not implement an automatic data padding operation for the last block, the application must follow the recommendation provided in Section 48.4.5 to manage messages whose sizes are not multiples of 16 bytes.
48.4.8 SAES suspend and resume operations
A message can be suspended to process another message with a higher priority. When the higher-priority message is sent, the suspended message can resume. This applies to both encryption and decryption mode.
Suspend and resume operations do not break the chaining operation. The message processing can resume as soon as SAES is enabled again, to receive a next data block.
Note: Suspend and resume operations are only supported when SAES is used in CPU mode.
Figure 402 gives an example of suspend and resume operations: Message 1 is suspended in order to send a shorter and higher-priority Message 2. It is recommended to set the IPRST bit of the SAES_CR register before transferring control of SAES to a potentially less secure application.
Figure 402. Example of suspend mode management

The diagram illustrates the suspend and resume process for SAES. It shows two parallel message processing paths: Message 1 and Message 2. Message 1 starts with 128-bit block 1, followed by 128-bit block 2, and then 128-bit block 3. At this point, a callout indicates 'New higher-priority message 2 to be processed'. The flow then moves to an 'AES suspend sequence' block. After the suspend sequence, the flow returns to Message 1, starting with 128-bit block 4, followed by 128-bit block 5, and 128-bit block 6, with an ellipsis indicating further blocks. Message 2 consists of 128-bit block 1 and 128-bit block 2. The flow for Message 2 starts after the 'AES suspend sequence' block, proceeds through its blocks, and then passes through an 'AES resume sequence' block before returning to the main Message 1 flow at 128-bit block 4. The diagram is labeled MSv42148V1 in the bottom right corner.
A detailed description of suspend and resume operations is provided in the sections dedicated to each chaining mode.
48.4.9 SAES basic chaining modes (ECB, CBC)
ECB is the simplest mode of operation. There are no chaining operations, and no special initialization stage. The message is divided into blocks and each block is encrypted or decrypted separately. When decrypting in ECB, a special key scheduling is required before processing the first block.
Figure 403 and Figure 404 describe the electronic codebook (ECB) chaining implementation in encryption and in decryption, respectively. To select ECB chaining mode, write CHMOD[3:0] with 0x0.
Figure 403. ECB encryption

The diagram illustrates the ECB encryption process for two blocks.
Block 1: DIN (plaintext P1) is an 8-bit input. DATATYPE[1:0] and KEY (8-bit) are inputs to the Swap management block, which outputs I1. I1 and KEY are inputs to the Encrypt block, which outputs O1. O1 and DATATYPE[1:0] are inputs to the Swap management block, which outputs DOUT (ciphertext C1).
Block 2: DIN (plaintext P2) is an 8-bit input. DATATYPE[1:0] and KEY (8-bit) are inputs to the Swap management block, which outputs I2. I2 and KEY are inputs to the Encrypt block, which outputs O2. O2 and DATATYPE[1:0] are inputs to the Swap management block, which outputs DOUT (ciphertext C2).
Legend: White box = input, grey box = output.
Reference: MSv69563V1
Figure 404. ECB decryption

The diagram illustrates the ECB decryption process for two blocks.
Block 1: DIN (ciphertext C1) is an 8-bit input. DATATYPE[1:0] and KEY (8-bit) are inputs to the Swap management block, which outputs I1. I1 and KEY are inputs to the Decrypt block, which outputs O1. O1 and DATATYPE[1:0] are inputs to the Swap management block, which outputs DOUT (plaintext P1).
Block 2: DIN (ciphertext C2) is an 8-bit input. DATATYPE[1:0] and KEY (8-bit) are inputs to the Swap management block, which outputs I2. I2 and KEY are inputs to the Decrypt block, which outputs O2. O2 and DATATYPE[1:0] are inputs to the Swap management block, which outputs DOUT (plaintext P2).
Legend: White box = input, grey box = output.
Reference: MSv69564V1
In CBC encryption mode the output of each block chains with the input of the following block. To make each message unique, an initialization vector is used during the first block processing. When decrypting in CBC, a special key scheduling is required before processing the first block.
Figure 405 and Figure 406 describe the cipher block chaining (CBC) implementation in encryption and in decryption, respectively. To select this chaining mode, write CHMOD[3:0] with 0x1.
Figure 405. CBC encryption

Block 1
DIN (plaintext P1)
DATATYPE[1:0] → Swap management
init. vector → IVI
KEY → Block cipher encryption
O1 → Swap management
DOUT (ciphertext C1)
Block 2
DIN (plaintext P2)
DATATYPE[1:0] → Swap management
KEY → Block cipher encryption
O2 → Swap management
DOUT (ciphertext C2)
Legend
- input
- output
- ⊕ XOR
MSv69565V1
Figure 406. CBC decryption

Block 1
DIN (ciphertext C1)
DATATYPE[1:0] → Swap management
KEY → Decrypt
Init.vector → IVI
O1 → Swap management
DOUT (plaintext P1)
Block 2
DIN (ciphertext C2)
DATATYPE[1:0] → Swap management
KEY → Decrypt
O2 → Swap management
DOUT (plaintext P2)
Legend
- input
- output
- ⊕ XOR
MSv69566V1
For more details, refer to NIST Special Publication 800-38A, Recommendation for Block Cipher Modes of Operation.
ECB and CBC encryption process
This process is described in Section 48.4.5, with the following sequence of events:
- 1. Disable the SAES peripheral, by clearing EN.
- 2. Wait until BUSY is cleared (indicating no RNG random number fetch in progress).
- 3. Initialize the SAES_CR register as follows:
- a) Select ECB or CBC chaining mode (write CHMOD[3:0] with 0x0 or 0x1) in encryption mode (write MODE[1:0] with 0x0).
- b) Configure the data type, through DATATYPE[1:0].
- c) Configure the key size, through KEYSIZE[1:0]. Also set KEYPROT if the key is not shared with a different security context (different secure or Compartment ID attribute).
- d) Select the key source using KEYSEL[2:0] (see step 5.)
- e) Select normal key mode, by clearing WRAPEN. For wrapped key usage (with WRAPEN set) refer to Section 48.4.14.
- 4. Write the initialization vector into the SAES_IVRx registers if CBC mode is selected in the previous step.
- 5. Write the key into the SAES_KEYRx registers. Alternatively, manage the key source selected by KEYSEL[2:0] (see Section 48.4.17: SAES key registers for details).
- 6. Wait until KEYVALID is set (key loading complete).
- 7. Enable the SAES peripheral, by setting EN.
- 8. Append cleartext data:
- a) If it is the second-last or the last block and the plaintext size of the message is not a multiple of 16 bytes, follow the guidance in Section 48.4.7.
- b) Append the cleartext block into SAES as described in Section 48.4.5, then read the SAES_DOUTR register four times to save the ciphertext block.
- c) Repeat the step b) until the third-last plaintext block is encrypted. For the last two blocks, follow the steps a) and b).
- 9. Finalize the sequence: disable the SAES peripheral, by clearing EN.
ECB/CBC decryption process
This process is described in Section 48.4.5, with the following sequence of events:
- 1. Disable the SAES peripheral, by clearing EN.
- 2. Wait until BUSY is cleared (indicating no RNG random number fetch in progress).
- 3. Initialize the SAES_CR register as follows:
- a) Select the key derivation mode (write MODE[1:0] with 0x1). The CHMOD[3:0] bitfield is not significant during this operation.
- b) Configure the data type, through DATATYPE[1:0].
- c) Configure the key size, through KEYSIZE[1:0]. Also set KEYPROT if the key is not shared with a different security context (different secure or Compartment ID attribute).
- d) Select the key source using KEYSEL[2:0] (see step 4.)
- e) Select normal key mode, by clearing WRAPEN. For wrapped key usage (with WRAPEN set) refer to Section 48.4.14.
- 4. Write the key into the SAES_KEYRx registers. Alternatively, manage the key source selected by KEYSEL[2:0] (see Section 48.4.17: SAES key registers for details).
- 5. Wait until KEYVALID is set (key loading complete).
- 6. Enable the SAES peripheral, by setting EN. The peripheral immediately starts an AES round for key preparation.
- 7. Wait until the CCF flag of the SAES_ISR register is set.
- 8. Clear the CCF flag, by setting the CCF bit of the SAES_ICR register. The decryption key is available in the AES core and SAES is disabled automatically.
- 9. Select ECB or CBC chaining mode (write CHMOD[3:0] with 0x0 or 0x1) in decryption mode (write MODE[1:0] with 0x2). Do not change other parameters.
- 10. Write the initialization vector into the SAES_IVRx registers if CBC mode is selected in the previous step.
- 11. Enable the SAES peripheral, by setting EN.
- 12. Append encrypted data:
- a) If it is the second-last or the last block and the ciphertext size of the message is not a multiple of 16 bytes, follow the guidance in Section 48.4.7.
- b) Append the ciphertext block into SAES as described in Section 48.4.5, then read the SAES_DOUTR register four times to save the cleartext block.
- c) Repeat the step b) until the third-last ciphertext block is decrypted. For the last two blocks, follow the steps a) and b).
- 13. Finalize the sequence: disable the SAES peripheral by clearing EN. Use IPRST to clear the ECB or CBC encryption key modified by the key preparation process.
Suspend/resume operations in ECB/CBC modes
The following sequences are valid for normal key mode (WRAPEN = 0).
Note: Suspend and resume operations are only supported when SAES is used in CPU mode.
To suspend the processing of a message, proceed as follows:
- 1. Wait until the CCF flag of the SAES_ISR register is set (computation complete).
- 2. Read four times the SAES_DOUTR register to save the last processed block.
- 3. Clear the CCF flag, by setting the CCF bit of the SAES_ICR register.
- 4. Save initialization vector registers (only required in CBC mode as the SAES_IVRx registers are altered during the data processing).
- 5. Disable the SAES peripheral, by clearing EN.
- 6. Save the SAES_CR register and clear the key registers if they are not needed, to process the higher-priority message.
To resume the processing of a message, proceed as follows:
- 1. Disable the SAES peripheral, by clearing EN.
- 2. Restore the SAES_CR register (with correct KEYSIZE[1:0]) then restore the SAES_KEYRx registers. Alternatively, select a key source different from key registers, using KEYSEL[2:0]. Refer to Section 48.4.17: SAES key registers for details.
- 3. Prepare the decryption key, as described in ECB/CBC decryption process (only required for ECB or CBC decryption).
- 4. Restore the SAES_IVRx registers, using the saved configuration (only required in CBC mode).
- 5. Enable the SAES peripheral, by setting EN.
Note: It is not required to save the key registers as the application knows the original key.
48.4.10 SAES counter (CTR) mode
The CTR mode uses the AES core to generate a key stream. The keys are then XOR-ed with the plaintext to obtain the ciphertext. Unlike with ECB and CBC modes, no key scheduling is required for the CTR decryption since the AES core is always used in encryption mode.
A typical message construction in CTR mode is given in Figure 407.
Figure 407. Message construction in CTR mode

MSv42156V1
The structure of this message is:
- • A 16-byte initial counter block (ICB), composed of two distinct fields:
- – Initialization vector (IV): a 96-bit value that must be unique for each encryption cycle with a given key.
- – Counter: a 32-bit big-endian integer that is incremented each time a block processing is complete. The initial value of the counter is defined by the application.
- • The plaintext P is encrypted as ciphertext C, with a known length. This length can be nonmultiple of 16 bytes, in which case a plaintext padding is required.
For more details, refer to NIST Special Publication 800-38A, Recommendation for Block Cipher Modes of Operation.
CTR encryption and decryption
Figure 408 describes the counter (CTR) chaining implementation in the SAES peripheral (encryption). To select this chaining mode, write CHMOD[3:0] with 0x2.
Figure 408. CTR encryption

The diagram illustrates the CTR encryption process for two blocks. For each block, the IVI (Initialization Vector) is composed of a Nonce and a 32-bit counter. For Block 1, the IVI is 'Nonce + 32-bit counter', and for Block 2, it is 'Nonce + 32-bit counter (+1)'. The IVI is fed into an 'Encrypt' block along with a 'KEY'. The output of the 'Encrypt' block is XORed with the 'DIN (plaintext)' to produce the ciphertext 'DOUT'. The 'Swap management' block is used to swap the plaintext and ciphertext based on the 'DATATYPE[1:0]' signal. A 'Counter increment (+1)' block is used to increment the counter for the next block. The legend indicates that white boxes represent inputs, grey boxes represent outputs, and the circle with a plus sign represents an XOR operation.
Initialization vectors in SAES must be initialized as shown in Table 441.
Table 441. Counter mode initialization vector definition
| SAES_IVR3[31:0] | SAES_IVR2[31:0] | SAES_IVR1[31:0] | SAES_IVR0[31:0] |
|---|---|---|---|
| IVI[127:96] | IVI[95:64] | IVI[63:32] | IVI[31:0] 32-bit counter |
CTR encryption and decryption process
This process is described in Section 48.4.5, with the following sequence of events:
- 1. Disable the SAES peripheral, by clearing EN.
- 2. Wait until BUSY clears (indicating no RNG random number fetch in progress).
- 3. Initialize the SAES_CR register:
- a) Select CTR chaining mode (write CHMOD[3:0] with 0x2) in encryption or decryption mode (write MODE[1:0] with 0x0 or 0x2).
- b) Configure the data type, through DATATYPE[1:0].
- c) Configure the key size, through KEYSIZE[1:0]. Also set KEYPROT if the key is not shared with a different security context (different secure or Compartment ID attribute).
- d) Select the key source using KEYSEL[2:0] (see step 5.)
- e) Select normal key mode, by clearing WRAPEN. For wrapped key usage (with WRAPEN set) refer to Section 48.4.14.
- 4. Write the initialization vector in SAES_IVRx registers according to Table 441.
- 5. Write the key into the SAES_KEYRx registers. Alternatively, manage the key source selected by KEYSEL[2:0] (see Section 48.4.17: SAES key registers for details).
- 6. Wait until KEYVALID is set (the key loading complete).
- 7. Enable the SAES peripheral, by setting EN.
- 8. Append data:
- a) If it is the last block and the plaintext (encryption) or ciphertext (decryption) size in the block is less than 16 bytes, pad the remainder of the block with zeros.
- b) Append the data block into SAES as described in Section 48.4.5, then read the SAES_DOUTR register four times to save the resulting block.
- c) Repeat the step b) until the second-last block is processed. For the last block of plaintext (encryption only), follow the steps a) and b). For the last block, discard the bits that are not part of the message when the last block is smaller than 16 bytes.
- 9. Finalize the sequence: disable the SAES peripheral, by clearing EN.
Suspend/resume operations in CTR mode
Like for CBC mode, it is possible to interrupt a message to send a higher-priority message, then resume the interrupted message. Detailed CBC suspend and resume sequence is described in Section 48.4.9: SAES basic chaining modes (ECB, CBC). The IV registers must be saved in suspend, then restored in resume operation, because they are altered during the data processing.
Note: Suspend and resume operations are only supported when SAES is used in CPU mode.
48.4.11 SAES Galois/counter mode (GCM)
The AES Galois/counter mode (GCM) allows encrypting and authenticating a plaintext message into the corresponding ciphertext and tag (also known as message authentication code).
GCM mode is based on AES in counter mode for confidentiality. It uses a multiplier over a fixed finite field for computing the message authentication code. The following figure shows a typical message construction in GCM mode.
Figure 409. Message construction in GCM

The diagram illustrates the message construction in GCM. It shows the structure of the message and the authentication process. The message consists of an Initial Counter Block (ICB), Additional Authenticated Data (AAD), and Plaintext (P). The ICB is composed of an Initialization Vector (IV) and a Counter. The AAD is followed by a zero padding block. The Plaintext (P) is followed by a zero padding block and a Last block containing the lengths of AAD and Plaintext. The diagram shows the authentication process where the ICB, AAD, and Last block are authenticated, and the Plaintext is encrypted and authenticated to produce the Authenticated & encrypted ciphertext (C) and the Authentication tag (T).
The message has the following structure:
- • 16-byte initial counter block (ICB), composed of two distinct fields:
- – Initialization vector (IV): a 96-bit value that must be unique for each encryption cycle with a given key. The GCM standard supports IVs with less than 96 bits, but in this case strict rules apply.
- – Counter: a 32-bit big-endian integer that is incremented each time a block processing is complete. According to NIST specification, the counter value is 0x2 when processing the first block of payload.
- • Authenticated header AAD (also known as additional authentication data) has a known length Len(A) that may be a nonmultiple of 16 bytes, and must not exceed 2⁶⁴-1 bits. This part of the message is only authenticated, not encrypted.
- • Plaintext message P is both authenticated and encrypted as ciphertext C, with a known length Len(P) that may be nonmultiple of 16 bytes, and cannot exceed 2³²-2 16-byte blocks.
- • Last block contains the AAD header length (bits [32:63]) and the payload length (bits [96:127]) information, as shown in Table 443.
The GCM standard specifies that ciphertext C has the same bit length as the plaintext P.
When a part of the message (AAD or P) has a length that is a nonmultiple of 16 bytes a special padding scheme is required.
For more details, refer to NIST Special Publication 800-38D, Recommendation for Block Cipher Modes of Operation - Galois/Counter Mode (GCM) and GMAC.
Figure 410 describes the GCM chaining implementation in the SAES peripheral (encryption). To select this chaining mode, write CHMOD[3:0] with 0x3.
Figure 410. GCM authenticated encryption

The first counter block (CB1) is derived from the initial counter block ICB by the application software, as defined in Table 442.
Table 442. Initialization of IV registers in GCM mode
| SAES_IVR3[31:0] | SAES_IVR2[31:0] | SAES_IVR1[31:0] | SAES_IVR0[31:0] |
|---|---|---|---|
| ICB[127:96] | ICB[95:64] | ICB[63:32] | ICB[31:0] 32-bit counter = 0x0002 |
The last block of a GCM message contains the AAD header and the payload lengths in bits, as shown in Table 443.
Table 443. GCM last block definition
| Word order to SAES_DINR | First word | Second word | Third word | Fourth word |
|---|---|---|---|---|
| Input data | AAD length[63:32] | AAD length[31:0] | Payload length[63:32] | Payload length[31:0] |
GCM encryption and decryption process
This process is described in Section 48.4.6, with the following sequence of events.
GCM initialize
- 1. Disable the SAES peripheral, by clearing EN.
- 2. Wait until BUSY clears (indicating no RNG random number fetch in progress).
- 3. Initialize the SAES_CR register:
- a) Select GCM chaining mode (write CHMOD[3:0] with 0x3) in encryption or decryption mode (write MODE[1:0] with 0x0 or 0x2). Do not write MODE[1:0] with 0x1.
- b) Configure the data type, through DATATYPE[1:0]
- c) Configure the key size, through KEYSIZE[1:0]. Also set KEYPROT if the key is not shared with a different security context (different secure or Compartment ID attribute).
- d) Select the key source using KEYSEL[2:0] (see step 5.)
- e) Select normal key mode, by clearing WRAPEN. For wrapped key usage (with WRAPEN set) refer to Section 48.4.14.
- f) Select the GCM initialization phase, by writing CPHASE[1:0] with 0x0
- 4. Write the initialization vector in SAES_IVRx registers according to Table 442.
- 5. Write the key into the SAES_KEYRx registers. Alternatively, manage the key source selected by KEYSEL[2:0] (see Section 48.4.17: SAES key registers for details).
- 6. Wait until KEYVALID is set (key loading complete).
- 7. Set EN to start the calculation of the hash key.
- 8. Wait until the CCF flag is set in the SAES_ISR register, indicating that the GCM hash subkey (H) computation is complete.
- 9. Clear the CCF flag by setting the CCF bit of the SAES_ICR register.
GCM header phase
- 10. Initialize header phase:
- a) Select the GCM header phase, by writing 0x1 to CPHASE[1:0]. Do not change the other configurations written during GCM initialization.
- b) Enable the SAES peripheral, by setting EN.
- 11. Append header data:
- a) If it is the last block and the AAD in the block is smaller than 16 bytes, pad the remainder of the block with zeros.
- b) Append the data block into SAES as described in Section 48.4.5.
- c) Repeat the step b) until the second-last AAD data block is processed. For the last block, follow the steps a) and b).
Note: This phase can be skipped if there is no AAD, that is, Len(A) = 0.
No data are read during header phase.
GCM payload phase
- 12. Initialize payload phase:
- a) Select the GCM payload phase, by writing CPHASE[1:0] with 0x2. Do not change the other configurations written during GCM initialization.
- b) If the header phase is skipped, enable the SAES peripheral by setting EN.
- 13. Append payload data:
- a) If it is the last block and the message in the block is smaller than 16 bytes, pad the remainder of the block with zeros.
- b) Append the data block into SAES as described in Section 48.4.5, then read the SAES_DOUTR register four times to save the resulting block. As mentioned in Section 48.4.5, the use of NPBLB[3:0] might be necessary.
- c) Repeat the step b) until the second-last plaintext block is encrypted or until the last block of ciphertext is decrypted. For the last block of plaintext (encryption only), follow the steps a) and b). For the last block, discard the bits that are not part of the payload when the last block is smaller than 16 bytes.
- 14. Wait until the BUSY flag clears (encryption only).
Note: This phase can be skipped if there is no payload, that is, Len(C) = 0 (see GMAC mode).
GCM finalization
- 15. Select the GCM final phase, by writing CPHASE[1:0] with 0x3. Do not change the other configurations written during GCM initialization. If DMA was used previously, clear the DMAINEN and DMAOUTEN bits to switch to CPU mode.
- 16. Write the final GCM block into the SAES_DINR register. It is the concatenated AAD bit and payload bit lengths, as shown in Table 443.
- 17. Wait until the CCF flag of the SAES_ISR register is set.
- 18. Get the GCM authentication tag, by reading the SAES_DOUTR register four times.
- 19. Clear the CCF flag, by setting the CCF bit in SAES_ICR register.
- 20. Disable the SAES peripheral, by clearing EN. If it is an authenticated decryption, compare the generated tag with the expected tag passed with the message.
Note: In the final phase, data are written to SAES_DINR normally (no swapping), while swapping is applied to tag data read from SAES_DOUTR.
When transiting from the header or the payload phase to the final phase, the SAES peripheral must not be disabled, otherwise the result is wrong.
Suspend/resume operations in GCM mode
Suspend/resume operations are not supported in GCM mode.
48.4.12 SAES Galois message authentication code (GMAC)
The Galois message authentication code (GMAC) allows the authentication of a plaintext, generating the corresponding tag information (also known as message authentication code).
GMAC is similar to GCM, except that it is applied on a message composed only by plaintext authenticated data (that is, only header, no payload). The following figure shows typical message construction for GMAC.
Figure 411. Message construction in GMAC mode
![Diagram showing message construction in GMAC mode. It illustrates the structure of the authenticated data, including the Initialization vector (IV), Counter, ICB, Authenticated data, and Last block. The Last block contains [Len(A)]64 and [0]64. The authentication tag (T) is derived from the authenticated data.](/RM0506-STM32MP21/4dcc39fe4a7937f917a8426cbba73401_img.jpg)
The diagram shows the message construction for GMAC mode. It consists of an Initialization vector (IV) and a Counter, which are used to generate the ICB (Initial Counter Block). The ICB is followed by the Authenticated data, which is padded to 16-byte boundaries. The Last block of the authenticated data contains the length of the authenticated data, [Len(A)]₆₄, and a zero padding [0]₆₄. The authentication tag (T) is derived from the authenticated data.
For more details, refer to NIST Special Publication 800-38D, Recommendation for Block Cipher Modes of Operation - Galois/Counter Mode (GCM) and GMAC.
Figure 412 describes the GMAC chaining implementation in the SAES peripheral. To select this chaining mode, write CHMOD[3:0] with 0x3.
Figure 412. GMAC authentication mode

The diagram illustrates the GMAC authentication mode implementation in the SAES peripheral. It is divided into four stages: (1) Init, (2) Header, (3) Data, and (4) Final. In the Init stage, the KEY is encrypted with an initial vector [0]₁₂₈ to produce H. In the Header stage, the DIN (message block 1) and DINR (message block n) are processed through Swap management and GF2mul blocks. In the Data stage, the DIN is processed through Swap management and GF2mul blocks. In the Final stage, the IVI (IV + (32-bit counter = 0x1)) is encrypted with the KEY to produce H. The DIN is processed through Swap management and GF2mul blocks. The output of the GF2mul block is XORed with the output of the Swap management block to produce the authentication tag (DOUT).
The GMAC algorithm corresponds to the GCM algorithm applied on a message that only contains a header. As a consequence, all steps and settings are the same as with the GCM, except that the payload phase is omitted.
Suspend/resume operations in GMAC mode
Suspend/resume operations are not supported in GMAC mode.
48.4.13 SAES counter with CBC-MAC (CCM)
The AES counter with cipher block chaining-message authentication code (CCM) algorithm allows encryption and authentication of plaintext, generating the corresponding ciphertext and tag (also known as message authentication code). To ensure confidentiality, the CCM algorithm is based on AES counter chaining mode. It uses cipher block chaining technique to generate the message authentication code. This is commonly called CBC-MAC.
Note: NIST does not approve CBC-MAC as an authentication mode outside the context of the CCM specification.
The following figure shows typical message construction for CCM.
Figure 413. Message construction in CCM mode

The diagram illustrates the message construction for CCM mode. It shows a sequence of blocks: B0, Associated data (A), and Plaintext (P). B0 is a 16-byte block containing flags and a Nonce (N). Associated data (A) is a variable-length block. Plaintext (P) is a variable-length block. The output is Authenticated & encrypted ciphertext (C) and a Message Authentication Code (MAC) (T). The diagram also shows the lengths of the blocks: Len(A), Len(P), Len(C), and Len(T). A 'Zero padding' block is shown at the end of the plaintext. A 'Decrypt and compare' block is shown between the ciphertext and the MAC.
The structure of the message is:
- • 16-byte first authentication block (B0), composed of three distinct fields:
- – Q: a bit string representation of the octet length of P (Len(P))
- – Nonce (N): a single-use value (that is, a new nonce must be assigned to each new communication) of Len(N) size. The sum Len(N) + Len(P) must be equal to 15 bytes.
- – Flags: most significant octet containing four flags for control information, as specified by the standard. It contains two 3-bit strings to encode the values t (MAC length expressed in bytes) and Q (plaintext length such that Len(P) < 28Q bytes). The counter blocks range associated to Q is equal to 28Q-4, that is, if the maximum value of Q is 8, the counter blocks used in cipher must be on 60 bits.
- • 16-byte blocks (B) associated to the associated data (A). This part of the message is only authenticated, not encrypted. This section has a known length Len(A) that can be a nonmultiple of 16 bytes (see Figure 413). The
standard also states that, on MSB bits of the first message block (B1), the associated data length expressed in bytes (a) must be encoded as follows:
- – If 0 < a < 2¹⁶-2⁸, then it is encoded as [a]₁₆, that is, on two bytes.
- – If 2¹⁶-2⁸ < a < 2³², then it is encoded as 0xff∥0xfe∥[a]₃₂, that is, on six bytes.
- – If 2³² < a < 2⁶⁴, then it is encoded as 0xff∥0xff∥[a]₆₄, that is, on 10 bytes.
- • 16-byte blocks (B) associated to the plaintext message P, which is both authenticated and encrypted as ciphertext C, with a known length Len(P). This length can be a nonmultiple of 16 bytes (see Figure 413).
- • Encrypted MAC (T) of length Len(T) appended to the ciphertext C of overall length Len(C).
When a part of the message (A or P) has a length that is a nonmultiple of 16 bytes, a special padding scheme is required.
Note: CCM chaining mode can also be used with associated data only (that is, no payload).
As an example, the C.1 section in NIST Special Publication 800-38C gives the following values (hexadecimal numbers):
N: 10111213 141516 (Len(N) is 56 bits or 7 bytes)
A: 00010203 04050607 (Len(A) is 64 bits or 8 bytes)
P: 20212223 (Len(P) is 32 bits or 4 bytes)
T: 6084341B (Len(T) is 32 bits or t = 4)
B0: 4F101112 13141516 00000000 00000004
B1: 00080001 02030405 06070000 00000000
B2: 20212223 00000000 00000000 00000000
CTR0: 0710111213 141516 00000000 00000000
CTR1: 0710111213 141516 00000000 00000001
For more details, refer to NIST Special Publication 800-38C, Recommendation for Block Cipher Modes of Operation - The CCM Mode for Authentication and Confidentiality.
Figure 414 describes the CCM chaining implementation in the SAES peripheral (encryption). To select this chaining mode, write CHMOD[3:0] with 0x4.
Figure 414. CCM mode authenticated encryption

MSv69570V2
The first block of a CCM message (B0) must be prepared by the application as defined in Table 444.
Table 444. Initialization of IV registers in CCM mode
| SAES_IVR3[31:0] | SAES_IVR2[31:0] | SAES_IVR1[31:0] | SAES_IVR0[31:0] |
|---|---|---|---|
| B0[127:96](1) | B0[95:64] | B0[63:32] | B0[31:0](2) |
- 1. The five most significant bits are cleared (flag bits).
- 2. Q length bits are cleared, except for the bit 0 that is set.
SAES supports counters up to 64 bits, as specified by NIST.
CCM encryption and decryption process
This process is described in Section 48.4.6, with the following sequence of events.
CCM initialize
- 1. Disable the SAES peripheral, by clearing EN.
- 2. Wait until BUSY clears (indicating no RNG random number fetch in progress).
- 3. Initialize the SAES_CR register:
- a) Select CCM chaining mode (write CHMOD[3:0] with 0x4) in encryption or decryption mode (write MODE[1:0] with 0x0 or 0x2). Do not write MODE[1:0] with 0x1.
- b) Configure the data type, through DATATYPE[1:0].
- c) Configure the key size, through KEYSIZE[1:0]. Also set KEYPROT if the key is not shared with a different security context (different secure or Compartment ID attribute).
- d) Select the key source using KEYSEL[2:0] (see step 5.)
- e) Select normal key mode, by clearing WRAPEN. For wrapped key usage (with WRAPEN set) refer to Section 48.4.14.
- f) Select the CCM initialization phase, by writing CPHASE[1:0] with 0x0.
- 4. Write the B0 data into the SAES_IVRx registers according to Table 444.
- 5. Write the key into the SAES_KEYRx registers Alternatively, manage the key source selected by KEYSEL[2:0] (see Section 48.4.17: SAES key registers for details).
- 6. Wait until KEYVALID is set (the key loading complete).
- 7. Set EN to start the first mask calculation. The EN bit clears automatically upon completion of the calculation.
- 8. Wait until the CCF flag of the SAES_ISR register is set.
- 9. Clear the CCF flag, by setting the CCF bit of the SAES_ICR register.
CCM header phase
- 10. Initialize header phase:
- a) Prepare the first block of the (B1) data associated with the message, in accordance with CCM chaining rules.
- b) Select the CCM header phase, by writing CPHASE[1:0] with 0x1. Do not change the other configurations written during the CCM initialization.
- c) Enable the SAES peripheral, by setting EN.
- 11. Append header data:
- a) If it is the last block and the associated data in the block is smaller than 16 bytes, pad the remainder of the block with zeros.
- b) Append the data block into SAES as described in Section 48.4.5.
- c) Repeat the step b) until the second-last associated data block is processed. For the last block, follow the steps a) and b).
Note: This phase can be skipped if there is no associated data, that is, Len(A) = 0
No data are read during the header phase.
CCM payload phase
- 12. Initialize payload phase:
- a) Select the CCM payload phase, by writing CPHASE[1:0] with 0x2. Do not change the other configurations written during the CCM initialization.
- b) If the header phase is skipped, enable the SAES peripheral, by setting EN.
- 13. Append payload data:
- a) In encryption only, if it is the last block and the plaintext in the block is smaller than 16 bytes, pad the remainder of the block with zeros.
- b) Append the data block into SAES as described in Section 48.4.5, then read the SAES_DOUTR register four times to save the resulting block. As mentioned in Section 48.4.5, the use of NPBLB[3:0] might be necessary.
- c) Repeat the step b) until the second-last plaintext block is encrypted or until the last block of ciphertext is decrypted. For the last block of plaintext (encryption only), follow the steps a) and b). For the last block, discard the bits that are not part of the payload when the last block is smaller than 16 bytes.
Note: This phase can be skipped if there is no payload, that is, Len(P) = 0 or Len(C) = Len(T).
Remove \(LSB_{Len(T)}(C)\) encrypted tag information when decrypting ciphertext C.
CCM finalization
- 14. Select the CCM final phase, by writing CPHASE[1:0] with 0x3. Do not change the other configurations written during the CCM initialization. If DMA was used previously, clear the DMAINEN and DMAOUTEN bits to switch to CPU mode.
- 15. Wait until CCF flag of the SAES_ISR register is set.
- 16. Get the CCM authentication tag, by reading the SAES_DOUTR register four times.
- 17. Clear the CCF flag, by setting the CCF bit of the SAES_ICR register.
- 18. Disable the SAES peripheral, by clearing EN. If it is an authenticated decryption, compare the generated tag with the expected tag passed with the message. Mask the authentication tag output with tag length to obtain a valid tag.
Note: In the final phase, swapping is applied to tag data read from SAES_DOUTR register.
When transiting from the header or the payload phase to the final phase, the SAES peripheral must not be disabled, otherwise the result is wrong.
Suspend and resume operations in CCM mode
Note: Suspend and resume operations are only supported when SAES is used in CPU mode.
To suspend the processing of a message in header or payload phase, proceed as follows:
- 1. Wait until the CCF flag of the SAES_ISR register is set (computation complete).
- 2. Read the SAES_DOUTR register four times to save the last processed block.
- 3. Clear the CCF flag in the SAES_ISR register, by setting the CCF bit of the SAES_ICR register.
- 4. Save the SAES_SUSPRx registers in the memory.
- 5. In the payload phase, save the IV registers as they are altered during the data processing. This step is not required in the header phase.
- 6. Disable the SAES peripheral, by clearing EN.
- 7. Save the current SAES_CR configuration in the memory. Key registers do not need to be saved as the original key value is known by the application.
To resume the processing of a message, proceed as follows:
- 1. Disable the SAES peripheral, by clearing EN.
- 2. Write the suspend register values, previously saved in the memory, back into their corresponding SAES_SUSPRx registers.
- 3. Restore the initial setting values in the SAES_CR and SAES_KEYRx registers. Alternatively, select a key source different from the key registers, by setting KEYSEL[2:0] to a value different from 0x0. Refer to Section 48.4.17: SAES key registers for details.
- 4. In the payload phase, restore the SAES_IVRx registers using the saved configuration. In the header phase, write the initial setting values back to the SAES_IVRx registers.
- 5. Enable the SAES peripheral, by setting EN.
48.4.14 SAES basic operations with wrapped keys
SAES peripheral can wrap (encrypt) and unwrap (decrypt) the application keys using hardware-secret key (DHUK, BHK or their XOR combination). With this feature, keys used in SAES can be made usable by the application software without being exposed in clear-text (unencrypted).
Wrapped key sequences are too small to be suspended/resumed. They also cannot be used when GCM or CCM mode are selected.
Using wrapped keys with ECB/CBC chaining modes
Figure 415 summarizes how to use wrapped keys when ECB or CBC mode are chosen.
- • In Step 1, the clear-text key is encrypted once in SAES. KEYSEL[2:0] is different from zero.
- • In Step 2, the encrypted key is decrypted in SAES each time the unwrapped (decrypted) key needs to be loaded in key registers.
- – Set WRAPID[2:0] to zero if the wrapped key is used in SAES
- – Set WRAPID[2:0] to a value different from zero if the wrapped key is used outside of the SAES.
- • In Step 3, the target peripheral (SAES or another AES peripheral) can use the unwrapped (decrypted) key. If SAES is the target peripheral, WRAPEN must be cleared, otherwise it remains set.
Figure 415. Usage of wrapped keys in ECB and CBC modes

Provisioning wrapped keys
The recommended sequence to wrap (that is, encrypt) a key using ECB/CBC is as follows:
- 1. Disable the SAES peripheral, by clearing EN.
- 2. Wait until BUSY clears (indicating no RNG random number fetch in progress).
- 3. Initialize the SAES_CR register as follows:
- a) Select ECB or CBC chaining mode (CHMOD[3:0] at 0x0 or 0x1) in encryption mode (MODE[1:0] at 0x0).
- b) Select 32-bit data type (DATATYPE at 0x0).
- c) Configure the key size with KEYSIZE[1:0]. This information is used both for the encryption key and for the key to wrap/encrypt, unless KEYSIZE[1:0] is 0x1. In this case the encryption key is fixed to 256-bit, not 192-bit.
- d) Select the correct key source by using KEYSEL[2:0].
- e) Set WRAPEN and select the wrapped key use with WRAPID[2:0]. Refer to Section 48.8.1 for details on WRAPID[2:0] options.
- 4. Write the initialization vector in SAES_IVRx registers if CBC mode is selected in the previous step.
- 5. If required, manage the key source selected by KEYSEL[2:0] (see Section 48.4.17).
- 6. Wait until KEYVALID is set (key loading complete).
- 7. Enable the SAES peripheral, by setting EN.
- 8. Write the SAES_DINR register four times to input the key to encrypt (MSB first).
If KEYSIZE[1:0] is 0x1 the 128-bit MSB block of the key to encrypt is made of two MSB words of the key (as two 32-bit LSB words), with the two 32-bit MSB words made of ciphertext stealing data (for example 8-bytes MSB of the 128 least significant key block). - 9. Wait until CCF flag is set in the SAES_ISR register.
- 10. Get the encrypted key (MSB first) by reading the SAES_DOUTR register four times. Then clear the CCF flag, by setting the CCF bit in SAES_ICR register.
- 11. Repeat steps 8 to 10 if KEYSIZE[1:0] is 0x1 or 0x2.
- 12. Disable the SAES peripheral, by clearing EN.
Note: Encryption with WRAPEN set is only supported when ECB or CBC is selected.
Unwrapping keys in appropriate target
The recommended sequence to unwrap (or decrypt) a wrapped (encrypted) key using ECB/CBC is as follows:
- 1. Disable the SAES peripheral, by clearing EN.
- 2. Wait until BUSY clears (indicating no RNG random number fetch in progress).
- 3. Initialize the SAES_CR register as follows:
- a) Select the key derivation mode, writing MODE[1:0] with 0x1. The CHMOD[3:0] bitfield must be the same as when the key were wrapped/encrypted.
- b) Select 32-bit data type (DATATYPE at 0x0).
- c) The KEYSIZE[1:0] bitfield must be the same as when the key were wrapped/encrypted. When KEYSIZE[1:0] is 0x1, the decryption key size is fixed to 256-bit, not 192-bit.
- d) Select with KEYSEL[2:0] the same key source as when the key was wrapped or encrypted.
- e) Set WRAPEN, with WRAPID[2:0] configured to match the value used when the key was wrapped or encrypted.
- 4. If required, manage the key source selected by KEYSEL[2:0] (see Section 48.4.17).
- 5. Wait until KEYVALID is set (key loading complete).
- 6. Enable the SAES peripheral, by setting EN.
- 7. Wait until CCF flag is set in the SAES_ISR register.
- 8. Clear the CCF flag, by setting the CCF bit in SAES_ICR register. The decryption key is available in the AES core, and SAES is disabled automatically.
- 9. Select the decryption mode, by writing MODE[1:0] with 0x2. Do not change other parameters in SAES_CR register.
- 10. Write in SAES_IVRx registers the same initialization vector as when the key were wrapped/encrypted, if CBC mode is selected in the previous step.
- 11. Enable the SAES peripheral, by setting EN.
- 12. Write the SAES_DINR register four times to input the key to decrypt (MSB first).
- 13. Wait until CCF flag is set in the SAES_ISR register. Then clear the CCF flag by setting the CCF bit in SAES_ICR register. Reading SAES_DOUTR returns zero and triggers a read error (RDERRF).
- 14. Repeat steps 12 and 13 if KEYSIZE[1:0] is 0x1 or 0x2.
- 15. Disable the SAES peripheral, by clearing EN.
At the end of this sequence, the decrypted wrapped key is immediately usable when the WRAPEN bit clears, based on the WRAPID value:
- • If the WRAPID[2:0] value is zero, the key can be shared with an application running in a different security context (such as secure, nonsecure, specific CPU) if KEYPROT bit was cleared during the step 3.
- • If the WRAPID[2:0] value is nonzero, the application must load the key to the target AES engine as described in Section 48.4.15.
- • At this stage, with WRAPEN and KEYVALID set, if WRAPID[2:0] value is changed from zero to nonzero, the SAES sets the KEIF error flag, thus clearing key registers and causing any key transfer sequence to fail (see Section 48.4.19 for details).
Note: When the application selects the DHUK as key source (KEYSEL[2:0] is 0x1 or 0x4), the application must use the same privilege, security, CPU, HDPL, WRAPEN/WRAPID, KEYSEL[2:0], CHMOD[3:0] and KEYSIZE[1:0] context for encryption and decryption. Otherwise, the result is incorrect.
Using wrapped keys with CTR chaining mode
Figure 416 summarizes how to use wrapped keys when CTR mode is chosen.
- • In Step 1 the hardware secret key is computed in SAES each time it needs to be used (AES CTR decryption with DIN=0).
- – Set WRAPID[2:0] to zero if wrapped key is used in SAES
- – Set WRAPID[2:0] to a value different from zero if wrapped key is used outside of the SAES.
- • In Step 2 the target peripheral (SAES or another AES peripheral) can use the computed key. If SAES is the target peripheral, WRAPEN must be cleared, otherwise it remains set.
Figure 416. Operation with wrapped keys in CTR mode

The diagram illustrates the operation with wrapped keys in CTR mode, divided into two steps: Step 1: provision and Step 2: use.
Step 1: provision (WRAPEN = 1): A block diagram shows a SAES dec block. The input DIN is set to 0. The output is labeled 'Decrypted key' and is crossed out with a red 'X'. A red arrow labeled 'h/w secret key' points to the SAES dec block.
Step 2: use (WRAPEN = 0): This step is further divided into two sub-steps based on WRAPID:
- WRAPID = 0x0: A block diagram shows a SAES enc/dec block. The input DIN is connected to the block. The output is labeled DOUT. A red arrow labeled 'Derypted key (from IV)' points to the SAES enc/dec block.
- WRAPID > 0x0: A block diagram shows a SAES block and an AES enc/dec block. The input DIN is connected to the SAES block. The output of the SAES block is labeled 'Derypted key (from IV)' and points to the AES enc/dec block. The output of the AES enc/dec block is labeled DOUT.
MSv72622V2
Recommended sequence for SAES wrapped key usage with CTR is described below:
- 1. Disable the SAES peripheral, by clearing EN.
- 2. Wait until BUSY clears (indicating no RNG random number fetch in progress).
- 3. Initialize the SAES_CR register as follows:
- a) Select the CTR chaining mode (CHMOD[3:0] at 0x2) in decryption mode (MODE[1:0] at 0x2). Other MODE[1:0] values are not supported.
- b) Select 32-bit data type (DATATYPE at 0x0).
- c) Configure the required key size using KEYSIZE[1:0]. 192-bit key (KEYSIZE[1:0] is 0x1) is not supported.
- d) Select the correct key source by using KEYSEL[2:0].
- e) Set WRAPEN and select the wrapped key usage with WRAPID[2:0]. Refer to Section 48.8.1 for details on WRAPID[2:0] options.
- 4. Write the initialization vector in SAES_IVRx registers. This information can be the ID of the key.
- 5. If required, manage the key source selected by KEYSEL[2:0] (see Section 48.4.17).
- 6. Wait until KEYVALID is set (key loading complete).
- 7. Enable the SAES peripheral, by setting EN.
- 8. Wait until CCF flag is set in the SAES_SR register. Then clear the CCF flag, by setting the CCF bit in SAES_ICR register. Reading SAES_DOUTR returns zero and triggers a read error (RDERRF).
- 9. Disable the SAES peripheral, by clearing EN.
At the end of this sequence, the decrypted wrapped key is immediately usable when the WRAPEN bit clears, based on the WRAPID value:
- • If the WRAPID[2:0] value is zero, the key can be shared with an application running in a different security context (such as secure, nonsecure, specific CPU) if the KEYPROT bit was cleared during the step 3.
- • If WRAPID[2:0] is different from zero, the application must load the key to the target AES engine as described in next Section 48.4.15.
- • At this stage, with WRAPEN and KEYVALID set, if WRAPID[2:0] value is changed from zero to nonzero, SAES sets KEIF error flag, thus clearing key registers and causing any key transfer sequence to fail (see Section 48.4.19 for details).
Note: When the application selects the DHUK as key source (KEYSEL[2:0] is 0x1 or 0x4), the application must use the same privilege, security, CPU, HDPL, WRAPEN/WRAPID, KEYSEL[2:0], CHMOD[3:0] and KEYSIZE[1:0] context for encryption and decryption. Otherwise, the result is incorrect.
Setting encryption with WRAPEN set and CTR mode selected automatically clears EN bit, disabling the peripheral.
48.4.15 Wrapped key usage outside the SAES peripheral
When WRAPID[2:0] is different from zero an AES peripheral can use the unwrapped key loaded in SAES peripheral. Refer to the WRAPID[2:0] bitfield description in Section 48.8.1 for the supported AES peripherals. The key unwrapping procedure in SAES is described in previous Section 48.4.14.
Once the wrapped key is decrypted in SAES key registers, it can be shared with the target AES peripheral (exclusively), while WRAPEN and KEYVALID are set in SAES. Key sharing sequence can be run multiple times in the target AES peripheral (for example, to manage a suspend/resume situation), as long as SAES is unused and duly remains in key sharing state, with WRAPEN and KEYVALID set.
If one of the CRYP1 and CRYP2 peripherals not selected by WRAPID[2:0] tries to read the unwrapped key in SAES, the key transfer sequence fails without errors.
If KEYSIZE[1:0] value in target CRYP1 or CRYP2 peripheral differs from SAES, the key transfer sequence fails with key error flag raised in both peripherals.
Note: KEYSIZE[1:0] is 0x1 (192-bit key) is not supported when WRAPEN is set and WRAPID[2:0] is greater than 0x0.
While WRAPEN and KEYVALID are set in SAES, modifying WRAPID[2:0] triggers a KEIF error, which causes the key registers to be cleared and any key transfer sequence to fail (see Section 48.4.19 for details).
48.4.16 SAES data registers and data swapping
Data input and output
A 16-byte data block enters the SAES peripheral with four successive 32-bit word writes into the SAES_DINR register (bitfield DIN[31:0]), the most significant word (bits [127:96]) first, the least significant word (bits [31:0]) last.
A 16-byte data block is retrieved from the SAES peripheral with four successive 32-bit word reads of the SAES_DOUTR register (bitfield DOUT[31:0]), the most significant word (bits [127:96]) first, the least significant word (bits [31:0]) last.
The four 32-bit words of a 16-byte data block must be stored in the memory consecutively and in big-endian order, that is, with the most significant word on the lowest address. See Table 446 “no swapping” option for details.
Data swapping
The SAES peripheral can be configured to perform a bit-, a byte-, a half-word-, or no swapping on the input data word in the SAES_DINR register, before loading it to the AES processing core, and on the data output from the AES processing core, before sending it to the SAES_DOUTR register. The choice depends on the type of data. For example, a byte swapping is used for an ASCII text stream.
The data swap type is selected through DATATYPE[1:0]. The selection applies to both SAES input and output, except in GCM final phase (in which data must be inserted normally).
Note: The data in the SAES key registers (SAES_KEYRx) and the initialization vector registers (SAES_IVRx) are not sensitive to the swap mode selection.
Table 446 and Figure 417 summarize the SAES data swapping feature. As shown, the padding bytes are swapped with the data written in SAES_DINR because the padding process is completed before the data swapping.
Table 445. SAES data swapping example
| DATATYPE[1:0] | Swapping performed | Data block |
|---|---|---|
| System memory data (big-endian) | ||
| 0x0 | No swapping | Block[127..64]: 0x04EEF672 2E04CE96 Block[63..0]: 0x4E6F7720 69732074 |
| Address @, word[127..96]: 0x04EEF672 Address @ + 0x4, word[95..64]: 0x2E04CE96 Address @ + 0x8, word[63..32]: 0x4E6F7720 Address @ + 0xC, word[31..0]: 0x69732074 | ||
| 0x1 | Half-word (16-bit) swapping | Block[63..0]: 0x4E6F 7720 6973 2074 |
| Address @, word[63..32]: 0x7720 4E6F Address @ + 0x4, word[31..0]: 0x2074 6973 | ||
| 0x2 | Byte (8-bit) swapping | Block[63..0]: 0x4E 6F 77 20 69 73 20 74 |
| Address @, word[63..32]: 0x2077 6F4E Address @ + 0x4, word[31..0]: 0x7420 7369 | ||
| 0x3 | Bit swapping | Block[63..32]: 0x4E6F7720 0100 1110 0110 1111 0111 0111 0010 0000 Block[31..0]: 0x69732074 0110 1001 0111 0011 0010 0000 0111 0100 |
| Address @, word[63..32]: 0x04EE F672 0000 0100 1110 1110 1111 0110 0111 0010 Address @ + 0x4, word[31..0]: 0x2E04 CE96 0010 1110 0000 0100 1100 1110 1001 0110 |
Figure 417. 128-bit block construction according to the data type
![Figure 417: 128-bit block construction according to the data type. The diagram shows four cases for DATATYPE[1:0]: 00 (no swapping), 01 (16-bit swapping), 10 (8-bit swapping), and 11 (bit swapping). Each case shows the mapping of 128 bits into four 32-bit words (Word 3, Word 2, Word 1, Word 0) and the resulting order of data in the AES core input/output buffer. A legend explains the symbols used: Dx for data bit 'x', arrows for data swap, circled numbers 1-4 for write/read order, gray boxes for zero padding, and dashed lines for AES core data.](/RM0506-STM32MP21/4e86b788394fb753212e71a495f50ce0_img.jpg)
DATATYPE[1:0] = 00: no swapping
Word 3: D127...D96
Word 2: D95...D64
Word 1: D63...D32
Word 0: D31...D0
DATATYPE[1:0] = 01: 16-bit (half-word) swapping
Word 3: D127...D112 | D111...D96
Word 2: D95...D80 | D79...D64
Word 1: D63...D48 | D47...D32
Word 0: D31...D16 | D15...D0
DATATYPE[1:0] = 10: 8-bit (byte) swapping
Word 3: D127..120 | D119..112 | D111..104 | D103..96
Word 2: D95..88 | D87..80 | D79..72 | D71..64
Word 1: D63..56 | D55..48 | D47..40 | D39..32
Word 0: D31..24 | D23..16 | D15..8 | D7..0
DATATYPE[1:0] = 11: bit swapping
Word 3: D127..D126 | D125...D98 | D97...D96
Word 2: D95...D94 | D93...D66 | D65...D64
Word 1: D63...D62 | D61...D34 | D33...D32
Word 0: D31...D30 | D29...D2 | D1...D0
Legend:
- Dx input/output data bit 'x'
- ↔ Data swap
- ①...④ Order of write to data input / read from data output register
- ■ Zero padding (example)
- --- AES core input/output data
MSv66122V2
Data padding
Figure 417 also gives an example of memory data block padding with zeros such that the zeroed bits after the data swap form a contiguous zone at the MSB end of the AES core input buffer. The example shows the padding of an input data block containing:
- • 84 message bits, with DATATYPE[1:0] equal to 0x0
- • 48 message bits, with DATATYPE[1:0] equal to 0x1
- • 56 message bits, with DATATYPE[1:0] equal to 0x2
- • 34 message bits, with DATATYPE[1:0] equal to 0x3
48.4.17 SAES key registers
The eight SAES_KEYRx write-only registers store the encryption or decryption key information, as shown on Table 446. Reads are not allowed for security reason.
Note: In the memory and in the SAES key registers, keys are stored in little-endian format, with most significant byte on the highest address.
Table 446. Key endianness in SAES_KEYRx registers (128/192/256-bit keys)
| SAES_KEYR7 [31:0] | SAES_KEYR6 [31:0] | SAES_KEYR5 [31:0] | SAES_KEYR4 [31:0] | SAES_KEYR3 [31:0] | SAES_KEYR2 [31:0] | SAES_KEYR1 [31:0] | SAES_KEYR0 [31:0] |
|---|---|---|---|---|---|---|---|
| - | - | - | - | KEY[127:96] | KEY[95:64] | KEY[63:32] | KEY[31:0] |
| - | - | - | - | TAMP_BKP3R [31:0] | TAMP_BKP2R [31:0] | TAMP_BKP1R [31:0] | TAMP_BKP0R [31:0] |
| - | - | KEY[191:160] | KEY[159:128] | KEY[127:96] | KEY[95:64] | KEY[63:32] | KEY[31:0] |
| - | - | TAMP_BKP5R [31:0] | TAMP_BKP4R [31:0] | TAMP_BKP3R [31:0] | TAMP_BKP2R [31:0] | TAMP_BKP1R [31:0] | TAMP_BKP0R [31:0] |
| KEY[255:224] | KEY[223:192] | KEY[191:160] | KEY[159:128] | KEY[127:96] | KEY[95:64] | KEY[63:32] | KEY[31:0] |
| TAMP_BKP7R [31:0] | TAMP_BKP6R [31:0] | TAMP_BKP5R [31:0] | TAMP_BKP4R [31:0] | TAMP_BKP3R [31:0] | TAMP_BKP2R [31:0] | TAMP_BKP1R [31:0] | TAMP_BKP0R [31:0] |
The key registers are not affected by the data swapping feature controlled by the DATATYPE[1:0] bitfield.
Write operations to the SAES_KEYRx registers are ignored when the SAES peripheral is enabled (EN bit set) and KEYSEL[2:0] is different from zero. The application must check this before modifying key registers.
The entire key must be written before starting an AES computation. With KEYSEL[2:0] at 0x0, the key registers must always be written in either ascending or descending order. The write sequence becomes:
- • SAES_KEYRx (x = 0 to 3 or x = 3 to 0) for KEYSIZE[1:0] equal to 0x0
- • SAES_KEYRx (x = 0 to 5 or x = 5 to 0) for KEYSIZE[1:0] equal to 0x1
- • SAES_KEYRx (x = 0 to 7 or x = 7 to 0) for KEYSIZE[1:0] equal to 0x2
Note: KEYSIZE[1:0] must be written before the key. When KEYSIZE[1:0] is 0x1 and WRAPEN is set, the application must write the eight key registers (not only six).
As soon as the first key register is written, the KEYVALID flag clears. Once the key registers writing sequence is complete, KEYVALID is set and EN becomes writable. If an error occurs, KEYVALID is cleared and KEIF set (see Section 48.4.19).
Key selection
With KEYSEL[2:0] at 0x0, the application must write the key to the SAES_KEYRx registers.
With KEYSEL[2:0] at 0x1, a derived hardware unique key (DHUK), computed inside SAES from a nonvolatile and secret root hardware unique key, is loaded directly into key registers, based on KEYSIZE[1:0] information. Thanks to the key derivation function, secure SAES uses a secure DHUK, while nonsecure SAES uses a nonsecure DHUK.
With KEYSEL[2:0] at 0x2, the boot hardware key (BHK), stored in tamper-resistant secure backup registers, is entirely transferred into the key registers upon performing a single read in ascending order of all the TAMP_BKPxR registers (x = 0 to 3 for KEYSIZE[1:0] equal to 0x0, x = 0 to 7 for KEYSIZE[1:0] equal to 0x1 or 0x2). Refer to Table 446.
With KEYSEL[2:0] at 0x4, the XOR combination of DHUK and BHK is entirely transferred into key registers upon performing a single read in ascending order of all the TAMP_BKPxR registers (x = 0 to 3 for KEYSIZE[1:0] equal to 0x0, x = 0 to 7 for KEYSIZE[1:0] equal to 0x1 or 0x2). Refer to Table 446.
KEYVALID must be cleared when the application needs to reload a key into the key registers selected by KEYSEL[2:0], provided the value is different from zero. For example, this is necessary when switching from ECB decryption to ECB encryption using the same key. When KEYVALID is set, the recommended method to clear it is by using IPRST (see Section 48.8.1).
For nonzero KEYSEL[2:0] values, initiating the key-loading sequence sets the BUSY flag and clears the KEYVALID flag. Once the amount of bits defined by KEYSIZE[1:0] is transferred to the SAES_KEYRx registers, BUSY is cleared, KEYVALID set and the EN bit becomes writable. If an error occurs, BUSY and KEYVALID are cleared and KEIF set (see Section 48.4.19).
Note: DHUK, BHK or their XOR combination are not readable by any software (even secure).
Note: Any write to TAMP_BKPxR registers is done by a secure application.
Key protection
As depicted in Figure 418, when the application sets the KEYPROT bit before writing a key into SAES_KEYRx, any application executing in a different security context (that is, different security or Compartment ID attribute) triggers a KEIF error flag upon access to any SAES register when KEYVALID is set.
Note: KEYSEL[2:0] values different from zero (normal key) automatically protect the key registers.
Figure 418. Key protection mechanisms
![Diagram illustrating key protection mechanisms between two security contexts. Security context A (secure) contains an SAES block with KEYVALID = 1. Security context B (nonsecure) contains two SAES blocks. The top SAES block is accessed when KEYPROT = 0 and KEYSEL[2:0] = 000. The bottom SAES block is accessed when KEYPROT = 1 or KEYSEL ≠ 000, which results in a KEIF error flag being set, indicated by a lightning bolt and a crossed-out key icon.](/RM0506-STM32MP21/1b7ad9639624cd3e1ce5aacf3677ed4b_img.jpg)
The diagram illustrates key protection mechanisms between two security contexts: Security context A (for example secure) and Security context B (for example nonsecure). In Security context A, there is an SAES block with a key icon and the label KEYVALID = 1. In Security context B, there are two SAES blocks. The top SAES block is accessed when KEYPROT = 0 and KEYSEL[2:0] = 000. The bottom SAES block is accessed when KEYPROT = 1 or KEYSEL ≠ 000, which results in a KEIF error flag being set, indicated by a lightning bolt and a crossed-out key icon. The diagram is labeled MSv63151V1.
48.4.18 SAES initialization vector registers
The four SAES_IVRx registers store the initialization vector (IV) information, as shown in Table 447. They can only be written if the SAES peripheral is disabled (EN cleared).
Note: In the memory and in the SAES IV registers, initialization vectors are stored in little-endian format, with most significant byte on the highest address.
Table 447. IVI bitfield spread over SAES_IVRx registers
| SAES_IVR3[31:0] | SAES_IVR2[31:0] | SAES_IVR1[31:0] | SAES_IVR0[31:0] |
|---|---|---|---|
| IVI[127:96] | IVI[95:64] | IVI[63:32] | IVI[31:0] |
Initialization vector information depends on the chaining mode selected. When used, SAES_IVRx registers are updated upon each AES computation cycle (useful for managing suspend mode).
The initialization vector registers are not affected by the data swapping feature controlled through DATATYPE[1:0].
48.4.19 SAES error management
The SAES peripheral manages the errors described in this section.
Read error flag (RDERRF)
Unexpected read attempt of the SAES_DOUTR register returns zero, setting the RDERRF flag and the RWEIF flag. RDERRF is triggered during the computation phase or during the input phase.
Note: Unless otherwise indicated, SAES is not disabled when RDERRF rises and it continues processing.
An interrupt is generated if the RWEIE bit is set. For more details, refer to Section 48.5: SAES interrupts.
The RDERRF and RWEIF flags are cleared by setting the RWEIF bit of the SAES_ICR register.
Write error flag (WRERRF)
Unexpected write attempt of the SAES_DINR register is ignored, setting the WRERRF and the RWEIF flags. WRERRF is triggered during the computation phase or during the output phase.
Note: Unless otherwise indicated, SAES is not disabled when WRERRF rises and it continues processing.
An interrupt is generated if the RWEIE bit is set. For more details, refer to Section 48.5: SAES interrupts.
The WRERRF and RWEIF flags are cleared by setting the RWEIF bit of the SAES_ICR register.
Key error interrupt flag (KEIF)
There are multiple sources of errors that set the KEIF flag of the SAES_ISR register and clear the KEYVALID bit of the SAES_SR register:
- • Key protection error: while KEYVALID is set, if KEYPROT is set or KEYSEL[2:0] is different from zero, this error is triggered when an application executing in a security context different from the one used to load the key (that is, different security or Compartment ID attribute) accesses the SAES peripheral.
- • Key writing sequence error: triggered upon detecting an incorrect sequence of writing key registers. See Section 48.4.17: SAES key registers for details.
- • Key sharing size mismatch error: triggered when WRAPEN is set, WRAPID[2:0] is greater than 0x0, and KEYSIZE[1:0] in CRYP1 or CRYP2 peripheral does not match KEYSIZE[1:0] in the SAES peripheral.
- • Key sharing error: triggered upon a failure to transfer the SAES shared key to the CRYP1 or CRYP2 peripheral. See Section 48.4.15: Wrapped key usage outside the SAES peripheral for details.
- • Hardware secret key loading error: triggered upon failing to load DHUK or BHK into SAES. The corresponding KEYSEL[2:0] value is not functional.
The KEIF flag is cleared with corresponding bit of the SAES_ICR register. An interrupt is generated if the KEIE bit of the SAES_IER register is set. For more details, refer to Section 48.5: SAES interrupts. Activating interrupts on key errors is recommended, for security reason.
Upon a key selection error, use IPRST to clear KEIF and the source of error (specific value of KEYSEL[2:0] and KEYSIZE[1:0]). Persisting problems may require a power-on reset.
Upon a key sharing error, reset both CRYP1 (or CRYP2, depending on the key sharing target) and SAES peripherals through the IPRST bit of their corresponding control register, then restart the key sharing sequence.
Note: For any key error, clear KEIF flag prior to disabling and reconfiguring SAES. Clearing KEIF without updating KEYSEL[2:0] and KEYSIZE[1:0] restarts the key loading process.
RNG error interrupt flag (RNGEIF)
SAES fetches random numbers from the RNG peripheral automatically after an IP reset triggered in the RCC. SAES cannot be used when RNGEIF is set.
An error detected while fetching a random number from RNG peripheral (due to, for example, bad entropy) sets the RNGEIF flag of the SAES_ISR register. The flag is cleared by setting the corresponding bit of the SAES_ICR register. An interrupt is generated if the RNGEIE bit of the SAES_IER register is set. For more details, refer to Section 48.5: SAES interrupts.
Upon an RNG error:
- • Verify that the RNG peripheral is properly initialized, its AHB clock is enabled and no noise source (or seed) error is pending in this peripheral.
- • Clear RNGEIF or reset the peripheral by setting IPRST. The clearance of the BUSY flag then indicates the completion of the random number fetch from RNG.
Note: To avoid RNGEIF errors, it is recommended to activate the RNG AHB clock each time SAES AHB clock is activated.
About DPA errors
An unexpected error triggers an SAES internal tamper event in the TAMP peripheral, and stops any processing in SAES.
To resume normal operation, reset the SAES peripheral through RCC or global reset.
48.5 SAES interrupts
There are multiple individual maskable interrupt sources generated by the SAES peripheral to signal the following events:
- • Computation complete (CCF)
- • Read error (RDERRF)
- • Wwrite error (WRERRF)
- • Key error (KEIF)
- • RNG error (RNGEIF)
See Section 48.4.19: SAES error management for details on SAES errors.
These sources are combined into a common interrupt signal from the SAES peripheral that connects to the Cortex® CPU interrupt controller. The application can enable or disable SAES interrupt sources individually by setting/clearing the corresponding enable bit of the SAES_IER register.
The status of the individual maskable interrupt sources can be read from the SAES_ISR register. They are cleared by setting the corresponding bit of the SAES_ICR register.
Table 448 gives a summary of the available features.
Table 448. SAES interrupt requests
| Interrupt acronym | Interrupt event | Event flag | Enable bit | Interrupt clear method |
|---|---|---|---|---|
| SAES | computation complete flag | CCF | CCFIE | set CCF(1) |
| read error flag | RWEIF, RDERRF(2) | RWEIE | set RWEIF(1) | |
| write error flag | RWEIF, WRERRF(2) | |||
| key error flag | KEIF | KEIE | set KEIF(1) | |
| RNG error flag | RNGEIF | RNGEIE | set RNGEIF(1) |
1. Bit of the SAES_ICR register.
2. Flags in the SAES_SR register. Setting either of them also sets the RWEIF flag in the SAES_ISR register.
48.6 SAES DMA requests
The SAES peripheral provides an interface to connect to the DMA (direct memory access) controller. The DMA operation is controlled through the DMAINEN and DMAOUTEN bits of the SAES_CR register. When key derivation is selected (MODE[1:0] is at 0x1), setting those bits has no effect.
SAES only supports single DMA requests. Suspend and resume operations are not supported in DMA mode.
Detailed usage of DMA with SAES can be found in section Appending data via DMA.
48.6.1 Data input using DMA
Setting DMAINEN enables DMA writing into SAES. SAES then initiates, during the input phase, a set of single DMA requests for each 16-byte data block to write to the SAES_DINR register (quadruple 32-bit word, MSB first).
Note: According to the algorithm and the mode selected, special padding / ciphertext stealing might be required (see Section 48.4.7).
48.6.2 Data output using DMA
Setting DMAOUTEN enables DMA reading from SAES. SAES then initiates, during the output phase, a set of single DMA requests for each 16-byte data block to read from the SAES_DOUTR register (quadruple 32-bit word, MSB first).
After the output phase, at the end of processing of a 16-byte data block, SAES switches automatically to a new input phase for the next data block, if any.
In DMA mode, the CCF flag has no use because the reading of the SAES_DOUTR register is managed by DMA automatically at the end of the computation phase.
Note: According to the message size, extra bytes might need to be discarded by the application in the last block.
48.6.3 Stopping DMA transfers
All DMA request signals are deasserted when SAES is disabled (EN cleared) or the DMA enable bit (DMAINEN for input data, DMAOUTEN for output data) is cleared.
48.7 SAES processing latency
The following tables provide the 16-byte data block processing latency for selected operating modes, given in SAES AHB clock cycles.
Table 449. Processing latency for ECB, CBC and CTR
| Key size | Mode of operation | Chaining algorithm | Clock cycles(1) |
|---|---|---|---|
| 128-bit | Encryption or decryption(2) | ECB, CBC, CTR | 82 |
| Key preparation | - | 66 | |
| 192-bit | Encryption or decryption(2) | ECB, CBC, CTR | 90 |
| Key preparation | - | 82 | |
| 256-bit | Encryption or decryption(2) | ECB, CBC, CTR | 102 |
| Key preparation | - | 88 |
1. SAES kernel clock.
2. Excluding key preparation time (ECB and CBC only).
Table 450. Processing latency for GCM and CCM
| Key size | Mode of operation | Chaining algorithm | Initialization phase | Header phase(1) | Payload phase(1)(2) | Final phase(1) |
|---|---|---|---|---|---|---|
| 128-bit | Mode 1: Encryption/ Mode 3: Decryption | GCM | 103 | 73 | 82(3) | 82 |
| CCM | 93 | 86 | 175 | 88 | ||
| 192-bit | Mode 1: Encryption/ Mode 3: Decryption | GCM | 111 | 73 | 90(3) | 90 |
| CCM | 101 | 94 | 191 | 96 | ||
| 256-bit | Mode 1: Encryption/ Mode 3: Decryption | GCM | 123 | 73 | 102(3) | 102 |
| CCM | 113 | 106 | 215 | 108 |
- 1. Data insertion can include wait states forced by SAES on the AHB bus (maximum 3 cycles, typical 1 cycle).
- 2. Value given for saes_hclk = saes_ker_ck.
- 3. For the last block processing time is increased to 286 cycles.
48.8 SAES registers
The registers are accessible through 32-bit word single accesses only. Other access types generate an AHB error, and other than 32-bit writes may corrupt the register content.
48.8.1 SAES control register (SAES_CR)
Address offset: 0x00
Reset value: 0x0000 0000
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| IPRST | KEYSEL[2:0] | WRAPID[2:0] | WRAPEN | NPBLB[3:0] | KEYPROT | KEYSIZE[1:0] | Res. | ||||||||
| rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| Res. | CPHASE[1:0] | DMAOUTEN | DMAINEN | Res. | Res. | CHMOD[3:0] | MODE[1:0] | DATATYPE[1:0] | EN | ||||||
| rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | |||
Bit 31 IPRST: SAES software reset
Setting this bit resets the SAES peripheral, putting all registers to their default values, except the IPRST bit itself, and the RNGEIF bit. Hence, any key-relative data is lost. For this reason, it is recommended to set the bit before handing over the SAES to a less secure application.
The bit must be low while writing any configuration registers. After setting this bit, the application must clear it when BUSY clears in SAES_SR (IPRST clear is ignored otherwise).
Bits 30:28 KEYSEL[2:0]: Key selection
The bitfield defines the source of the key information to use in the AES cryptographic core.
0x0: Software key, loaded in key registers SAES_KEYx
0x1: Derived hardware unique key (DHUK)
0x2: Boot hardware key (BHK)
0x4: XOR of DHUK and BHK
Other: Reserved (if used, unfreeze SAES with IPRST)
When KEYSEL[2:0] is different from zero, selected key value is available in key registers when BUSY is cleared and KEYVALID set in the SAES_SR register. Otherwise, the key error flag KEIF is set. Repeated writing of KEYSEL[2:0] with the same non-zero value only triggers the loading of DHUK, BHK or their XOR combination when KEYVALID clears.
When the application software changes the key selection by writing the KEYSEL[2:0] bitfield, the key registers are immediately erased and the KEYVALID flag cleared.
At the end of the decryption process, KEYSEL[2:0] is cleared if WRAPEN is set.
With the bitfield value other than zero and KEYVALID set, the application cannot transfer the ownership of SAES with a loaded key to an application running in another security context (such as secure, nonsecure, specific CPU). More specifically, when security or Compartment ID of an access to any register does not match the information recorded by SAES, the KEIF flag is set.
Attempts to write the bitfield are ignored when the BUSY flag of SAES_SR register is set, as well as when the EN bit of the SAES_CR register is set before the write access and it is not cleared by that write access.
Bits 27:25 WRAPID[2:0]: Wrap ID
This bitfield defines, at the end of a decryption process with WRAPEN set, which target can use the key stored in SAES key registers.
0x0: The SAES itself
0x1: The CRYP1 peripheral, through the key bus
0x2: The CRYP2 peripheral, through the key bus
Other: Reserved (do not use)
When WRAPEN is set and WRAPID is different from zero, the SAES key registers are shared with the peripheral selected with this bitfield after a successful decryption process. This sharing ends when either WRAPEN or KEYVALID is cleared. Changing this bitfield value when WRAPEN and KEYVALID are set triggers a key error (KEIF set in SAES_ISR), with KEYVALID automatically cleared.
Attempts to write the bitfield are ignored when BUSY is set, as well as when EN is set before the write access and it is not cleared by that write access.
Bit 24 WRAPEN: Wrap enable
Set this bit when manipulating wrapped (or encrypted) keys.
0: Normal key. The key registers are freely usable and no specific use or protection applies to the SAES_DINR and SAES_DOUTR registers.
1: Wrapped key. When a decryption is selected, read-as-zero SAES_DOUTR register is automatically loaded into the SAES key registers, after a successful decryption process.
When WRAPEN is set WRAPID[2:0] and KEYSIZE[1:0] must be properly initialized.
When WRAPEN is set any attempt to configure the SAES peripheral for use by an application belonging to a different security domain (such as secure or nonsecure, other CPU) results in automatic key erasure and setting of the KEIF flag.
Attempts to write this bit are ignored when BUSY is set, as well as when EN is set before the write access and it is not cleared by that write access.
Bits 23:20 NPBLB[3:0]: Number of padding bytes in last block
This padding information must be filled by software before processing the last block of GCM payload encryption or CCM payload decryption, otherwise authentication tag computation is incorrect.
0x0: All bytes are valid (no padding)
0x1: Padding for the last LSB byte
...
0xF: Padding for the 15 LSB bytes of last block.
Bit 19 KEYPROT: Key protection
When set, hardware-based key protection is enabled.
0: When KEYVALID is set and KEYSEL[2:0] is 0x0, the application can transfer the ownership of SAES, with its loaded key, to an application running in another security context (such as nonsecure, secure, specific CPU).
1: When KEYVALID is set, key error flag (KEIF) is set when an access to any registers is detected, this access having a security context (for example, secure, nonsecure, Compartment ID) that does not match the one of the application that loaded the key.
Attempts to write the bit are ignored when BUSY is set, as well as when EN is set before the write access and it is not cleared by that write access.
Bits 18:17 KEYSIZE[1:0]: Key size
This bitfield defines the key length in bits of the key used by SAES.
0x0: 128-bit
0x1: 192-bit
0x2: 256-bit
0x3: Reserved
When WRAPEN is set, KEYSIZE[1:0] also defines the length of the key to encrypt or decrypt.
Attempts to write the bit are ignored when BUSY is set, as well as when the EN is set before the write access and it is not cleared by that write access.
Bits 16:15 Reserved, must be kept at reset value.
Bits 14:13 CPHASE[1:0]: Chaining phase
This bitfield selects the phase, applicable only with GCM, GMAC or CCM chaining modes. It is ignored when ECB, CBC or CTR is selected, and WRAPEN is set.
0x0: Initialization phase
0x1: Header phase
0x2: Payload phase
0x3: Final phase
Bit 12 DMAOUTEN: DMA output enable
This bit enables automatic generation of DMA requests during the data phase, for outgoing data transfers from SAES via DMA.
0: Disable
1: Enable
Setting this bit is ignored when MODE[1:0] is at 0x1 (key derivation).
Bit 11 DMAINEN: DMA input enable
This bit enables automatic generation of DMA requests during the data phase, for incoming data transfers to SAES via DMA.
0: Disable
1: Enable
Setting this bit is ignored when MODE[1:0] is at 0x1 (key derivation).
Bits 10:9 Reserved, must be kept at reset value.
Bits 8:5 CHMOD[3:0]: Chaining mode
This bitfield selects the AES chaining mode in SAES.
0x0: Electronic codebook (ECB)
0x1: Cipher-Block Chaining (CBC)
0x2: Counter Mode (CTR)
0x3: Galois Counter Mode (GCM) and Galois Message Authentication Code (GMAC)
0x4: Counter with CBC-MAC (CCM)
Other: Reserved
Attempts to write the bitfield are ignored when the BUSY bit of the SAES_SR register is set, as well as when the EN bit of this register is set before the write access and it is not cleared by that write access.
Bits 4:3 MODE[1:0]: Operating mode
This bitfield selects the SAES operating mode:
0x0: Encryption
0x1: Key derivation (or key preparation), for ECB/CBC decryption only
0x2: Decryption
0x3: Reserved
Attempts to write the bitfield are ignored when the BUSY bit of the SAES_SR register is set, as well as when the EN bit of this register is set before the write access and it is not cleared by that write access.
Bits 2:1 DATATYPE[1:0]: Data type
This bitfield defines the format of data written to the SAES_DINR register or read from the SAES_DOUTR register, through selecting the mode of data swapping. This swapping is defined in Section 48.4.16: SAES data registers and data swapping.
0x0: No swapping (32-bit data)
0x1: Half-word swapping (16-bit data)
0x2: Byte swapping (8-bit data)
0x3: Bit-level swapping
Attempts to write the bitfield are ignored when BUSY is set, as well as when EN is set before the write access and it is not cleared by that write access.
Bit 0 EN: Enable
This bit enables/disables the SAES peripheral.
0: Disable
1: Enable
At any moment, clearing then setting the bit re-initializes the SAES peripheral. When the WRAPEN and the BUSY bits are set, IPRST bit is used instead.
This bit is automatically cleared by hardware upon the completion of the key preparation (MODE[1:0] at 0x1) and upon the completion of GCM/GMAC/CCM initialization phase.
The bit cannot be set as long as KEYVALID is cleared. It cannot be set either when SAES is in one of the following configurations:
- – WRAPEN set, CHMOD[3:0] at 0x3 (GCM)
- – WRAPEN set, CHMOD[3:0] at 0x2 (CTR), and MODE[1:0] at 0x0 (encryption).
48.8.2 SAES status register (SAES_SR)
Address offset: 0x04
Reset value: 0x0000 0000
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | KEYVALID | WRERRF | RDERRF | BUSY | Res. | Res. | Res. | Res. |
| r | r | r | r |
Bits 31:8 Reserved, must be kept at reset value.
Bit 7 KEYVALID: Key valid flag
This bit is set by hardware when the key of size defined by KEYSIZE[1:0] is loaded in SAES_KEYRx key registers.
0: Key not valid
1: Key valid
The EN bit can only be set when KEYVALID is set.
In normal mode when KEYSSEL[2:0] is at zero, the key must be written to the key registers in the correct sequence, otherwise the KEIF flag is set and KEYVALID remains cleared.
When KEYSSEL[2:0] is different from zero, the BUSY flag is automatically set by SAES. When the key is loaded successfully, BUSY is cleared and KEYVALID set. Upon an error, KEIF is set, BUSY cleared and KEYVALID remains cleared.
If set, KEIF must be cleared through the SAES_ICR register, otherwise KEYVALID cannot be set. See the KEIF flag description for more details.
For further information on key loading, refer to Section 48.4.17: SAES key registers.
Bit 6 WRERRF: Write error flag
This bit is set when an unexpected write to the SAES_DINR register occurred. When set WRERRF bit has no impact on the SAES operations.
0: No error
1: Unexpected write to SAES_DINR register occurred during computation or data output phase.
The flag setting generates an interrupt if the RWEIE bit of the SAES_IER register is set.
The flag is cleared by setting the RWEIF bit of the SAES_ICR register.
Bit 5 RDERRF: Read error flag
This bit is set when an unexpected read to the SAES_DOUTR register occurred. When set RDERRF bit has no impact on the SAES operations.
0: No error
1: Unexpected read to SAES_DOUTR register occurred during computation or data input phase.
The flag setting generates an interrupt if the RWEIE bit of the SAES_IER register is set.
The flag is cleared by setting the RWEIF bit of the SAES_ICR register.
Bit 4 BUSY: Busy
This flag indicates whether SAES is idle or busy.
0: Idle
1: Busy
SAES is flagged as idle when disabled (EN = 0) or when the last processing is complete.
SAES is flagged as busy when processing a block data, fetching random number from the RNG, transferring a shared key to the target peripheral, or preparing a key (ECB or CBC decryption only).
The GCM final phase must only be selected when BUSY is low.
Bits 3:0 Reserved, must be kept at reset value.
48.8.3 SAES data input register (SAES_DINR)
Address offset: 0x08
Reset value: 0x0000 0000
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| DIN[31:16] | |||||||||||||||
| w | w | w | w | w | w | w | w | w | w | w | w | w | w | w | w |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| DIN[15:0] | |||||||||||||||
| w | w | w | w | w | w | w | w | w | w | w | w | w | w | w | w |
Bits 31:0 DIN[31:0]: Data input
A four-fold sequential write to this bitfield during the Input phase results in writing a complete 16-bytes block of input data to the SAES peripheral. From the first to the fourth write, the corresponding data weights are [127:96], [95:64], [63:32], and [31:0]. Upon each write, the data from the 32-bit input buffer are handled by the data swap block according to the DATATYPE[1:0] bitfield, then written into the AES core 16-bytes input buffer.
Reads return zero.
48.8.4 SAES data output register (SAES_DOUTR)
Address offset: 0x0C
Reset value: 0x0000 0000
Read when WRAPEN is set while MODE[1:0] is at 0x2 and EN is set triggers a read error.
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| DOUT[31:16] | |||||||||||||||
| r | r | r | r | r | r | r | r | r | r | r | r | r | r | r | r |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| DOUT[15:0] | |||||||||||||||
| r | r | r | r | r | r | r | r | r | r | r | r | r | r | r | r |
Bits 31:0 DOUT[31:0]: Data output
This read-only bitfield fetches a 32-bit output buffer. A four-fold sequential read of this bitfield, upon the computation completion (CCF flag set), virtually reads a complete 16-byte block of output data from the SAES peripheral. Before reaching the output buffer, the data produced by the AES core are handled by the data swap block according to the DATATYPE[1:0] bitfield.
Data weights from the first to the fourth read operation are: [127:96], [95:64], [63:32], and [31:0].
Writes are ignored.
48.8.5 SAES key register 0 (SAES_KEYR0)
Address offset: 0x020
Reset value: 0x0000 0000
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| KEY[31:16] | |||||||||||||||
| w | w | w | w | w | w | w | w | w | w | w | w | w | w | w | w |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| KEY[15:0] | |||||||||||||||
| w | w | w | w | w | w | w | w | w | w | w | w | w | w | w | w |
Bits 31:0 KEY[31:0]: Cryptographic key, bits [31:0]
These are bits [31:0] of the write-only bitfield KEY[255:0] AES encryption or decryption key, depending on the MODE[1:0] bitfield of the SAES_CR register.
Writes to SAES_KEYRx registers are ignored when SAES is enabled (EN bit set). When KEYSEL[2:0] is different from 0, writes to the key registers are ignored, and the KEIF bit in the SAES_ISR register is set without changing KEYVALID.
With WRAPEN cleared, a special writing sequence is required. In this sequence, any valid write to AES_KEYRx register clears the KEYVALID flag except for the sequence-completing write that sets it. Also refer to the description of the KEYVALID flag in the AES_SR register.
48.8.6 SAES key register 1 (SAES_KEYR1)
Address offset: 0x024
Reset value: 0x0000 0000
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| KEY[63:48] | |||||||||||||||
| w | w | w | w | w | w | w | w | w | w | w | w | w | w | w | w |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| KEY[47:32] | |||||||||||||||
| w | w | w | w | w | w | w | w | w | w | w | w | w | w | w | w |
Bits 31:0 KEY[63:32]: Cryptographic key, bits [63:32]
Refer to the SAES_KEYR0 register for description of the KEY[255:0] bitfield and for information relative to writing SAES_KEYRx registers.
48.8.7 SAES key register 2 (SAES_KEYR2)
Address offset: 0x028
Reset value: 0x0000 0000
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| KEY[95:80] | |||||||||||||||
| w | w | w | w | w | w | w | w | w | w | w | w | w | w | w | w |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| KEY[79:64] | |||||||||||||||
| w | w | w | w | w | w | w | w | w | w | w | w | w | w | w | w |
Bits 31:0 KEY[95:64]: Cryptographic key, bits [95:64]
Refer to the SAES_KEYR0 register for description of the KEY[255:0] bitfield and for information relative to writing SAES_KEYRx registers.
48.8.8 SAES key register 3 (SAES_KEYR3)
Address offset: 0x02C
Reset value: 0x0000 0000
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| KEY[127:112] | |||||||||||||||
| w | w | w | w | w | w | w | w | w | w | w | w | w | w | w | w |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| KEY[111:96] | |||||||||||||||
| w | w | w | w | w | w | w | w | w | w | w | w | w | w | w | w |
Bits 31:0 KEY[127:96]: Cryptographic key, bits [127:96]
Refer to the SAES_KEYR0 register for description of the KEY[255:0] bitfield and for information relative to writing SAES_KEYRx registers.
48.8.9 SAES key register 4 (SAES_KEYR4)
Address offset: 0x030
Reset value: 0x0000 0000
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| KEY[159:144] | |||||||||||||||
| w | w | w | w | w | w | w | w | w | w | w | w | w | w | w | w |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| KEY[143:128] | |||||||||||||||
| w | w | w | w | w | w | w | w | w | w | w | w | w | w | w | w |
Bits 31:0 KEY[159:128]: Cryptographic key, bits [159:128]
Refer to the SAES_KEYR0 register for description of the KEY[255:0] bitfield and for information relative to writing SAES_KEYRx registers.
48.8.10 SAES key register 5 (SAES_KEYR5)
Address offset: 0x034
Reset value: 0x0000 0000
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| KEY[191:176] | |||||||||||||||
| w | w | w | w | w | w | w | w | w | w | w | w | w | w | w | w |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| KEY[175:160] | |||||||||||||||
| w | w | w | w | w | w | w | w | w | w | w | w | w | w | w | w |
Bits 31:0 KEY[191:160]: Cryptographic key, bits [191:160]
Refer to the SAES_KEYR0 register for description of the KEY[255:0] bitfield and for information relative to writing SAES_KEYRx registers.
48.8.11 SAES key register 6 (SAES_KEYR6)
Address offset: 0x038
Reset value: 0x0000 0000
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| KEY[223:208] | |||||||||||||||
| w | w | w | w | w | w | w | w | w | w | w | w | w | w | w | w |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| KEY[207:192] | |||||||||||||||
| w | w | w | w | w | w | w | w | w | w | w | w | w | w | w | w |
Bits 31:0 KEY[223:192]: Cryptographic key, bits [223:192]
Refer to the SAES_KEYR0 register for description of the KEY[255:0] bitfield and for information relative to writing SAES_KEYRx registers.
48.8.12 SAES key register 7 (SAES_KEYR7)
Address offset: 0x03C
Reset value: 0x0000 0000
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| KEY[255:240] | |||||||||||||||
| w | w | w | w | w | w | w | w | w | w | w | w | w | w | w | w |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| KEY[239:224] | |||||||||||||||
| w | w | w | w | w | w | w | w | w | w | w | w | w | w | w | w |
Bits 31:0 KEY[255:224]: Cryptographic key, bits [255:224]
Refer to the SAES_KEYR0 register for description of the KEY[255:0] bitfield and for information relative to writing SAES_KEYRx registers.
48.8.13 SAES initialization vector register 0 (SAES_IVR0)
Address offset: 0x040
Reset value: 0x0000 0000
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| IVI[31:16] | |||||||||||||||
| rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| IVI[15:0] | |||||||||||||||
| rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw |
Bits 31:0 IVI[31:0]: Initialization vector input, bits [31:0]
SAES_IVRx registers store the 128-bit initialization vector or the nonce, depending on the chaining mode selected. This value is updated by hardware after each computation round (when applicable). Write to this register is ignored when EN bit is set in SAES_CR register.
48.8.14 SAES initialization vector register 1 (SAES_IVR1)
Address offset: 0x044
Reset value: 0x0000 0000
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| IVI[63:48] | |||||||||||||||
| rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| IVI[47:32] | |||||||||||||||
| rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw |
Bits 31:0 IVI[63:32]: Initialization vector input, bits [63:32]
Refer to the SAES_IVR0 register for description of the IVI[128:0] bitfield.
48.8.15 SAES initialization vector register 2 (SAES_IVR2)
Address offset: 0x048
Reset value: 0x0000 0000
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| IVI[95:80] | |||||||||||||||
| rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| IVI[79:64] | |||||||||||||||
| rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw |
Bits 31:0 IVI[95:64]: Initialization vector input, bits [95:64]
Refer to the SAES_IVR0 register for description of the IVI[128:0] bitfield.
48.8.16 SAES initialization vector register 3 (SAES_IVR3)
Address offset: 0x04C
Reset value: 0x0000 0000
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| IVI[127:112] | |||||||||||||||
| rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| IVI[111:96] | |||||||||||||||
| rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw |
Bits 31:0 IVI[127:96]: Initialization vector input, bits [127:96]
Refer to the SAES_IVR0 register for description of the IVI[128:0] bitfield.
48.8.17 SAES context swap registers (SAES_SUSPRx)
Address offset: 0x050 + x * 0x4, (x = 0 to 7)
Reset value: 0x0000 0000
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| SUSPx[31:16] | |||||||||||||||
| rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| SUSPx[15:0] | |||||||||||||||
| rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw |
Bits 31:0 SUSPx[31:0]: Context swap data x
SAES_SUSPRx registers contain the complete internal register states of the SAES when the CCM processing of the current task is suspended to process a higher-priority task. Refer to Section 48.4.8: SAES suspend and resume operations for more details.
Clearing EN bit in SAES_CR sets this register to zero.
SAES_SUSPRx registers are not used in other chaining modes than CCM, or when SAES is used in DMA mode.
48.8.18 SAES interrupt enable register (SAES_IER)
Address offset: 0x300
Reset value: 0x0000 0000
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | RNGEIE | KEIE | RWEIE | CCFIE | Res. | Res. |
| rw | rw | rw | rw |
Bits 31:6 Reserved, must be kept at reset value.
Bit 5 RNGEIE: RNG error interrupt enable
This bit enables or disables (masks) the SAES interrupt generation when RNGEIF (RNG error flag) is set.
- 0: Disabled (masked)
- 1: Enabled (not masked)
Bit 4 KEIE: Key error interrupt enable
This bit enables or disables (masks) the SAES interrupt generation when KEIF (key error flag) is set.
- 0: Disabled (masked)
- 1: Enabled (not masked)
Bit 3 RWEIE: Read or write error interrupt enable
This bit enables or disables (masks) the SAES interrupt generation when RWEIF (Read or write error flag) is set.
- 0: Disabled (masked)
- 1: Enabled (not masked)
Bit 2 CCFIE: Computation complete flag interrupt enable
This bit enables or disables (masks) the SAES interrupt generation when CCF (computation complete flag) is set.
- 0: Disabled (masked)
- 1: Enabled (not masked)
Bits 1:0 Reserved, must be kept at reset value.
48.8.19 SAES interrupt status register (SAES_ISR)
Address offset: 0x304
Reset value: 0x0000 0000
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | RNGEIF | KEIF | RWEIF | CCF | Res. | Res. |
| r | r | r | r |
Bits 31:6 Reserved, must be kept at reset value.
Bit 5 RNGEIF: RNG error interrupt flag
This read-only bit is set by hardware when an error is detected on RNG bus interface (for example bad entropy).
- 0: RNG bus is functional
- 1: Error detected on RNG bus interface (random seed fetching error)
The flag setting generates an interrupt if the RNGEIE bit of the SAES_IER register is set. The flag is cleared by setting the corresponding bit of the SAES_ICR register. The clear action triggers the reload of a new random number from the RNG peripheral.

Bit 4 KEIF: Key error interrupt flag
This read-only bit is set by hardware when the key information fails to load into key registers or when the key register use is forbidden.
0: No key error detected
1: Key information failed to load into key registers or the key register use is forbidden
The flag setting generates an interrupt if the KEIE bit of the SAES_IER register is set. It also clears the key registers and the KEYVALID flag in SAES_SR.
The flag is cleared by setting the corresponding bit of the SAES_ICR register.
KEIF is raised upon any of the following events:
–SAES fails to load the DHUK (KEYSEL[2:0] is 0x1 or 0x4).
–SAES fails to load the BHK (KEYSEL[2:0] is 0x2 or 0x4).
–CRYP1 or CRYP2 fails to load the key shared by the SAES peripheral (WRAPEN set and WRAPID is 0x1 or 0x2, respectively).
–KEYVALID is set and either KEYPROT is set or KEYSEL[2:0] is other than 0x0. The security context of the application that loads the key (secure or nonsecure) does not match the security attribute of the access to SAES_CR or SAES_DOUT. In this case, KEYVALID and EN bits are cleared.
–SAES_KEYRx register write does not respect the correct order. (For KEYSIZE[1:0] at 0x0, SAES_KEYR0 then SAES_KEYR1 then SAES_KEYR2 then SAES_KEYR3 register, or the reverse. For KEYSIZE[1:0] at 0x2, SAES_KEYR0 then SAES_KEYR1 then SAES_KEYR2 then SAES_KEYR3 then SAES_KEYR4 then SAES_KEYR5 then SAES_KEYR6 then SAES_KEYR7, or the reverse. For KEYSIZE[1:0] at 0x1, SAES_KEYR0 then SAES_KEYR1 then SAES_KEYR2 then SAES_KEYR3 then SAES_KEYR4 then SAES_KEYR5, or the reverse).
–When WRAPEN is set, WRAPID[2:0] value is changed after KEYVALID is set.
KEIF must be cleared by the application software, otherwise KEYVALID cannot be set.
Bit 3 RWEIF: Read or write error interrupt flag
This read-only bit is set by hardware when a RDERRF or a WRERRF error flag is set in the SAES_SR register.
0: No read or write error detected
1: Read or write error detected
The flag setting generates an interrupt if the RWEIE bit of the SAES_IER register is set.
The flag is cleared by setting the corresponding bit of the SAES_ICR register.
The flags has no meaning when key derivation mode is selected.
See the SAES_SR register for details.
Bit 2 CCF: Computation complete flag
This flag indicates whether the computation is complete. It is significant only when the DMAOUTEN bit is cleared, and it may stay high when DMAOUTEN is set.
0: Not complete
1: Complete
The flag setting generates an interrupt if the CCFIE bit of the SAES_IER register is set.
The flag is cleared by setting the corresponding bit of the SAES_ICR register.
Bits 1:0 Reserved, must be kept at reset value.
48.8.20 SAES interrupt clear register (SAES_ICR)
Address offset: 0x308
Reset value: 0x0000 0000
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | RNGEIF | KEIF | RWEIF | CCF | Res. | Res. |
| w | w | w | w |
Bits 31:6 Reserved, must be kept at reset value.
Bit 5 RNGEIF: RNG error interrupt flag clear
Setting this bit clears the RNGEIF status bit in SAES_ISR register.
Bit 4 KEIF: Key error interrupt flag clear
Setting this bit clears the KEIF status bit in SAES_ISR register.
Bit 3 RWEIF: Read or write error interrupt flag clear
Setting this bit clears the RWEIF status bit of the SAES_ISR register, and clears both RDERRF and WRERRF flags in the SAES_SR register.
Bit 2 CCF: Computation complete flag clear
Setting this bit clears the CCF status bit in SAES_ISR register.
Bits 1:0 Reserved, must be kept at reset value.
48.8.21 SAES hardware configuration register (SAES_HWCFGR)
Address offset: 0x3F0
Reset value: 0x0000 0001
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | CFG1[3:0] | |||
| r | r | r | r | ||||||||||||
Bits 31:4 Reserved, must be kept at reset value.
Bits 3:0 CFG1[3:0]: HW Generic 1
This field returns 0x1.
48.8.22 SAES version register (SAES_VERR)
Address offset: 0x3F4
Reset value: 0x0000 0010
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | MAJREV[3:0] | MINREV[3:0] | ||||||
| r | r | r | r | r | r | r | r | ||||||||
Bits 31:8 Reserved, must be kept at reset value.
Bits 7:4 MAJREV[3:0]: Major revision
This bitfield returns the SAES peripheral major version (0x1).
Bits 3:0 MINREV[3:0]: Minor revision
This bitfield returns the SAES peripheral minor version (0x0).
48.8.23 SAES identification register (SAES_IPIDR)
Address offset: 0x3F8
Reset value: 0x0017 0012
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| ID[31:16] | |||||||||||||||
| r | r | r | r | r | r | r | r | r | r | r | r | r | r | r | r |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| ID[15:0] | |||||||||||||||
| r | r | r | r | r | r | r | r | r | r | r | r | r | r | r | r |
Bits 31:0 ID[31:0]: Identification code of the peripheral
This bitfield returns the identification code of the SAES peripheral.
48.8.24 SAES size ID register (SAES_SIDR)
Address offset: 0x3FC
Reset value: 0xA3C5 DD01
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| SID[31:16] | |||||||||||||||
| r | r | r | r | r | r | r | r | r | r | r | r | r | r | r | r |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| SID[15:0] | |||||||||||||||
| r | r | r | r | r | r | r | r | r | r | r | r | r | r | r | r |
Bits 31:0 SID[31:0]: Size identification code
This bitfield returns the size identification code of the SAES peripheral as defined below:
Bits[31:8] = 0xA3C5DD (fixed code)
Bits[7:0] = 0x01 (1 Kbyte address decoding)
48.8.25 SAES register map
Table 451. SAES register map and reset values
| Offset | Register name Reset | 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0x000 | SAES_CR | IPRST | KEYSEL[2:0] | WRAPID[2:0] | WRAPEN | NPBLB[3:0] | KEYPROT | KEYSIZE[1:0] | Res. | Res. | CPHASE[1:0] | DMAOUTEN | DMAINEN | Res. | Res. | CHMOD[3:0] | MODE[1:0] | DATATYPE[1:0] | EN | |||||||||||||||||
| Reset value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ||||||
| 0x004 | SAES_SR | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | KEYVALID | WRERRF | RDERRF | BUSY | Res. | Res. | Res. | Res. | Res. | ||
| Reset value | 0 | 0 | 0 | 0 | ||||||||||||||||||||||||||||||||
| 0x008 | SAES_DINR | DATAIN[31:0] | ||||||||||||||||||||||||||||||||||
| Reset value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |||
| 0x00C | SAES_DOUTR | DATAOUT[31:0] | ||||||||||||||||||||||||||||||||||
| Reset value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |||
| 0x020 | SAES_KEYR0 | KEY[31:0] | ||||||||||||||||||||||||||||||||||
| Reset value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |||
| 0x024 | SAES_KEYR1 | KEY[63:32] | ||||||||||||||||||||||||||||||||||
| Reset value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |||
| 0x028 | SAES_KEYR2 | KEY[95:64] | ||||||||||||||||||||||||||||||||||
| Reset value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |||
| 0x02C | SAES_KEYR3 | KEY[127:96] | ||||||||||||||||||||||||||||||||||
| Reset value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |||
| 0x030 | SAES_KEYR4 | KEY[159:128] | ||||||||||||||||||||||||||||||||||
| Reset value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |||
| 0x034 | SAES_KEYR5 | KEY[191:160] | ||||||||||||||||||||||||||||||||||
| Reset value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |||
| 0x038 | SAES_KEYR6 | KEY[223:192] | ||||||||||||||||||||||||||||||||||
| Reset value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |||
| 0x03C | SAES_KEYR7 | KEY[255:224] | ||||||||||||||||||||||||||||||||||
| Reset value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |||
| 0x040 | SAES_IVR0 | IVI[31:0] | ||||||||||||||||||||||||||||||||||
| Reset value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |||
| 0x044 | SAES_IVR1 | IVI[63:32] | ||||||||||||||||||||||||||||||||||
| Reset value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |||
Table 451. SAES register map and reset values (continued)
| Offset | Register name Reset | 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0x048 | SAES_IVR2 | IVI[95:64] | |||||||||||||||||||||||||||||||
| Reset value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |
| 0x04C | SAES_IVR3 | IVI[127:96] | |||||||||||||||||||||||||||||||
| Reset value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |
| 0x050 | SAES_SUSPR0 | SUSP0[31:0] | |||||||||||||||||||||||||||||||
| Reset value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |
| 0x054 | SAES_SUSPR1 | SUSP1[31:0] | |||||||||||||||||||||||||||||||
| Reset value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |
| ... | |||||||||||||||||||||||||||||||||
| 0x068 | SAES_SUSPR6 | SUSP6[31:0] | |||||||||||||||||||||||||||||||
| Reset value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |
| 0x06C | SAES_SUSPR7 | SUSP7[31:0] | |||||||||||||||||||||||||||||||
| Reset value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |
| 0x300 | SAES_IER | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | RNGEIF | KEIE | RWEIE | CCFIE | Res. | Res. |
| Reset value | 0 | 0 | 0 | 0 | |||||||||||||||||||||||||||||
| 0x304 | SAES_ISR | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | RNGEIF | KEIF | RWEIF | CCF | Res. | Res. |
| Reset value | 0 | 0 | 0 | 0 | |||||||||||||||||||||||||||||
| 0x308 | SAES_ICR | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | RNGEIF | KEIF | RWEIF | CCF | Res. | Res. |
| Reset value | 0 | 0 | 0 | 0 | |||||||||||||||||||||||||||||
| 0x3F0 | SAES_HWCFG R | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | CFG1[3:0] | |||
| Reset value | 0 | 0 | 0 | 1 | |||||||||||||||||||||||||||||
| 0x3F4 | SAES_VERR | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | MAJREV[3:0] | MINREV[3:0] | |||||
| Reset value | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | |||||||||||||||||||||||||
| 0x3F8 | SAES_IPIDR | ID[31:0] | |||||||||||||||||||||||||||||||
| Reset value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | |
| 0x3FC | SAES_SIDR | SID[31:0] | |||||||||||||||||||||||||||||||
| Reset value | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 1 | 0 | 1 | 1 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | |