Symmetric Encryption Engine
AES Engine
The AES engine encrypts or decrypts data according to the Advanced Encryption Standard (AES) defined by NIST, supporting automatic message padding. It supports both software register keys and hardware OTP keys. Hardware encryption/decryption reduces software overhead, lowers CPU and memory resource consumption, and operates faster and more securely than software implementations.
AES Algorithm Support
Supported key sizes: AES-128, AES-192, AES-256
Supported encryption/decryption modes:
ECB (Electronic Codebook)
CBC (Cipher Block Chaining)
OFB (Output Feedback)
CFB (Cipher Feedback)
CTR (Counter)
GCM (Galois/Counter)
Supported key sizes: AES-128, AES-192, AES-256
Supported encryption/decryption modes:
ECB (Electronic Codebook)
CBC (Cipher Block Chaining)
OFB (Output Feedback)
CFB (Cipher Feedback)
CTR (Counter)
GCM (Galois/Counter)
Supported key sizes: AES-128, AES-192, AES-256
Supported encryption/decryption modes:
ECB (Electronic Codebook)
CBC (Cipher Block Chaining)
OFB (Output Feedback)
CFB (Cipher Feedback)
CTR (Counter)
GCM (Galois/Counter)
Supported key sizes: AES-128, AES-192, AES-256
Supported encryption/decryption modes:
ECB (Electronic Codebook)
CBC (Cipher Block Chaining)
OFB (Output Feedback)
CFB (Cipher Feedback)
CTR (Counter)
GCM (Galois/Counter)
Supported key sizes: AES-128, AES-192, AES-256
Supported encryption/decryption modes:
ECB (Electronic Codebook)
CBC (Cipher Block Chaining)
OFB (Output Feedback)
CFB (Cipher Feedback)
CTR (Counter)
GCM (Galois/Counter)
Supported key sizes: AES-128, AES-192, AES-256
Supported encryption/decryption modes:
ECB (Electronic Codebook)
CBC (Cipher Block Chaining)
OFB (Output Feedback)
CFB (Cipher Feedback)
CTR (Counter)
GCM (Galois/Counter)
The engine algorithm has been NIST CAVP certified.
Supported key sizes: AES-128, AES-192, AES-256
Supported encryption/decryption modes:
ECB (Electronic Codebook)
CBC (Cipher Block Chaining)
OFB (Output Feedback)
CFB (Cipher Feedback)
CTR (Counter)
GCM (Galois/Counter)
GMAC (Galois Message Authentication Code)
CMAC (Cipher Block Chaining-Message Authentication Code)
XTS (XEX-based Tweaked CodeBook mode with CipherText Stealing)
Supported message authentication codes:
GMAC (Galois Message Authentication Code)
CMAC (Cipher Block Chaining-Message Authentication Code)
AES Keys
The AES engine features an independent key management unit. This unit supports both software keys and hardware OTP keys.
The hardware encryption engine provides two key loading methods:
Software transfer: Keys are dynamically passed in by the application (software accessible)
OTP automatic loading: Keys are pre-burned into the OTP physical storage area (not accessible by software, only accessible by the encryption engine, preventing tampering or reading)
The OTP physical storage area supports storing 6 sets of keys, which need to be burned through the efuse command.
Engine Type |
Security |
Key Index |
OTP Key |
|---|---|---|---|
AES |
Secure |
0 |
S_IPSEC_Key1 |
AES |
Secure |
1 |
S_IPSEC_Key2 |
AES |
Secure |
2 |
RSIP_AES_Key1 |
AES |
Secure |
3 |
RSIP_AES_Key2 |
AES |
Non-secure |
0 |
NS_IPSEC_Key1 |
AES |
Non-secure |
1 |
NS_IPSEC_Key2 |
AES |
Non-secure |
2 |
RSIP_AES_Key1 |
AES |
Non-secure |
3 |
RSIP_AES_Key2 |
The detailed functions of OTP keys are shown below:
OTP Key Name |
Address |
Size bits |
Default Value |
Description |
|---|---|---|---|---|
S_IPSEC_Key1 (RDP) |
Logical map 0x200 |
256 |
0xFF |
When OTPKey_init function is enabled, the secure encryption engine will automatically load this key for HMAC or AES algorithm |
S_IPSEC_Key2 (Secure boot HMAC) |
Logical map 0x220 |
256 |
0xFF |
|
RSIP_AES_Key1 |
Logical map 0x2c0 |
256 |
0xFF |
When OTPKey_init function is enabled, non-secure AES engine and secure AES engine will automatically load this key for AES algorithm |
RSIP_AES_Key2 |
Logical map 0x2e0 |
256 |
0xFF |
|
S_IPSEC_Key1_Read_Protection |
Physical map 0x365[3] |
1 |
1 |
0: Enable S_IPSEC_Key1 read protection, prohibit key from being read 1: Disable S_IPSEC_Key1 read protection |
S_IPSEC_Key1_Write_Protection |
Physical map 0x365[4] |
1 |
1 |
0: Enable S_IPSEC_Key1 write protection, prohibit key from being written to all 0s by hackers 1: Disable S_IPSEC_Key1 write protection |
S_IPSEC_Key2_Read_Protection |
Physical map 0x365[5] |
1 |
1 |
0: Enable S_IPSEC_Key2 read protection, prohibit key from being read 1: Disable S_IPSEC_Key2 read protection |
S_IPSEC_Key2_Write_Protection |
Physical map 0x365[6] |
1 |
1 |
0: Enable S_IPSEC_Key2 write protection, prohibit key from being written to all 0s by hackers 1: Disable S_IPSEC_Key2 write protection |
RSIP_AES_Key1_Read_Protection |
Physical map 0x366[7] |
1 |
1 |
0: Enable RSIP_AES_Key1 read protection, prohibit key from being read 1: Disable RSIP_AES_Key1 read protection |
RSIP_AES_Key1_Write_Protection |
Physical map 0x367[0] |
1 |
1 |
0: Enable RSIP_AES_Key1 write protection, prohibit key from being written to all 0s by hackers 1: Disable RSIP_AES_Key1 write protection |
RSIP_AES_Key2_Read_Protection |
Physical map 0x367[1] |
1 |
1 |
0: Enable RSIP_AES_Key2 read protection, prohibit key from being read 1: Disable RSIP_AES_Key2 read protection |
RSIP_AES_Key2_Write_Protection |
Physical map 0x367[2] |
1 |
1 |
0: Enable RSIP_AES_Key2 write protection, prohibit key from being written to all 0s by hackers 1: Disable RSIP_AES_Key2 write protection |
The hardware encryption engine provides two key loading methods:
Software transfer: Keys are dynamically passed in by the application (software accessible)
OTP automatic loading: Keys are pre-burned into the OTP physical storage area (not accessible by software, only accessible by the encryption engine, preventing tampering or reading)
The OTP physical storage area supports storing 6 sets of keys, which need to be burned through the efuse command.
Engine Type |
Security |
Key Index |
OTP Key |
|---|---|---|---|
AES |
Secure |
0 |
S_IPSEC_Key1 |
AES |
Secure |
1 |
S_IPSEC_Key2 |
AES |
Secure |
2 |
RSIP_AES_Key1 |
AES |
Secure |
3 |
RSIP_AES_Key2 |
AES |
Non-secure |
0 |
NS_IPSEC_Key1 |
AES |
Non-secure |
1 |
NS_IPSEC_Key2 |
AES |
Non-secure |
2 |
RSIP_AES_Key1 |
AES |
Non-secure |
3 |
RSIP_AES_Key2 |
The detailed functions of OTP keys are shown below:
OTP Key Name |
Address |
Size bits |
Default Value |
Description |
|---|---|---|---|---|
S_IPSEC_Key1 (RDP) |
Logical map 0x200 |
256 |
0xFF |
When OTPKey_init function is enabled, the secure encryption engine will automatically load this key for HMAC or AES algorithm |
S_IPSEC_Key2 (Secure boot HMAC) |
Logical map 0x220 |
256 |
0xFF |
|
RSIP_AES_Key1 |
Logical map 0x2c0 |
256 |
0xFF |
When OTPKey_init function is enabled, non-secure AES engine and secure AES engine will automatically load this key for AES algorithm |
RSIP_AES_Key2 |
Logical map 0x2e0 |
256 |
0xFF |
|
S_IPSEC_Key1_Read_Protection |
Physical map 0x365[3] |
1 |
1 |
0: Enable S_IPSEC_Key1 read protection, prohibit key from being read 1: Disable S_IPSEC_Key1 read protection |
S_IPSEC_Key1_Write_Protection |
Physical map 0x365[4] |
1 |
1 |
0: Enable S_IPSEC_Key1 write protection, prohibit key from being written to all 0s by hackers 1: Disable S_IPSEC_Key1 write protection |
S_IPSEC_Key2_Read_Protection |
Physical map 0x365[5] |
1 |
1 |
0: Enable S_IPSEC_Key2 read protection, prohibit key from being read 1: Disable S_IPSEC_Key2 read protection |
S_IPSEC_Key2_Write_Protection |
Physical map 0x365[6] |
1 |
1 |
0: Enable S_IPSEC_Key2 write protection, prohibit key from being written to all 0s by hackers 1: Disable S_IPSEC_Key2 write protection |
RSIP_AES_Key1_Read_Protection |
Physical map 0x366[7] |
1 |
1 |
0: Enable RSIP_AES_Key1 read protection, prohibit key from being read 1: Disable RSIP_AES_Key1 read protection |
RSIP_AES_Key1_Write_Protection |
Physical map 0x367[0] |
1 |
1 |
0: Enable RSIP_AES_Key1 write protection, prohibit key from being written to all 0s by hackers 1: Disable RSIP_AES_Key1 write protection |
RSIP_AES_Key2_Read_Protection |
Physical map 0x367[1] |
1 |
1 |
0: Enable RSIP_AES_Key2 read protection, prohibit key from being read 1: Disable RSIP_AES_Key2 read protection |
RSIP_AES_Key2_Write_Protection |
Physical map 0x367[2] |
1 |
1 |
0: Enable RSIP_AES_Key2 write protection, prohibit key from being written to all 0s by hackers 1: Disable RSIP_AES_Key2 write protection |
The hardware encryption engine provides two key loading methods:
Software transfer: Keys are dynamically passed in by the application (software accessible)
OTP automatic loading: Keys are pre-burned into the OTP physical storage area (not accessible by software, only accessible by the encryption engine, preventing tampering or reading)
The OTP physical storage area supports storing 6 sets of keys, which need to be burned through the efuse command.
Engine Type |
Security |
Key Index |
OTP Key |
|---|---|---|---|
AES |
Secure |
0 |
S_IPSEC_Key1 |
AES |
Secure |
1 |
S_IPSEC_Key2 |
AES |
Secure |
2 |
RSIP_AES_Key1 |
AES |
Secure |
3 |
RSIP_AES_Key2 |
AES |
Non-secure |
0 |
NS_IPSEC_Key1 |
AES |
Non-secure |
1 |
NS_IPSEC_Key2 |
AES |
Non-secure |
2 |
RSIP_AES_Key1 |
AES |
Non-secure |
3 |
RSIP_AES_Key2 |
The detailed functions of OTP keys are shown below:
OTP Key Name |
Address |
Size bits |
Default Value |
Description |
|---|---|---|---|---|
S_IPSEC_Key1 (RDP) |
Logical map 0x200 |
256 |
0xFF |
When OTPKey_init function is enabled, the secure encryption engine will automatically load this key for HMAC or AES algorithm |
S_IPSEC_Key2 (Secure boot HMAC) |
Logical map 0x220 |
256 |
0xFF |
|
RSIP_AES_Key1 |
Logical map 0x2c0 |
256 |
0xFF |
When OTPKey_init function is enabled, non-secure AES engine and secure AES engine will automatically load this key for AES algorithm |
RSIP_AES_Key2 |
Logical map 0x2e0 |
256 |
0xFF |
|
S_IPSEC_Key1_Read_Protection |
Physical map 0x365[3] |
1 |
1 |
0: Enable S_IPSEC_Key1 read protection, prohibit key from being read 1: Disable S_IPSEC_Key1 read protection |
S_IPSEC_Key1_Write_Protection |
Physical map 0x365[4] |
1 |
1 |
0: Enable S_IPSEC_Key1 write protection, prohibit key from being written to all 0s by hackers 1: Disable S_IPSEC_Key1 write protection |
S_IPSEC_Key2_Read_Protection |
Physical map 0x365[5] |
1 |
1 |
0: Enable S_IPSEC_Key2 read protection, prohibit key from being read 1: Disable S_IPSEC_Key2 read protection |
S_IPSEC_Key2_Write_Protection |
Physical map 0x365[6] |
1 |
1 |
0: Enable S_IPSEC_Key2 write protection, prohibit key from being written to all 0s by hackers 1: Disable S_IPSEC_Key2 write protection |
RSIP_AES_Key1_Read_Protection |
Physical map 0x366[7] |
1 |
1 |
0: Enable RSIP_AES_Key1 read protection, prohibit key from being read 1: Disable RSIP_AES_Key1 read protection |
RSIP_AES_Key1_Write_Protection |
Physical map 0x367[0] |
1 |
1 |
0: Enable RSIP_AES_Key1 write protection, prohibit key from being written to all 0s by hackers 1: Disable RSIP_AES_Key1 write protection |
RSIP_AES_Key2_Read_Protection |
Physical map 0x367[1] |
1 |
1 |
0: Enable RSIP_AES_Key2 read protection, prohibit key from being read 1: Disable RSIP_AES_Key2 read protection |
RSIP_AES_Key2_Write_Protection |
Physical map 0x367[2] |
1 |
1 |
0: Enable RSIP_AES_Key2 write protection, prohibit key from being written to all 0s by hackers 1: Disable RSIP_AES_Key2 write protection |
The hardware encryption engine provides two key loading methods:
Software transfer: Keys are dynamically passed in by the application (software accessible)
OTP automatic loading: Keys are pre-burned into the OTP physical storage area (not accessible by software, only accessible by the encryption engine, preventing tampering or reading)
The OTP physical storage area supports storing 6 sets of keys, which need to be burned through the efuse command.
Engine Type |
Security |
Key Index |
OTP Key |
|---|---|---|---|
AES |
Secure |
0 |
S_IPSEC_Key1 |
AES |
Secure |
1 |
S_IPSEC_Key2 |
AES |
Secure |
2 |
RSIP_AES_Key1 |
AES |
Secure |
3 |
RSIP_AES_Key2 |
AES |
Non-secure |
0 |
NS_IPSEC_Key1 |
AES |
Non-secure |
1 |
NS_IPSEC_Key2 |
AES |
Non-secure |
2 |
RSIP_AES_Key1 |
AES |
Non-secure |
3 |
RSIP_AES_Key2 |
The detailed functions of OTP keys are shown below:
OTP Key Name |
Address |
Size bits |
Default Value |
Description |
|---|---|---|---|---|
S_IPSEC_Key1 (RDP) |
Logical map 0x200 |
256 |
0xFF |
When OTPKey_init function is enabled, the secure encryption engine will automatically load this key for HMAC or AES algorithm |
S_IPSEC_Key2 (Secure boot HMAC) |
Logical map 0x220 |
256 |
0xFF |
|
RSIP_AES_Key1 |
Logical map 0x2c0 |
256 |
0xFF |
When OTPKey_init function is enabled, non-secure AES engine and secure AES engine will automatically load this key for AES algorithm |
RSIP_AES_Key2 |
Logical map 0x2e0 |
256 |
0xFF |
|
S_IPSEC_Key1_Read_Protection |
Physical map 0x365[3] |
1 |
1 |
0: Enable S_IPSEC_Key1 read protection, prohibit key from being read 1: Disable S_IPSEC_Key1 read protection |
S_IPSEC_Key1_Write_Protection |
Physical map 0x365[4] |
1 |
1 |
0: Enable S_IPSEC_Key1 write protection, prohibit key from being written to all 0s by hackers 1: Disable S_IPSEC_Key1 write protection |
S_IPSEC_Key2_Read_Protection |
Physical map 0x365[5] |
1 |
1 |
0: Enable S_IPSEC_Key2 read protection, prohibit key from being read 1: Disable S_IPSEC_Key2 read protection |
S_IPSEC_Key2_Write_Protection |
Physical map 0x365[6] |
1 |
1 |
0: Enable S_IPSEC_Key2 write protection, prohibit key from being written to all 0s by hackers 1: Disable S_IPSEC_Key2 write protection |
RSIP_AES_Key1_Read_Protection |
Physical map 0x366[7] |
1 |
1 |
0: Enable RSIP_AES_Key1 read protection, prohibit key from being read 1: Disable RSIP_AES_Key1 read protection |
RSIP_AES_Key1_Write_Protection |
Physical map 0x367[0] |
1 |
1 |
0: Enable RSIP_AES_Key1 write protection, prohibit key from being written to all 0s by hackers 1: Disable RSIP_AES_Key1 write protection |
RSIP_AES_Key2_Read_Protection |
Physical map 0x367[1] |
1 |
1 |
0: Enable RSIP_AES_Key2 read protection, prohibit key from being read 1: Disable RSIP_AES_Key2 read protection |
RSIP_AES_Key2_Write_Protection |
Physical map 0x367[2] |
1 |
1 |
0: Enable RSIP_AES_Key2 write protection, prohibit key from being written to all 0s by hackers 1: Disable RSIP_AES_Key2 write protection |
The hardware encryption engine provides two key loading methods:
Software transfer: Keys are dynamically passed in by the application (software accessible)
OTP automatic loading: Keys are pre-burned into the OTP physical storage area (not accessible by software, only accessible by the encryption engine, preventing tampering or reading)
The OTP physical storage area supports storing 6 sets of keys, which need to be burned through the efuse command.
Engine Type |
Security |
Key Index |
OTP Key |
|---|---|---|---|
AES |
Secure |
0 |
S_IPSEC_Key1 |
AES |
Secure |
1 |
S_IPSEC_Key2 |
AES |
Secure |
2 |
RSIP_AES_Key1 |
AES |
Secure |
3 |
RSIP_AES_Key2 |
AES |
Non-secure |
0 |
NS_IPSEC_Key1 |
AES |
Non-secure |
1 |
NS_IPSEC_Key2 |
AES |
Non-secure |
2 |
RSIP_AES_Key1 |
AES |
Non-secure |
3 |
RSIP_AES_Key2 |
The detailed functions of OTP keys are shown below:
OTP Key Name |
Address |
Size bits |
Default Value |
Description |
|---|---|---|---|---|
S_IPSEC_Key1 (RDP) |
Logical map 0x200 |
256 |
0xFF |
When OTPKey_init function is enabled, the secure encryption engine will automatically load this key for HMAC or AES algorithm |
S_IPSEC_Key2 (Secure boot HMAC) |
Logical map 0x220 |
256 |
0xFF |
|
RSIP_AES_Key1 |
Logical map 0x2c0 |
256 |
0xFF |
When OTPKey_init function is enabled, non-secure AES engine and secure AES engine will automatically load this key for AES algorithm |
RSIP_AES_Key2 |
Logical map 0x2e0 |
256 |
0xFF |
|
S_IPSEC_Key1_Read_Protection |
Physical map 0x365[3] |
1 |
1 |
0: Enable S_IPSEC_Key1 read protection, prohibit key from being read 1: Disable S_IPSEC_Key1 read protection |
S_IPSEC_Key1_Write_Protection |
Physical map 0x365[4] |
1 |
1 |
0: Enable S_IPSEC_Key1 write protection, prohibit key from being written to all 0s by hackers 1: Disable S_IPSEC_Key1 write protection |
S_IPSEC_Key2_Read_Protection |
Physical map 0x365[5] |
1 |
1 |
0: Enable S_IPSEC_Key2 read protection, prohibit key from being read 1: Disable S_IPSEC_Key2 read protection |
S_IPSEC_Key2_Write_Protection |
Physical map 0x365[6] |
1 |
1 |
0: Enable S_IPSEC_Key2 write protection, prohibit key from being written to all 0s by hackers 1: Disable S_IPSEC_Key2 write protection |
RSIP_AES_Key1_Read_Protection |
Physical map 0x366[7] |
1 |
1 |
0: Enable RSIP_AES_Key1 read protection, prohibit key from being read 1: Disable RSIP_AES_Key1 read protection |
RSIP_AES_Key1_Write_Protection |
Physical map 0x367[0] |
1 |
1 |
0: Enable RSIP_AES_Key1 write protection, prohibit key from being written to all 0s by hackers 1: Disable RSIP_AES_Key1 write protection |
RSIP_AES_Key2_Read_Protection |
Physical map 0x367[1] |
1 |
1 |
0: Enable RSIP_AES_Key2 read protection, prohibit key from being read 1: Disable RSIP_AES_Key2 read protection |
RSIP_AES_Key2_Write_Protection |
Physical map 0x367[2] |
1 |
1 |
0: Enable RSIP_AES_Key2 write protection, prohibit key from being written to all 0s by hackers 1: Disable RSIP_AES_Key2 write protection |
The hardware encryption engine provides two key loading methods:
Software transfer: Keys are dynamically passed in by the application (software accessible)
OTP automatic loading: Keys are pre-burned into the OTP physical storage area (not accessible by software, only accessible by the encryption engine, preventing tampering or reading)
The OTP physical storage area supports storing 6 sets of keys, which need to be burned through the efuse command.
Engine Type |
Security |
Key Index |
OTP Key |
|---|---|---|---|
AES |
Secure |
0 |
S_IPSEC_Key1 |
AES |
Secure |
1 |
S_IPSEC_Key2 |
AES |
Secure |
2 |
RSIP_AES_Key1 |
AES |
Secure |
3 |
RSIP_AES_Key2 |
AES |
Non-secure |
0 |
NS_IPSEC_Key1 |
AES |
Non-secure |
1 |
NS_IPSEC_Key2 |
AES |
Non-secure |
2 |
RSIP_AES_Key1 |
AES |
Non-secure |
3 |
RSIP_AES_Key2 |
The detailed functions of OTP keys are shown below:
OTP Key Name |
Address |
Size bits |
Default Value |
Description |
|---|---|---|---|---|
S_IPSEC_Key1 (RDP) |
Logical map 0x200 |
256 |
0xFF |
When OTPKey_init function is enabled, the secure encryption engine will automatically load this key for HMAC or AES algorithm |
S_IPSEC_Key2 (Secure boot HMAC) |
Logical map 0x220 |
256 |
0xFF |
|
RSIP_AES_Key1 |
Logical map 0x2c0 |
256 |
0xFF |
When OTPKey_init function is enabled, non-secure AES engine and secure AES engine will automatically load this key for AES algorithm |
RSIP_AES_Key2 |
Logical map 0x2e0 |
256 |
0xFF |
|
S_IPSEC_Key1_Read_Protection |
Physical map 0x365[3] |
1 |
1 |
0: Enable S_IPSEC_Key1 read protection, prohibit key from being read 1: Disable S_IPSEC_Key1 read protection |
S_IPSEC_Key1_Write_Protection |
Physical map 0x365[4] |
1 |
1 |
0: Enable S_IPSEC_Key1 write protection, prohibit key from being written to all 0s by hackers 1: Disable S_IPSEC_Key1 write protection |
S_IPSEC_Key2_Read_Protection |
Physical map 0x365[5] |
1 |
1 |
0: Enable S_IPSEC_Key2 read protection, prohibit key from being read 1: Disable S_IPSEC_Key2 read protection |
S_IPSEC_Key2_Write_Protection |
Physical map 0x365[6] |
1 |
1 |
0: Enable S_IPSEC_Key2 write protection, prohibit key from being written to all 0s by hackers 1: Disable S_IPSEC_Key2 write protection |
RSIP_AES_Key1_Read_Protection |
Physical map 0x366[7] |
1 |
1 |
0: Enable RSIP_AES_Key1 read protection, prohibit key from being read 1: Disable RSIP_AES_Key1 read protection |
RSIP_AES_Key1_Write_Protection |
Physical map 0x367[0] |
1 |
1 |
0: Enable RSIP_AES_Key1 write protection, prohibit key from being written to all 0s by hackers 1: Disable RSIP_AES_Key1 write protection |
RSIP_AES_Key2_Read_Protection |
Physical map 0x367[1] |
1 |
1 |
0: Enable RSIP_AES_Key2 read protection, prohibit key from being read 1: Disable RSIP_AES_Key2 read protection |
RSIP_AES_Key2_Write_Protection |
Physical map 0x367[2] |
1 |
1 |
0: Enable RSIP_AES_Key2 write protection, prohibit key from being written to all 0s by hackers 1: Disable RSIP_AES_Key2 write protection |
Six Secure OTP Keys: After OTP key programming, read/write protection can be enabled. Once protection is enabled, software cannot read/write the keys only hardware can use them. By default, these OTP keys are only accessible in Secure state. To use a Secure OTP key in Non-Secure state, first call the crypto_aes_share_secure_key API in Secure state to modify the key’s usage permissions.
Two Secure Software Keys: Register keys can be freely configured via software. These Secure Software Keys can only be read/written in Secure state; Non-Secure state cannot access the key registers. By default, Secure Software Keys are only usable in Secure state. To configure keys in Secure CPU and use them in Non-Secure state, first set the corresponding key share register bits in Secure state. Note: AES-XTS mode requires simultaneous use of two keys.
Two Non-Secure Software Keys: Can be read, written, and used in either Secure or Non-Secure state.
AES Key ID |
Key Type |
Length (bits) |
OTP Addr |
Key Usage Permission |
Shared IP |
|---|---|---|---|---|---|
0 |
OTP |
256 |
0x200 |
Secure (default) / Non-Secure |
Shared with HMAC |
1 |
OTP |
256 |
0x220 |
Secure (default) / Non-Secure |
Shared with HMAC |
2 |
OTP |
256 |
0x240 |
Secure (default) / Non-Secure |
Shared with HMAC |
3 |
OTP |
256 |
0x260 |
Secure (default) / Non-Secure |
Shared with HMAC |
4 |
OTP |
256 |
0x2C0 |
Secure (default) / Non-Secure |
Shared with RSIP |
5 |
OTP |
256 |
0x2E0 |
Secure (default) / Non-Secure |
Shared with RSIP |
33 |
Register |
256 |
N/A |
Secure (default) / Non-Secure |
AES only |
34 |
Register |
256 |
N/A |
Secure (default) / Non-Secure |
AES only |
35 |
Register |
256 |
N/A |
Non-Secure |
AES only |
36 |
Register |
256 |
N/A |
Non-Secure |
AES only |
AES Engine Security
The AES architecture achieves efficient encryption processing while ensuring security through hardware-level isolation and intelligent arbitration:
Two independent register sets:
Secure address space: 0x5XXX_XXXX, mapped to secure-dedicated registers
Non-secure address space: 0x4XXX_XXXX, mapped to non-secure-dedicated registers
Arbitration mechanism when both secure and non-secure domains request the encryption engine simultaneously:
Basic policy: Round-robin scheduling + FIFO status priority (full FIFO has priority)
Atomicity guarantee: Must complete an entire round of encryption operation (LS=1) before switching engine control
Interrupt mechanism:
Physical isolation design: Secure and non-secure interrupts are connected to different interrupt numbers
Error isolation reporting: Bus errors trigger both interrupts simultaneously, but need to be cleared independently
Special setting: Interrupt security attributes only support automatic hardware switching
The AES architecture achieves efficient encryption processing while ensuring security through hardware-level isolation and intelligent arbitration:
Two independent register sets:
Secure address space: 0x5XXX_XXXX, mapped to secure-dedicated registers
Non-secure address space: 0x4XXX_XXXX, mapped to non-secure-dedicated registers
Arbitration mechanism when both secure and non-secure domains request the encryption engine simultaneously:
Basic policy: Round-robin scheduling + FIFO status priority (full FIFO has priority)
Atomicity guarantee: Must complete an entire round of encryption operation (LS=1) before switching engine control
Interrupt mechanism:
Physical isolation design: Secure and non-secure interrupts are connected to different interrupt numbers
Error isolation reporting: Bus errors trigger both interrupts simultaneously, but need to be cleared independently
Special setting: Interrupt security attributes only support automatic hardware switching
The AES architecture achieves efficient encryption processing while ensuring security through hardware-level isolation and intelligent arbitration:
Two independent register sets:
Secure address space: 0x5XXX_XXXX, mapped to secure-dedicated registers
Non-secure address space: 0x4XXX_XXXX, mapped to non-secure-dedicated registers
Arbitration mechanism when both secure and non-secure domains request the encryption engine simultaneously:
Basic policy: Round-robin scheduling + FIFO status priority (full FIFO has priority)
Atomicity guarantee: Must complete an entire round of encryption operation (LS=1) before switching engine control
Interrupt mechanism:
Physical isolation design: Secure and non-secure interrupts are connected to different interrupt numbers
Error isolation reporting: Bus errors trigger both interrupts simultaneously, but need to be cleared independently
Special setting: Interrupt security attributes only support automatic hardware switching
The AES architecture achieves efficient encryption processing while ensuring security through hardware-level isolation and intelligent arbitration:
Two independent register sets:
Secure address space: 0x5XXX_XXXX, mapped to secure-dedicated registers
Non-secure address space: 0x4XXX_XXXX, mapped to non-secure-dedicated registers
Arbitration mechanism when both secure and non-secure domains request the encryption engine simultaneously:
Basic policy: Round-robin scheduling + FIFO status priority (full FIFO has priority)
Atomicity guarantee: Must complete an entire round of encryption operation (LS=1) before switching engine control
Interrupt mechanism:
Physical isolation design: Secure and non-secure interrupts are connected to different interrupt numbers
Error isolation reporting: Bus errors trigger both interrupts simultaneously, but need to be cleared independently
Special setting: Interrupt security attributes only support automatic hardware switching
The AES architecture achieves efficient encryption processing while ensuring security through hardware-level isolation and intelligent arbitration:
Two independent register sets:
Secure address space: 0x5XXX_XXXX, mapped to secure-dedicated registers
Non-secure address space: 0x4XXX_XXXX, mapped to non-secure-dedicated registers
Arbitration mechanism when both secure and non-secure domains request the encryption engine simultaneously:
Basic policy: Round-robin scheduling + FIFO status priority (full FIFO has priority)
Atomicity guarantee: Must complete an entire round of encryption operation (LS=1) before switching engine control
Interrupt mechanism:
Physical isolation design: Secure and non-secure interrupts are connected to different interrupt numbers
Error isolation reporting: Bus errors trigger both interrupts simultaneously, but need to be cleared independently
Special setting: Interrupt security attributes only support automatic hardware switching
The AES architecture achieves efficient encryption processing while ensuring security through hardware-level isolation and intelligent arbitration:
Two independent register sets:
Secure address space: 0x5XXX_XXXX, mapped to secure-dedicated registers
Non-secure address space: 0x4XXX_XXXX, mapped to non-secure-dedicated registers
Arbitration mechanism when both secure and non-secure domains request the encryption engine simultaneously:
Basic policy: Round-robin scheduling + FIFO status priority (full FIFO has priority)
Atomicity guarantee: Must complete an entire round of encryption operation (LS=1) before switching engine control
Interrupt mechanism:
Physical isolation design: Secure and non-secure interrupts are connected to different interrupt numbers
Error isolation reporting: Bus errors trigger both interrupts simultaneously, but need to be cleared independently
Special setting: Interrupt security attributes only support automatic hardware switching
The AES crypto engine supports TrustZone technology and can automatically identify whether the CPU access is in Secure or Non-secure state. It incorporates a hardware mutex lock mechanism, meaning the CPU must first obtain this mutex lock before each operation; otherwise, it cannot access the hardware registers.
When the Secure CPU holds the lock, all Non-secure access is blocked. Only after the Secure CPU releases the lock can the Non-secure CPU regain access. Conversely, if a Non-secure CPU holds the lock, the Secure CPU can configure a dedicated preemption register to forcibly release the Non-secure lock and reset the engine, thereby immediately gaining control of the engine.
Additionally, each time the lock is released, the engine automatically clears sensitive information from the hardware and register states, ensuring no information leakage occurs.
During the computation process, the AES engine uses masking, redundant operations, and randomization to prevent side-channel attacks:
Masking: Protects the encryption process by randomizing intermediate calculation values, making it difficult for side-channel attacks to directly obtain useful information, such as signals generated by power consumption or electromagnetic radiation. The mask is randomly generated by TRNG at each AES initialization.
Redundant operations: Inserts additional or irrelevant operations during the encryption or decryption process to confuse attackers, making it difficult to analyze the execution flow of AES. These operations do not alter the result but increase noise in the side-channel signals.
Randomization: Scrambles the operation or data processing sequence to make the execution process unpredictable. This ensures that no fixed patterns develop over time that could be exploited by attackers to develop effective attack strategies.
AES Engine Usage Modes
DMA Mode
The AES engine uses DMA to move data between memory and fifo, and encrypts/decrypts data during the transfer process. DMA mode has high encryption/decryption efficiency for large amounts of data. However, DMA mode requires that the address and length of the data are aligned to the cache line length (32 bytes), otherwise there will be cache line data mismatch issues. If the address and length are not aligned, the serial port log will print a warning message. The driver has already handled the cache clean operation for the source address and cache invalidate operation for the destination address, so users do not need to clean the cache again outside the API.
DMA Mode
The AES engine uses DMA to move data between memory and fifo, and encrypts/decrypts data during the transfer process. DMA mode has high encryption/decryption efficiency for large amounts of data. However, DMA mode requires that the address and length of the data are aligned to the cache line length (32 bytes), otherwise there will be cache line data mismatch issues. If the address and length are not aligned, the serial port log will print a warning message. The driver has already handled the cache clean operation for the source address and cache invalidate operation for the destination address, so users do not need to clean the cache again outside the API.
DMA Mode
The AES engine uses DMA to move data between memory and fifo, and encrypts/decrypts data during the transfer process. DMA mode has high encryption/decryption efficiency for large amounts of data. However, DMA mode requires that the address and length of the data are aligned to the cache line length (32 bytes), otherwise there will be cache line data mismatch issues. If the address and length are not aligned, the serial port log will print a warning message. The driver has already handled the cache clean operation for the source address and cache invalidate operation for the destination address, so users do not need to clean the cache again outside the API.
DMA Mode
The AES engine uses DMA to move data between memory and fifo, and encrypts/decrypts data during the transfer process. DMA mode has high encryption/decryption efficiency for large amounts of data. However, DMA mode requires that the address and length of the data are aligned to the cache line length (32 bytes), otherwise there will be cache line data mismatch issues. If the address and length are not aligned, the serial port log will print a warning message. The driver has already handled the cache clean operation for the source address and cache invalidate operation for the destination address, so users do not need to clean the cache again outside the API.
DMA Mode
The AES engine uses DMA to move data between memory and fifo, and encrypts/decrypts data during the transfer process. DMA mode has high encryption/decryption efficiency for large amounts of data. However, DMA mode requires that the address and length of the data are aligned to the cache line length (32 bytes), otherwise there will be cache line data mismatch issues. If the address and length are not aligned, the serial port log will print a warning message. The driver has already handled the cache clean operation for the source address and cache invalidate operation for the destination address, so users do not need to clean the cache again outside the API.
DMA Mode
The AES engine uses DMA to move data between memory and fifo, and encrypts/decrypts data during the transfer process. DMA mode has high encryption/decryption efficiency for large amounts of data. However, DMA mode requires that the address and length of the data are aligned to the cache line length (32 bytes), otherwise there will be cache line data mismatch issues. If the address and length are not aligned, the serial port log will print a warning message. The driver has already handled the cache clean operation for the source address and cache invalidate operation for the destination address, so users do not need to clean the cache again outside the API.
AES engine supports two operation modes: DMA mode and Slave mode. Both modes can use Software key or OTP key.
DMA Mode
The AES engine uses channel 0 of the engine’s internal DMA controller. It uses DMA to move data between memory locations and encrypts/decrypts data during the transfer process. DMA mode has high encryption/decryption efficiency for large amounts of data. However, DMA mode requires that the address and length of the data are aligned to the cache line length (32 bytes), otherwise there will be cache line data mismatch issues. If the address and length are not aligned, the serial port log will print a warning message. The driver has already handled the cache clean operation for the source address and cache invalidate operation for the destination address, so users do not need to clean the cache again outside the API.
Slave Mode
The CPU writes data to the AES engine through the APB bus to encrypt or decrypt data. This mode is suitable for 16-byte AES operations and has no restrictions on address or message length alignment. It can be used in combination with other modes to support more encryption or message authentication code algorithms.
AES API
Realtek provides ROM APIs, eliminating the need for users to manage specific register operations and processes. For enhanced applicability, the AES hardware acceleration engine has been integrated into MbedTLS. Due to hardware/software limitations, Realtek has not implemented hardware acceleration for MbedTLS’s CMAC/AES-GCM algorithms. Users can directly invoke ROM APIs during CMAC/AES-GCM operations for superior performance. Note that MbedTLS APIs only support software keys; ROM APIs must be used when employing OTP keys.
HMAC Engine
The HMAC engine is a hardware accelerator for computing HMAC and SHA2, supporting automatic message padding. The HMAC algorithm supports both software register keys and hardware OTP keys.
HMAC Algorithm Support
General Hash Functions:
SHA2-224
SHA2-256
SHA2-384
SHA2-512
HMAC (Hash-based Message Authentication Code):
HMAC_SHA2-224
HMAC_SHA2-256
HMAC_SHA2-384
HMAC_SHA2-512
HMAC Keys
The HMAC engine features an independent key management unit supporting both software keys and hardware OTP keys.
The hardware encryption engine provides two key loading methods:
Software transfer: Keys are dynamically passed in by the application (software accessible)
OTP automatic loading: Keys are pre-burned into the OTP physical storage area (not accessible by software, only accessible by the encryption engine, preventing tampering or reading)
The OTP physical storage area supports storing 6 sets of keys, which need to be burned through the efuse command.
Engine Type |
Security |
Key Index |
OTP Key |
|---|---|---|---|
SHA HMAC |
Secure |
0 |
S_IPSEC_Key1 |
SHA HMAC |
Secure |
1 |
S_IPSEC_Key2 |
SHA HMAC |
Non-secure |
0 |
NS_IPSEC_Key1 |
SHA HMAC |
Non-secure |
1 |
NS_IPSEC_Key2 |
The detailed functions of OTP keys are shown below:
OTP Key Name |
Address |
Size bits |
Default Value |
Description |
|---|---|---|---|---|
S_IPSEC_Key1 (RDP) |
Logical map 0x200 |
256 |
0xFF |
When OTPKey_init function is enabled, the secure encryption engine will automatically load this key for HMAC or AES algorithm |
S_IPSEC_Key2 (Secure boot HMAC) |
Logical map 0x220 |
256 |
0xFF |
|
NS_IPSEC_Key1 |
Logical map 0x240 |
256 |
0xFF |
When OTPKey_init function is enabled, the non-secure encryption engine will automatically load this key for HMAC algorithm |
NS_IPSEC_Key2 |
Logical map 0x260 |
256 |
0xFF |
|
S_IPSEC_Key1_Read_Protection |
Physical map 0x365[3] |
1 |
1 |
0: Enable S_IPSEC_Key1 read protection, prohibit key from being read 1: Disable S_IPSEC_Key1 read protection |
S_IPSEC_Key1_Write_Protection |
Physical map 0x365[4] |
1 |
1 |
0: Enable S_IPSEC_Key1 write protection, prohibit key from being written to all 0s by hackers 1: Disable S_IPSEC_Key1 write protection |
S_IPSEC_Key2_Read_Protection |
Physical map 0x365[5] |
1 |
1 |
0: Enable S_IPSEC_Key2 read protection, prohibit key from being read 1: Disable S_IPSEC_Key2 read protection |
S_IPSEC_Key2_Write_Protection |
Physical map 0x365[6] |
1 |
1 |
0: Enable S_IPSEC_Key2 write protection, prohibit key from being written to all 0s by hackers 1: Disable S_IPSEC_Key2 write protection |
NS_IPSEC_Key1_Read_Protection |
Physical map 0x365[7] |
1 |
1 |
0: Enable NS_IPSEC_Key1 read protection, prohibit key from being read 1: Disable NS_IPSEC_Key1 read protection |
NS_IPSEC_Key1_Write_Protection |
Physical map 0x366[0] |
1 |
1 |
0: Enable NS_IPSEC_Key1 write protection, prohibit key from being written to all 0s by hackers 1: Disable NS_IPSEC_Key1 write protection |
NS_IPSEC_Key2_Read_Protection |
Physical map 0x366[1] |
1 |
1 |
0: Enable NS_IPSEC_Key2 read protection, prohibit key from being read 1: Disable NS_IPSEC_Key2 read protection |
NS_IPSEC_Key2_Write_Protection |
Physical map 0x366[2] |
1 |
1 |
0: Enable NS_IPSEC_Key2 write protection, prohibit key from being written to all 0s by hackers 1: Disable NS_IPSEC_Key2 write protection |
The hardware encryption engine provides two key loading methods:
Software transfer: Keys are dynamically passed in by the application (software accessible)
OTP automatic loading: Keys are pre-burned into the OTP physical storage area (not accessible by software, only accessible by the encryption engine, preventing tampering or reading)
The OTP physical storage area supports storing 6 sets of keys, which need to be burned through the efuse command.
Engine Type |
Security |
Key Index |
OTP Key |
|---|---|---|---|
SHA HMAC |
Secure |
0 |
S_IPSEC_Key1 |
SHA HMAC |
Secure |
1 |
S_IPSEC_Key2 |
SHA HMAC |
Non-secure |
0 |
NS_IPSEC_Key1 |
SHA HMAC |
Non-secure |
1 |
NS_IPSEC_Key2 |
The detailed functions of OTP keys are shown below:
OTP Key Name |
Address |
Size bits |
Default Value |
Description |
|---|---|---|---|---|
S_IPSEC_Key1 (RDP) |
Logical map 0x200 |
256 |
0xFF |
When OTPKey_init function is enabled, the secure encryption engine will automatically load this key for HMAC or AES algorithm |
S_IPSEC_Key2 (Secure boot HMAC) |
Logical map 0x220 |
256 |
0xFF |
|
NS_IPSEC_Key1 |
Logical map 0x240 |
256 |
0xFF |
When OTPKey_init function is enabled, the non-secure encryption engine will automatically load this key for HMAC algorithm |
NS_IPSEC_Key2 |
Logical map 0x260 |
256 |
0xFF |
|
S_IPSEC_Key1_Read_Protection |
Physical map 0x365[3] |
1 |
1 |
0: Enable S_IPSEC_Key1 read protection, prohibit key from being read 1: Disable S_IPSEC_Key1 read protection |
S_IPSEC_Key1_Write_Protection |
Physical map 0x365[4] |
1 |
1 |
0: Enable S_IPSEC_Key1 write protection, prohibit key from being written to all 0s by hackers 1: Disable S_IPSEC_Key1 write protection |
S_IPSEC_Key2_Read_Protection |
Physical map 0x365[5] |
1 |
1 |
0: Enable S_IPSEC_Key2 read protection, prohibit key from being read 1: Disable S_IPSEC_Key2 read protection |
S_IPSEC_Key2_Write_Protection |
Physical map 0x365[6] |
1 |
1 |
0: Enable S_IPSEC_Key2 write protection, prohibit key from being written to all 0s by hackers 1: Disable S_IPSEC_Key2 write protection |
NS_IPSEC_Key1_Read_Protection |
Physical map 0x365[7] |
1 |
1 |
0: Enable NS_IPSEC_Key1 read protection, prohibit key from being read 1: Disable NS_IPSEC_Key1 read protection |
NS_IPSEC_Key1_Write_Protection |
Physical map 0x366[0] |
1 |
1 |
0: Enable NS_IPSEC_Key1 write protection, prohibit key from being written to all 0s by hackers 1: Disable NS_IPSEC_Key1 write protection |
NS_IPSEC_Key2_Read_Protection |
Physical map 0x366[1] |
1 |
1 |
0: Enable NS_IPSEC_Key2 read protection, prohibit key from being read 1: Disable NS_IPSEC_Key2 read protection |
NS_IPSEC_Key2_Write_Protection |
Physical map 0x366[2] |
1 |
1 |
0: Enable NS_IPSEC_Key2 write protection, prohibit key from being written to all 0s by hackers 1: Disable NS_IPSEC_Key2 write protection |
The hardware encryption engine provides two key loading methods:
Software transfer: Keys are dynamically passed in by the application (software accessible)
OTP automatic loading: Keys are pre-burned into the OTP physical storage area (not accessible by software, only accessible by the encryption engine, preventing tampering or reading)
The OTP physical storage area supports storing 6 sets of keys, which need to be burned through the efuse command.
Engine Type |
Security |
Key Index |
OTP Key |
|---|---|---|---|
SHA HMAC |
Secure |
0 |
S_IPSEC_Key1 |
SHA HMAC |
Secure |
1 |
S_IPSEC_Key2 |
SHA HMAC |
Non-secure |
0 |
NS_IPSEC_Key1 |
SHA HMAC |
Non-secure |
1 |
NS_IPSEC_Key2 |
The detailed functions of OTP keys are shown below:
OTP Key Name |
Address |
Size bits |
Default Value |
Description |
|---|---|---|---|---|
S_IPSEC_Key1 (RDP) |
Logical map 0x200 |
256 |
0xFF |
When OTPKey_init function is enabled, the secure encryption engine will automatically load this key for HMAC or AES algorithm |
S_IPSEC_Key2 (Secure boot HMAC) |
Logical map 0x220 |
256 |
0xFF |
|
NS_IPSEC_Key1 |
Logical map 0x240 |
256 |
0xFF |
When OTPKey_init function is enabled, the non-secure encryption engine will automatically load this key for HMAC algorithm |
NS_IPSEC_Key2 |
Logical map 0x260 |
256 |
0xFF |
|
S_IPSEC_Key1_Read_Protection |
Physical map 0x365[3] |
1 |
1 |
0: Enable S_IPSEC_Key1 read protection, prohibit key from being read 1: Disable S_IPSEC_Key1 read protection |
S_IPSEC_Key1_Write_Protection |
Physical map 0x365[4] |
1 |
1 |
0: Enable S_IPSEC_Key1 write protection, prohibit key from being written to all 0s by hackers 1: Disable S_IPSEC_Key1 write protection |
S_IPSEC_Key2_Read_Protection |
Physical map 0x365[5] |
1 |
1 |
0: Enable S_IPSEC_Key2 read protection, prohibit key from being read 1: Disable S_IPSEC_Key2 read protection |
S_IPSEC_Key2_Write_Protection |
Physical map 0x365[6] |
1 |
1 |
0: Enable S_IPSEC_Key2 write protection, prohibit key from being written to all 0s by hackers 1: Disable S_IPSEC_Key2 write protection |
NS_IPSEC_Key1_Read_Protection |
Physical map 0x365[7] |
1 |
1 |
0: Enable NS_IPSEC_Key1 read protection, prohibit key from being read 1: Disable NS_IPSEC_Key1 read protection |
NS_IPSEC_Key1_Write_Protection |
Physical map 0x366[0] |
1 |
1 |
0: Enable NS_IPSEC_Key1 write protection, prohibit key from being written to all 0s by hackers 1: Disable NS_IPSEC_Key1 write protection |
NS_IPSEC_Key2_Read_Protection |
Physical map 0x366[1] |
1 |
1 |
0: Enable NS_IPSEC_Key2 read protection, prohibit key from being read 1: Disable NS_IPSEC_Key2 read protection |
NS_IPSEC_Key2_Write_Protection |
Physical map 0x366[2] |
1 |
1 |
0: Enable NS_IPSEC_Key2 write protection, prohibit key from being written to all 0s by hackers 1: Disable NS_IPSEC_Key2 write protection |
The hardware encryption engine provides two key loading methods:
Software transfer: Keys are dynamically passed in by the application (software accessible)
OTP automatic loading: Keys are pre-burned into the OTP physical storage area (not accessible by software, only accessible by the encryption engine, preventing tampering or reading)
The OTP physical storage area supports storing 6 sets of keys, which need to be burned through the efuse command.
Engine Type |
Security |
Key Index |
OTP Key |
|---|---|---|---|
SHA HMAC |
Secure |
0 |
S_IPSEC_Key1 |
SHA HMAC |
Secure |
1 |
S_IPSEC_Key2 |
SHA HMAC |
Non-secure |
0 |
NS_IPSEC_Key1 |
SHA HMAC |
Non-secure |
1 |
NS_IPSEC_Key2 |
The detailed functions of OTP keys are shown below:
OTP Key Name |
Address |
Size bits |
Default Value |
Description |
|---|---|---|---|---|
S_IPSEC_Key1 (RDP) |
Logical map 0x200 |
256 |
0xFF |
When OTPKey_init function is enabled, the secure encryption engine will automatically load this key for HMAC or AES algorithm |
S_IPSEC_Key2 (Secure boot HMAC) |
Logical map 0x220 |
256 |
0xFF |
|
NS_IPSEC_Key1 |
Logical map 0x240 |
256 |
0xFF |
When OTPKey_init function is enabled, the non-secure encryption engine will automatically load this key for HMAC algorithm |
NS_IPSEC_Key2 |
Logical map 0x260 |
256 |
0xFF |
|
S_IPSEC_Key1_Read_Protection |
Physical map 0x365[3] |
1 |
1 |
0: Enable S_IPSEC_Key1 read protection, prohibit key from being read 1: Disable S_IPSEC_Key1 read protection |
S_IPSEC_Key1_Write_Protection |
Physical map 0x365[4] |
1 |
1 |
0: Enable S_IPSEC_Key1 write protection, prohibit key from being written to all 0s by hackers 1: Disable S_IPSEC_Key1 write protection |
S_IPSEC_Key2_Read_Protection |
Physical map 0x365[5] |
1 |
1 |
0: Enable S_IPSEC_Key2 read protection, prohibit key from being read 1: Disable S_IPSEC_Key2 read protection |
S_IPSEC_Key2_Write_Protection |
Physical map 0x365[6] |
1 |
1 |
0: Enable S_IPSEC_Key2 write protection, prohibit key from being written to all 0s by hackers 1: Disable S_IPSEC_Key2 write protection |
NS_IPSEC_Key1_Read_Protection |
Physical map 0x365[7] |
1 |
1 |
0: Enable NS_IPSEC_Key1 read protection, prohibit key from being read 1: Disable NS_IPSEC_Key1 read protection |
NS_IPSEC_Key1_Write_Protection |
Physical map 0x366[0] |
1 |
1 |
0: Enable NS_IPSEC_Key1 write protection, prohibit key from being written to all 0s by hackers 1: Disable NS_IPSEC_Key1 write protection |
NS_IPSEC_Key2_Read_Protection |
Physical map 0x366[1] |
1 |
1 |
0: Enable NS_IPSEC_Key2 read protection, prohibit key from being read 1: Disable NS_IPSEC_Key2 read protection |
NS_IPSEC_Key2_Write_Protection |
Physical map 0x366[2] |
1 |
1 |
0: Enable NS_IPSEC_Key2 write protection, prohibit key from being written to all 0s by hackers 1: Disable NS_IPSEC_Key2 write protection |
The hardware encryption engine provides two key loading methods:
Software transfer: Keys are dynamically passed in by the application (software accessible)
OTP automatic loading: Keys are pre-burned into the OTP physical storage area (not accessible by software, only accessible by the encryption engine, preventing tampering or reading)
The OTP physical storage area supports storing 6 sets of keys, which need to be burned through the efuse command.
Engine Type |
Security |
Key Index |
OTP Key |
|---|---|---|---|
SHA HMAC |
Secure |
0 |
S_IPSEC_Key1 |
SHA HMAC |
Secure |
1 |
S_IPSEC_Key2 |
SHA HMAC |
Non-secure |
0 |
NS_IPSEC_Key1 |
SHA HMAC |
Non-secure |
1 |
NS_IPSEC_Key2 |
The detailed functions of OTP keys are shown below:
OTP Key Name |
Address |
Size bits |
Default Value |
Description |
|---|---|---|---|---|
S_IPSEC_Key1 (RDP) |
Logical map 0x200 |
256 |
0xFF |
When OTPKey_init function is enabled, the secure encryption engine will automatically load this key for HMAC or AES algorithm |
S_IPSEC_Key2 (Secure boot HMAC) |
Logical map 0x220 |
256 |
0xFF |
|
NS_IPSEC_Key1 |
Logical map 0x240 |
256 |
0xFF |
When OTPKey_init function is enabled, the non-secure encryption engine will automatically load this key for HMAC algorithm |
NS_IPSEC_Key2 |
Logical map 0x260 |
256 |
0xFF |
|
S_IPSEC_Key1_Read_Protection |
Physical map 0x365[3] |
1 |
1 |
0: Enable S_IPSEC_Key1 read protection, prohibit key from being read 1: Disable S_IPSEC_Key1 read protection |
S_IPSEC_Key1_Write_Protection |
Physical map 0x365[4] |
1 |
1 |
0: Enable S_IPSEC_Key1 write protection, prohibit key from being written to all 0s by hackers 1: Disable S_IPSEC_Key1 write protection |
S_IPSEC_Key2_Read_Protection |
Physical map 0x365[5] |
1 |
1 |
0: Enable S_IPSEC_Key2 read protection, prohibit key from being read 1: Disable S_IPSEC_Key2 read protection |
S_IPSEC_Key2_Write_Protection |
Physical map 0x365[6] |
1 |
1 |
0: Enable S_IPSEC_Key2 write protection, prohibit key from being written to all 0s by hackers 1: Disable S_IPSEC_Key2 write protection |
NS_IPSEC_Key1_Read_Protection |
Physical map 0x365[7] |
1 |
1 |
0: Enable NS_IPSEC_Key1 read protection, prohibit key from being read 1: Disable NS_IPSEC_Key1 read protection |
NS_IPSEC_Key1_Write_Protection |
Physical map 0x366[0] |
1 |
1 |
0: Enable NS_IPSEC_Key1 write protection, prohibit key from being written to all 0s by hackers 1: Disable NS_IPSEC_Key1 write protection |
NS_IPSEC_Key2_Read_Protection |
Physical map 0x366[1] |
1 |
1 |
0: Enable NS_IPSEC_Key2 read protection, prohibit key from being read 1: Disable NS_IPSEC_Key2 read protection |
NS_IPSEC_Key2_Write_Protection |
Physical map 0x366[2] |
1 |
1 |
0: Enable NS_IPSEC_Key2 write protection, prohibit key from being written to all 0s by hackers 1: Disable NS_IPSEC_Key2 write protection |
The hardware encryption engine provides two key loading methods:
Software transfer: Keys are dynamically passed in by the application (software accessible)
OTP automatic loading: Keys are pre-burned into the OTP physical storage area (not accessible by software, only accessible by the encryption engine, preventing tampering or reading)
The OTP physical storage area supports storing 6 sets of keys, which need to be burned through the efuse command.
Engine Type |
Security |
Key Index |
OTP Key |
|---|---|---|---|
SHA HMAC |
Secure |
0 |
S_IPSEC_Key1 |
SHA HMAC |
Secure |
1 |
S_IPSEC_Key2 |
SHA HMAC |
Non-secure |
0 |
NS_IPSEC_Key1 |
SHA HMAC |
Non-secure |
1 |
NS_IPSEC_Key2 |
The detailed functions of OTP keys are shown below:
OTP Key Name |
Address |
Size bits |
Default Value |
Description |
|---|---|---|---|---|
S_IPSEC_Key1 (RDP) |
Logical map 0x200 |
256 |
0xFF |
When OTPKey_init function is enabled, the secure encryption engine will automatically load this key for HMAC or AES algorithm |
S_IPSEC_Key2 (Secure boot HMAC) |
Logical map 0x220 |
256 |
0xFF |
|
NS_IPSEC_Key1 |
Logical map 0x240 |
256 |
0xFF |
When OTPKey_init function is enabled, the non-secure encryption engine will automatically load this key for HMAC algorithm |
NS_IPSEC_Key2 |
Logical map 0x260 |
256 |
0xFF |
|
S_IPSEC_Key1_Read_Protection |
Physical map 0x365[3] |
1 |
1 |
0: Enable S_IPSEC_Key1 read protection, prohibit key from being read 1: Disable S_IPSEC_Key1 read protection |
S_IPSEC_Key1_Write_Protection |
Physical map 0x365[4] |
1 |
1 |
0: Enable S_IPSEC_Key1 write protection, prohibit key from being written to all 0s by hackers 1: Disable S_IPSEC_Key1 write protection |
S_IPSEC_Key2_Read_Protection |
Physical map 0x365[5] |
1 |
1 |
0: Enable S_IPSEC_Key2 read protection, prohibit key from being read 1: Disable S_IPSEC_Key2 read protection |
S_IPSEC_Key2_Write_Protection |
Physical map 0x365[6] |
1 |
1 |
0: Enable S_IPSEC_Key2 write protection, prohibit key from being written to all 0s by hackers 1: Disable S_IPSEC_Key2 write protection |
NS_IPSEC_Key1_Read_Protection |
Physical map 0x365[7] |
1 |
1 |
0: Enable NS_IPSEC_Key1 read protection, prohibit key from being read 1: Disable NS_IPSEC_Key1 read protection |
NS_IPSEC_Key1_Write_Protection |
Physical map 0x366[0] |
1 |
1 |
0: Enable NS_IPSEC_Key1 write protection, prohibit key from being written to all 0s by hackers 1: Disable NS_IPSEC_Key1 write protection |
NS_IPSEC_Key2_Read_Protection |
Physical map 0x366[1] |
1 |
1 |
0: Enable NS_IPSEC_Key2 read protection, prohibit key from being read 1: Disable NS_IPSEC_Key2 read protection |
NS_IPSEC_Key2_Write_Protection |
Physical map 0x366[2] |
1 |
1 |
0: Enable NS_IPSEC_Key2 write protection, prohibit key from being written to all 0s by hackers 1: Disable NS_IPSEC_Key2 write protection |
The HMAC engine is equipped with an independent key management unit. The key management unit supports software keys and OTP hardware keys.
4 Secure OTP keys: After OTP keys are burned, read and write protection can be enabled. Once protection is enabled, software cannot read or write, only hardware can use them. By default, these OTP keys can only be used in Secure state. If a Secure OTP key needs to be used in Non-Secure state, the crypto_hmac_sha2_share_secure_key API must be called in secure state first to modify the key’s usage permissions.
1 Secure Software key: Register key can be freely configured through software. This Secure Software Key can only be read and written in secure state, Non-Secure state cannot access the key register. By default, the Secure Software key can only be used in Secure state. If the user needs to configure the key in Secure CPU and use the key in Non-Secure state, the corresponding key share register bit must be configured in secure state first.
1 Non-Secure Software key: Can be read, written, and used in both Secure and Non-Secure states.
HMAC Key ID |
Key Type |
Length (bits) |
OTP Address |
Key Usage Permission |
Shared IP |
|---|---|---|---|---|---|
0 |
OTP |
256 |
0x200 |
Secure (default) / Non-secure |
Shared with AES |
1 |
OTP |
256 |
0x220 |
Secure (default) / Non-secure |
Shared with AES |
2 |
OTP |
256 |
0x240 |
Secure (default) / Non-secure |
Shared with AES |
3 |
OTP |
256 |
0x260 |
Secure (default) / Non-secure |
Shared with AES |
33 |
Register |
256 |
N/A |
Secure (default) / Non-secure |
HMAC only |
34 |
Register |
256 |
N/A |
Non-secure |
HMAC only |
HMAC Engine Security
The HASH architecture achieves efficient encryption processing while ensuring security through hardware-level isolation and intelligent arbitration:
Two independent register sets:
Secure address space: 0x5XXX_XXXX, mapped to secure-dedicated registers
Non-secure address space: 0x4XXX_XXXX, mapped to non-secure-dedicated registers
Arbitration mechanism when both secure and non-secure domains request the encryption engine simultaneously:
Basic policy: Round-robin scheduling + FIFO status priority (full FIFO has priority)
Atomicity guarantee: Must complete an entire round of encryption operation (LS=1) before switching engine control
Interrupt mechanism:
Physical isolation design: Secure and non-secure interrupts are connected to different interrupt numbers
Error isolation reporting: Bus errors trigger both interrupts simultaneously, but need to be cleared independently
Special setting: Interrupt security attributes only support automatic hardware switching
The HASH architecture achieves efficient encryption processing while ensuring security through hardware-level isolation and intelligent arbitration:
Two independent register sets:
Secure address space: 0x5XXX_XXXX, mapped to secure-dedicated registers
Non-secure address space: 0x4XXX_XXXX, mapped to non-secure-dedicated registers
Arbitration mechanism when both secure and non-secure domains request the encryption engine simultaneously:
Basic policy: Round-robin scheduling + FIFO status priority (full FIFO has priority)
Atomicity guarantee: Must complete an entire round of encryption operation (LS=1) before switching engine control
Interrupt mechanism:
Physical isolation design: Secure and non-secure interrupts are connected to different interrupt numbers
Error isolation reporting: Bus errors trigger both interrupts simultaneously, but need to be cleared independently
Special setting: Interrupt security attributes only support automatic hardware switching
The HASH architecture achieves efficient encryption processing while ensuring security through hardware-level isolation and intelligent arbitration:
Two independent register sets:
Secure address space: 0x5XXX_XXXX, mapped to secure-dedicated registers
Non-secure address space: 0x4XXX_XXXX, mapped to non-secure-dedicated registers
Arbitration mechanism when both secure and non-secure domains request the encryption engine simultaneously:
Basic policy: Round-robin scheduling + FIFO status priority (full FIFO has priority)
Atomicity guarantee: Must complete an entire round of encryption operation (LS=1) before switching engine control
Interrupt mechanism:
Physical isolation design: Secure and non-secure interrupts are connected to different interrupt numbers
Error isolation reporting: Bus errors trigger both interrupts simultaneously, but need to be cleared independently
Special setting: Interrupt security attributes only support automatic hardware switching
The HASH architecture achieves efficient encryption processing while ensuring security through hardware-level isolation and intelligent arbitration:
Two independent register sets:
Secure address space: 0x5XXX_XXXX, mapped to secure-dedicated registers
Non-secure address space: 0x4XXX_XXXX, mapped to non-secure-dedicated registers
Arbitration mechanism when both secure and non-secure domains request the encryption engine simultaneously:
Basic policy: Round-robin scheduling + FIFO status priority (full FIFO has priority)
Atomicity guarantee: Must complete an entire round of encryption operation (LS=1) before switching engine control
Interrupt mechanism:
Physical isolation design: Secure and non-secure interrupts are connected to different interrupt numbers
Error isolation reporting: Bus errors trigger both interrupts simultaneously, but need to be cleared independently
Special setting: Interrupt security attributes only support automatic hardware switching
The HASH architecture achieves efficient encryption processing while ensuring security through hardware-level isolation and intelligent arbitration:
Two independent register sets:
Secure address space: 0x5XXX_XXXX, mapped to secure-dedicated registers
Non-secure address space: 0x4XXX_XXXX, mapped to non-secure-dedicated registers
Arbitration mechanism when both secure and non-secure domains request the encryption engine simultaneously:
Basic policy: Round-robin scheduling + FIFO status priority (full FIFO has priority)
Atomicity guarantee: Must complete an entire round of encryption operation (LS=1) before switching engine control
Interrupt mechanism:
Physical isolation design: Secure and non-secure interrupts are connected to different interrupt numbers
Error isolation reporting: Bus errors trigger both interrupts simultaneously, but need to be cleared independently
Special setting: Interrupt security attributes only support automatic hardware switching
The HASH architecture achieves efficient encryption processing while ensuring security through hardware-level isolation and intelligent arbitration:
Two independent register sets:
Secure address space: 0x5XXX_XXXX, mapped to secure-dedicated registers
Non-secure address space: 0x4XXX_XXXX, mapped to non-secure-dedicated registers
Arbitration mechanism when both secure and non-secure domains request the encryption engine simultaneously:
Basic policy: Round-robin scheduling + FIFO status priority (full FIFO has priority)
Atomicity guarantee: Must complete an entire round of encryption operation (LS=1) before switching engine control
Interrupt mechanism:
Physical isolation design: Secure and non-secure interrupts are connected to different interrupt numbers
Error isolation reporting: Bus errors trigger both interrupts simultaneously, but need to be cleared independently
Special setting: Interrupt security attributes only support automatic hardware switching
The engine algorithm has passed NIST CAVP certification.
The HASH engine supports TrustZone technology and can automatically identify whether the CPU access is in Secure or Non-secure state. It incorporates a hardware mutex lock mechanism, meaning the CPU must first obtain this mutex lock before each operation; otherwise, it cannot access the hardware registers.
When the Secure CPU holds the lock, all Non-secure access is blocked. Only after the Secure CPU releases the lock can the Non-secure CPU regain access. Conversely, if a Non-secure CPU holds the lock, the Secure CPU can configure a dedicated preemption register to forcibly release the Non-secure lock and reset the engine, thereby immediately gaining control of the engine.
Additionally, each time the lock is released, the engine automatically clears sensitive information from the hardware and register states, ensuring no information leakage occurs.
HMAC Engine Usage Modes
DMA Mode
The HASH engine uses DMA to move data between memory and fifo, and uses HMAC to encrypt/decrypt data during the transfer process. DMA mode has high encryption/decryption efficiency for large amounts of data. However, DMA mode requires that the address and length of the data are aligned to the cache line length (32 bytes), otherwise there will be cache line data mismatch issues. If the address and length are not aligned, the serial port log will print a warning message. The driver has already handled the cache clean operation for the source address and cache invalidate operation for the destination address, so users do not need to clean the cache again outside the API.
DMA Mode
The HASH engine uses DMA to move data between memory and fifo, and uses HMAC to encrypt/decrypt data during the transfer process. DMA mode has high encryption/decryption efficiency for large amounts of data. However, DMA mode requires that the address and length of the data are aligned to the cache line length (32 bytes), otherwise there will be cache line data mismatch issues. If the address and length are not aligned, the serial port log will print a warning message. The driver has already handled the cache clean operation for the source address and cache invalidate operation for the destination address, so users do not need to clean the cache again outside the API.
DMA Mode
The HASH engine uses DMA to move data between memory and fifo, and uses HMAC to encrypt/decrypt data during the transfer process. DMA mode has high encryption/decryption efficiency for large amounts of data. However, DMA mode requires that the address and length of the data are aligned to the cache line length (32 bytes), otherwise there will be cache line data mismatch issues. If the address and length are not aligned, the serial port log will print a warning message. The driver has already handled the cache clean operation for the source address and cache invalidate operation for the destination address, so users do not need to clean the cache again outside the API.
DMA Mode
The HASH engine uses DMA to move data between memory and fifo, and uses HMAC to encrypt/decrypt data during the transfer process. DMA mode has high encryption/decryption efficiency for large amounts of data. However, DMA mode requires that the address and length of the data are aligned to the cache line length (32 bytes), otherwise there will be cache line data mismatch issues. If the address and length are not aligned, the serial port log will print a warning message. The driver has already handled the cache clean operation for the source address and cache invalidate operation for the destination address, so users do not need to clean the cache again outside the API.
DMA Mode
The HASH engine uses DMA to move data between memory and fifo, and uses HMAC to encrypt/decrypt data during the transfer process. DMA mode has high encryption/decryption efficiency for large amounts of data. However, DMA mode requires that the address and length of the data are aligned to the cache line length (32 bytes), otherwise there will be cache line data mismatch issues. If the address and length are not aligned, the serial port log will print a warning message. The driver has already handled the cache clean operation for the source address and cache invalidate operation for the destination address, so users do not need to clean the cache again outside the API.
DMA Mode
The HASH engine uses DMA to move data between memory and fifo, and uses HMAC to encrypt/decrypt data during the transfer process. DMA mode has high encryption/decryption efficiency for large amounts of data. However, DMA mode requires that the address and length of the data are aligned to the cache line length (32 bytes), otherwise there will be cache line data mismatch issues. If the address and length are not aligned, the serial port log will print a warning message. The driver has already handled the cache clean operation for the source address and cache invalidate operation for the destination address, so users do not need to clean the cache again outside the API.
HMAC engine supports two operation modes: DMA mode and Slave mode. Both modes can use Software key or OTP key.
DMA Mode
The HMAC engine shares a DMA controller with AES. The HMAC engine can only use channel 1 of the DMA.
In DMA mode, the engine supports read-only mode and copy mode:
Read-only mode: At startup, only the source data address needs to be specified. The engine will only read data from the data address and calculate the hash.
Copy mode: At startup, both the source data address and destination address need to be specified. While calculating the hash, the engine will also transfer the data completely to the destination address. This is suitable for copy verification scenarios.
Slave Mode
The CPU writes the message to the internal FIFO of the engine through the APB bus, then reads out the hash value. Customers do not need to be concerned with this mode.
HMAC API
Realtek provides low-level HMAC APIs, freeing users from managing specific register operations and processes. For broader applicability, the SHA2 hardware acceleration engine has been integrated into MbedTLS SHA2-Hash/HMAC APIs. Other hash algorithms (e.g., SHA1/MD5) lack hardware acceleration. MbedTLS APIs only support software keys and require low-level APIs for OTP key usage. Additionally, MbedTLS APIs do not support DMA copy mode.
Crypto Key Byte Order
The Crypto Engine key byte order is consistent with MbedTLS data structures, both adopting little-endian byte order. The following example uses a 256-bit key to illustrate the correct byte order for converting from a readable hexadecimal string to an array and programming it into OTP.
Example Key
Original key (hexadecimal large number representation):
0x0123456789abcdef0123456789abcdef00112233445566778899aabbccddeeff
Key Array Definition
When passing the key as a byte array to the hardware API in a program, it must be arranged in little-endian order. Example array for 32 bytes:
/* 256-bit key, little-endian byte order */
uint8_t key1[32] = {
0xff, 0xee, 0xdd, 0xcc, 0xbb, 0xaa, 0x99, 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11, 0x00,
0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01, 0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01
};
OTP Key Programming Flow
The following example uses NS_SHA_key2: First generate a little-endian ordered key, then use the AT+OTP=RRAW serial programming command to write to OTP physical address 0x260 (length 0x20, 32 bytes):
AT+OTP=WRAW,0x260,0x20,ffeeddccbbaa99887766554433221100efcdab8967452301efcdab8967452301
In mass production, after the key is written, key read protection and write protection must be enabled according to the OTP table descriptions to prevent OTP keys from being tampered with or leaked.
Note
The above example uses a 32-byte NS_SHA_key2 key; actual address and length should be adjusted according to actual needs.
Note that after OTP programming and system reset, the OTP key can be loaded into the engine.
This byte order rule applies to all IC models.
OTP Key Content Mapping
The actual content in the OTP physical address section after writing the above command:
Address |
b0 |
b1 |
b2 |
b3 |
b4 |
b5 |
b6 |
b7 |
b8 |
b9 |
b10 |
b11 |
b12 |
b13 |
b14 |
b15 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0x260 |
ff |
ee |
dd |
cc |
bb |
aa |
99 |
88 |
77 |
66 |
55 |
44 |
33 |
22 |
11 |
00 |
0x270 |
ef |
cd |
ab |
89 |
67 |
45 |
23 |
01 |
ef |
cd |
ab |
89 |
67 |
45 |
23 |
01 |