An6008 Getting Started With Debug Authentication Da For Stm32 Mcus Stmicroelectronics
An6008 Getting Started With Debug Authentication Da For Stm32 Mcus Stmicroelectronics
Application note
Introduction
This document describes the debug authentication (DA) security service. When not specified, STM32 refers to all applicable
products present in Table 1. Applicable products.
The STM32 debug authentication controls the product life cycle, such as regressions (for more details about the life cycle, refer
to the reference manual), and debug reopening:
• Regression
The user leverages the regression service to erase the user firmware and data within the user flash memory, SRAM, and
option-byte keys (OBK) when OBK are supported by STM32. After a regression, STM32 falls back in product state open.
Depending on STM32 products, there can be several kinds of regression: full regression and partial regression Refer to
Section 3: STM32 debug authentication services description for more details.
• Debug reopening
The user leverages the debug reopening to safely reopen the debug on STM32 when it is in a product state different than
open.
When the STM32 product state is not open, the user can trigger the debug authentication services by sending a password or a
certificate chain to the STM32 device.
These two options are named the debug authentication methods.
The debug authentication protocol uses the STM32 device debug access port 0 (DAP0) and the DBGMCU IP for
communication.
STM32
The STM32 debug authentication implements the Arm® PSA ADAC (authenticated debug access control) specification.
The Arm® PSA ADAC protocol is based on the certificate chain and the challenge/response principle.
Type Product
1 General information
Acronym Definition
TZ Arm® TrustZone®
Reference documents
1. This URL belongs to a third-party. It is active at document publication. However, STMicroelectronics shall not be liable for
any change, move, or inactivation of the URL or the referenced material.
Products compatibility
STM32H7Sxx STM32H7Rxx
2 Overview
***
***
DT73819V1
To access the debug authentication feature, the host must send the password to the STM32 device. When the
STM32 device receives the password, it verifies that its hash corresponds to the one that is provisioned inside the
key storage.
Figure 3 shows how the user triggers the debug authentication service using the certificate method.
Challenge Response
DT73820V1
: Debug Authentication Certificate
When the user triggers the debug authentication feature (regression or debug reopening), they first send a
certificate and an action request to the STM32 device.
1. On certificate chain reception, the STM32 device:
– verifies that the root key embedded in the certificate corresponds to the hash of the root public key
stored in the device.
– manages the permissions embedded in the certificates (refer to Section 5.4.3: Permission masks for
more details.
– checks that the requested action fits with the authorized actions list carried by the certificate chain.
2. The STM32 device sends a challenge to the host.
3. The STM32 device verifies that the host owns the debug authentication private key before performing the
requested action (regression or debug reopening). The certificate carries the authorized actions. Finally, a
token which carries the requested action and the response to the challenge is sent to the device.
STM32H573xx Yes
STM32H563xx/STM32H562xx Yes
STM32H533xx Yes
STM32H523xx Yes
STM32H503xx Yes
STM32H7Rx/7Sx Yes
with
• key.pem = .pem file containing the user private key
• certificates_chain = .b64 file containing the chain of certificates
In order to launch a full regression by using password method, use the following command:
.\STM32_Programmer_CLI.exe -c port=SWD per=a pwd=.\password.bin debugauth=1
with
• password.bin = binary file containing the password
STM32H573xx Yes
STM32H563xx/STM32H562xx Yes
STM32H533xx Yes
STM32H523xx Yes
STM32H503xx No
STM32H7Rx/7Sx No
Closed No(1) No No
1. STM32 secure resources cannot be accessed even if the user establishes a debug connection to STM32.
2. The user can only establish a debug connection to STM32 when Cortex®‑M33 is running in nonsecure domain. With a
debug connection, the user can access every nonsecure resource of the system.
3. The debug authentication service is not available in product state LOCKED.
STM32H573xx Yes
STM32H563xx/STM32H562xx Yes
STM32H533xx Yes
STM32H523xx Yes
STM32H503xx No
STM32H7Rx/7Sx Yes
In order to reopen debug from HDPL2 secure, use the following command:
.\STM32_Programmer_CLI.exe -c port=SWD speed=fast per=f key=.\key.pem cert=.\certificate_chai
n debugauth=1
In order to reopen debug from HDPL3 secure, use the following command:
.\STM32_Programmer_CLI.exe -c port=SWD speed=fast per=g key=.\key.pem cert=.\certificate_chai
n debugauth=1
In order to reopen debug from HDPL1 nonsecure, use the following command:
.\STM32_Programmer_CLI.exe -c port=SWD speed=fast per=h key=.\key.pem cert=.\certificate_chai
n debugauth=1
In order to reopen debug from HDPL2 nonsecure, use the following command:
.\STM32_Programmer_CLI.exe -c port=SWD speed=fast per=i key=.\key.pem cert=.\certificate_chai
n debugauth=1
In order to reopen debug from HDPL3 nonsecure, use the following command:
.\STM32_Programmer_CLI.exe -c port=SWD speed=fast per=j key=.\key.pem cert=.\certificate_chai
n debugauth=1
STM32H573xx Yes
STM32H563xx/STM32H563xx Yes
STM32H533xx Yes
STM32H523xx Yes
STM32H503xx No
STM32H7Rx/7Sx Yes
STM32H7Sxx Yes
STM32H7Rxx Yes
4.1 Provisioning
4.1.1 Introduction
The debug authentication use two kinds of methods:
• A password (maximum length of password is 128 bits/16 bytes).
• A certificate chain.
Before using the debug authentication service, the user must provision STM32 with data for debug authentication
configuration.
The debug authentication configuration includes three main information:
• A SHA256 hash on below data, for integrity check
• A DA credential related to the chosen authentication method, named debug authentication root key in TPC
• A permission mask
On STM32H503xx, debug authentication data is provisioned and not encrypted in OTP (at address
0x08FFF000).
OTP programming is done by using STM32CubeProgrammer.
On STM32H573xx/STM32H533xx (crypto device), DA data is stored encrypted (AES-CBC) in HDPL1 OBK (at
address 0x0FFD0100).
On STM32H563xx/STM32H523xx (noncrypto device), DA data is stored not encrypted in HDPL1 OBK (at
address 0x0FFD0100).
OBK generation is done by using the STM32 Trusted Package Creator.
OBK provisioning is done by using the STM32CubeProgrammer.
OBK generation is done by the STM32 Trusted Package Creator.
OBK provisioning is done by using the STM32CubeProgrammer.
For more details, also refer to document [5].
On STM32H7Rx/7Sx, DA data is stored encrypted (AES-CBC) in HDPL0 OBK (at index 8).
Bit 127 Bit 126 Bit 125 Bit 124 Bit 123 Bit 122 Bit 121 Bit 120
Forced
Reserved Reserved Reserved Reserved Reserved Reserved Reserved
download
Full Partial
Reserved Reserved Reserved Reserved Reserved Reserved
regression regression
Open debug Open debug Open debug Open debug Open debug Open debug
Reserved from HDPL3 from HDPL2 from HDPL1 Reserved from HDPL3 from HDPL2 from HDPL1
S/NS S/NS S/NS NS NS NS
DBGCMU_DBG_AUTH_DEV
Host
JTAG/SWD Cortex
DBGCMU_DBG_AUTH_HOST
DT73840V1
DBGMCU acts as a mailbox between the host and the STM32 device.
The debug host uses JTAG/SWD to write a word within the DBGMCU_DBG_AUTH_HOST register in order to send
messages to the debug authentication service of the STM32 device.
The debug authentication service of the STM32 device reads the same register to get the messages.
The debug authentication service writes a word within the DBGMCU_DBG_AUTH_DEV register in order to send a
word to the debug host.
The debug host uses JTAG/SWD to read a single word from the DBGMCU_DBG_AUTH_DEV register.
The debug host and the STM32 device use the DBGMCU_DBG_AUTH_ACK register for acknowledgment of
exchanges from the STM32 device to the debug host and from the debug host to the STM32 device.
For more details about the DBGMCU register, refer to document [2].
Host and STM32 use the Arm® PSA ADAC protocol over DBGMCU mailbox.
Once the debug authentication sequence is completed, STM32 debug authentication opens access point 1 and
the debug host can establish the debug connection with it.
With access point 1, the debug host accesses all STM32 resources granted by the debug reopening context
request.
DT73821V1
DT73822V1
5.4.2 Certificates and certificate chains
There are three types of certificates:
• Root certificate
• Intermediate certificate
• Leaf certificate
A certificate chain can be composed of:
• A root certificate only
• A root certificate + a leaf certificate
• A root certificate + Nx intermediate certificates + a leaf certificate
Certificates and certificate chain are created by using STM32 Trusted Package Creator.
Example of usage
A manufacturer (root level) subcontracts some services to other entities (intermediate level). These
subcontractors also subcontract some of their services to other entities (leaf level).
DT73823V1
Example of an authorized action
In this example, the token mask is used to request a debug opening from HDPL3 NS. The permission
accumulation allows this action so it is applied.
In the example described Figure 8, the certificate chain contains a root certificate and a leaf certificate.
DT73824V1
STM32
Host
2
STM32CubeProgrammer Probe OBK
1
STM32 Trusted Package
Creator
DA_Config.xml
DT73826V1
Step 1
The STM32 Trusted Package Creator is used to create the debug authentication configuration .obk file from the
debug authentication configuration .xml file.
Step 2
The DA configuration obk file is programmed in STM32 OBK by using the STM32CubeProgrammer.
STM32
Host
2
STM32CubeProgrammer Debug port Debug
or IDE Probe
SDM / DBGMCU Authentication
Certificate chains
1
STM32 Trusted Package
Creator
Certificates_Gen.xml
DT73825V1
Step 1
The STM32 Trusted Package Creator is used to create the certificate chain from the certificate generation xml file.
Step 2
A debug authentication service is launched by using the STM32CubeProgrammer or an IDE (both integrating the
SDM library) to send the certificates chain to the device.
Revision history
Table 15. Document revision history
Contents
1 General information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4
2.1 Debug authentication provisioning overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.2 Debug authentication using password overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.3 Debug authentication using certificates overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
3 STM32 debug authentication services description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.1 Discovery service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.1.1 Discovery service details. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.1.2 CLI command for discovery command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.2 Full regression service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.2.1 Full regression details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.2.2 STM32 series full regression support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.2.3 CLI commands for full regression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.3 Partial regression service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.3.1 Partial regression service details. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.3.2 Partial regression service and EEPROM emulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.3.3 Partial regression service and HDP areas. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.3.4 Partial regression service and WRP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.3.5 STM32 series partial regression support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.3.6 CLI command for partial regression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.4 Debug reopening service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.4.1 Debug reopening service details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.4.2 Debug reopening and STiRoT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.4.3 STM32 debug reopening support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.4.4 CLI commands to reopen debug on STM32H5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.4.5 CLI commands to reopen debug on STM32H7Rx/7Sx . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.5 Close debug service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.5.1 Close debug details. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.5.2 STM32 close debug support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.5.3 CLI command for close debug command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.6 Forced download service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.6.1 Forced download details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.6.2 STM32H7Rx/7Sx series forced download support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.6.3 CLI command for forced download . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4 Debug authentication activation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12
4.1 Provisioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.1.2 Debug authentication using password. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.1.3 Debug authentication using certificates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.1.4 Permission mask. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.2 Debug authentication trigger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
5 STM32 debug authentication protocol description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14
5.1 Physical link . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
5.2 STM32 debug authentication protocol overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
5.3 Debug authentication using password . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.4 Debug authentication using a certificate chain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.4.1 Sequence diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.4.2 Certificates and certificate chains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
5.4.3 Permission masks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
5.4.4 Certificates and product series/device filtering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
6 Debug authentication ecosystem overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18
6.1 Debug authentication provisioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
6.2 Launch debug authentication service (certificate method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
7 STM32 debug authentication restrictions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .20
7.1 Debug authentication and WWDG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21
List of tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24
List of figures. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25
List of tables
Table 1. Applicable products . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Table 2. Terms and abbreviations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Table 3. Synthesis table for SMT32H5 products . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Table 4. Synthesis table for STM32H7Rx/7Sx products . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Table 5. Discovery service availability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Table 6. STM32 series full regression support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Table 7. STM32 series partial regression support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Table 8. Debug connection vs product state. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Table 9. STM32 debug reopening support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Table 10. STM32 close debug support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Table 11. STM32H7Rx/7Sx series forced download support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Table 12. DA configuration xml file details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Table 13. Debug authentication configuration obk file details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Table 14. Debug authentication certificates generation xml file details. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Table 15. Document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
List of figures
Figure 1. Debug authentication interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Figure 2. Debug authentication using a password . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Figure 3. Debug authentication using certificate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Figure 4. DBGMCU usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Figure 5. Debug authentication using password . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Figure 6. Debug authentication using a root certificate. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Figure 7. Example of a forbidden action . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Figure 8. Example of an authorized action . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Figure 9. Debug authentication ecosystem during provisioning phase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Figure 10. Debug authentication ecosystem for service launch. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19