Skip to content

Commit cb791c3

Browse files
committed
Added WOLFBOOT_UDS_OBKEYS=1
Instruction to provision keys via iRoT / OBKeys (STM32H5 only)
1 parent 68067b6 commit cb791c3

5 files changed

Lines changed: 55 additions & 0 deletions

File tree

docs/DICE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,27 @@ families must implement the appropriate subset based on hardware support.
7474
- `hal_attestation_get_iak_private_key(uint8_t *buf, size_t *len)`
7575
- Optional provisioned IAK private key (used in IAK mode only).
7676

77+
## STM32H5 OBKeys UDS (optional)
78+
79+
STM32H5 devices provide OBKeys secure storage areas tied to temporal isolation
80+
levels (HDPL). The HDPL1 area is intended for iRoT keys and is the recommended
81+
location for a device-unique UDS when `WOLFBOOT_UDS_OBKEYS=1` is enabled. OBKeys
82+
secure storage is only available on STM32H5 lines except STM32H503.
83+
84+
Provisioning uses STs secure data provisioning flow:
85+
86+
1. Create an OBKeys provisioning file (`.obk`) using STM32TrustedPackageCreator
87+
(CLI supports `-obk <xml>` input).
88+
2. Program the `.obk` file using STM32CubeProgrammer CLI with the `-sdp` option.
89+
90+
3. After provisioning, move the device to the CLOSED state as appropriate for
91+
production.
92+
93+
When `WOLFBOOT_UDS_OBKEYS=1`, the STM32H5 HAL first attempts to read UDS from
94+
OBKeys using a platform hook (`stm32h5_obkeys_read_uds`). Integrate this hook
95+
with your RSSe/RSSLib provisioning flow (DataProvisioning API) as described in
96+
ST documentation.
97+
7798
## NSC access (non-secure API)
7899

79100
The non-secure application calls the PSA Initial Attestation API wrappers:

hal/stm32h5.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,15 @@ int RAMFUNCTION hal_flash_write(uint32_t address, const uint8_t *data, int len)
168168
#define STM32H5_BSEC_UID1 (*(volatile uint32_t *)(STM32H5_BSEC_BASE + 0x18))
169169
#define STM32H5_BSEC_UID2 (*(volatile uint32_t *)(STM32H5_BSEC_BASE + 0x1C))
170170

171+
#ifdef WOLFBOOT_UDS_OBKEYS
172+
__attribute__((weak)) int stm32h5_obkeys_read_uds(uint8_t *out, size_t out_len)
173+
{
174+
(void)out;
175+
(void)out_len;
176+
return -1;
177+
}
178+
#endif
179+
171180
static int uds_from_uid(uint8_t *out, size_t out_len)
172181
{
173182
uint8_t uid[12];
@@ -234,6 +243,12 @@ int hal_uds_derive_key(uint8_t *out, size_t out_len)
234243
return -1;
235244
}
236245

246+
#ifdef WOLFBOOT_UDS_OBKEYS
247+
if (stm32h5_obkeys_read_uds(out, out_len) == 0) {
248+
return 0;
249+
}
250+
#endif
251+
237252
#if defined(FLASH_OTP_KEYSTORE)
238253
if (hal_flash_otp_read(FLASH_OTP_BASE + OTP_UDS_OFFSET,
239254
uds, sizeof(uds)) == 0) {

options.mk

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ ifeq ($(WOLFBOOT_UDS_UID_FALLBACK_FORTEST),1)
3939
CFLAGS+=-D"WOLFBOOT_UDS_UID_FALLBACK_FORTEST"
4040
endif
4141

42+
ifeq ($(WOLFBOOT_UDS_OBKEYS),1)
43+
ifneq ($(TARGET),stm32h5)
44+
$(error WOLFBOOT_UDS_OBKEYS is only supported on STM32H5 targets)
45+
endif
46+
CFLAGS+=-D"WOLFBOOT_UDS_OBKEYS"
47+
endif
48+
4249
## Sealing a secret into the TPM
4350
ifeq ($(WOLFBOOT_TPM_SEAL),1)
4451
WOLFTPM:=1

tools/config.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ ifeq ($(ARCH),)
6161
WOLFBOOT_ATTESTATION_TEST?=0
6262
WOLFBOOT_UNIVERSAL_KEYSTORE?=0
6363
WOLFBOOT_UDS_UID_FALLBACK_FORTEST?=0
64+
WOLFBOOT_UDS_OBKEYS?=0
6465
TZEN?=0
6566
WOLFCRYPT_TZ?=0
6667
WOLFCRYPT_TZ_PKCS11?=0
@@ -99,6 +100,7 @@ CONFIG_VARS:= ARCH TARGET SIGN HASH MCUXSDK MCUXPRESSO MCUXPRESSO_CPU MCUXPRESSO
99100
WOLFBOOT_ATTESTATION_IAK \
100101
WOLFBOOT_ATTESTATION_TEST \
101102
WOLFBOOT_UDS_UID_FALLBACK_FORTEST \
103+
WOLFBOOT_UDS_OBKEYS \
102104
WOLFCRYPT_TZ WOLFCRYPT_TZ_PKCS11 \
103105
WOLFCRYPT_TZ_PSA \
104106
WOLFBOOT_PARTITION_SIZE WOLFBOOT_SECTOR_SIZE \

tools/keytools/otp/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,14 @@
33
This application is used to provision the public keys into a dedicated FLASH OTP
44
area. For more information about its usage, please refer to [/docs/flash-OTP.md](/docs/flash-OTP.md).
55

6+
## Attestation UDS storage
7+
8+
For targets that support it (for example STM32H5), wolfBoot can store a random
9+
UDS for DICE attestation in OTP using the primer app. This is the default
10+
approach when OBKeys secure storage is not available or not provisioned.
11+
12+
If you have access to STM32H5 OBKeys secure storage, prefer that for production
13+
iRoT key material. Enable `WOLFBOOT_UDS_OBKEYS=1` and provision OBKeys via
14+
STM32TrustedPackageCreator/STM32CubeProgrammer (see `docs/DICE.md`). OTP should
15+
be used for development or as a fallback when OBKeys is unavailable.
616

0 commit comments

Comments
 (0)