Skip to content

Commit 051a2a4

Browse files
authored
Merge pull request #787 from twcook86/lpc55s69_hwpuf
Support for PUF in LPC55S69
2 parents b240ee7 + 28d7171 commit 051a2a4

16 files changed

Lines changed: 777 additions & 74 deletions

‎.github/workflows/test-configs.yml‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,20 @@ jobs:
178178
config-file: ./config/examples/lpc55s69-tz.config
179179
board-name: lpcxpresso55s69
180180

181+
lpc55s69_tz_psa_test:
182+
uses: ./.github/workflows/test-build-mcux-sdk-manifests.yml
183+
with:
184+
arch: arm
185+
config-file: ./config/examples/lpc55s69-tz-psa.config
186+
board-name: lpcxpresso55s69
187+
188+
lpc55s69_benchmark_test:
189+
uses: ./.github/workflows/test-build-mcux-sdk-manifests.yml
190+
with:
191+
arch: arm
192+
config-file: ./config/examples/lpc55s69-benchmark.config
193+
board-name: lpcxpresso55s69
194+
181195
m2354_test:
182196
uses: ./.github/workflows/test-build.yml
183197
with:

‎.github/workflows/trustzone-emulator-tests.yml‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,54 @@ jobs:
168168
./tools/keytools/otp/otp-keystore-gen
169169
m33mu tools/keytools/otp/otp-keystore-primer.bin --persist --timeout 10 || true
170170
m33mu wolfboot.bin test-app/image_v1_signed.bin:0x60000 --uart-stdout --expect-bkpt 0x7f --timeout 600 --persist
171+
172+
# LPC55S69 DICE attestation + HW PUF. The PUF root key is provisioned
173+
# at first boot (WOLFBOOT_HWPUF_PROVISION=1) and used for DICE key
174+
# derivation on subsequent boots. Requires m33mu with lpc55s69 PUF/RNG
175+
# models (wolfboot-ci >= 1.22).
176+
# The lpc55s69 HAL needs MCUXpresso SDK headers (fsl_common.h); same
177+
# west-based setup as the lpc55s69 jobs in test-configs.yml.
178+
- name: Checkout CMSIS (lpc55s69)
179+
uses: actions/checkout@main
180+
with:
181+
repository: nxp-mcuxpresso/CMSIS_5
182+
path: CMSIS_5
183+
184+
- name: Setup MCUXpresso SDK (lpc55s69)
185+
shell: bash
186+
run: |
187+
python3 -m venv venv
188+
source venv/bin/activate
189+
pip install west
190+
west init -m https://github.com/nxp-mcuxpresso/mcuxsdk-manifests.git mcuxpresso-sdk
191+
cd mcuxpresso-sdk
192+
sed -i '/se_hostlib\|emwin/d' manifests/boards/lpcxpresso55s69.yml
193+
west update_board --set board lpcxpresso55s69
194+
195+
- name: Clean and build test with DICE attestation + HW PUF (lpc55s69)
196+
run: |
197+
make clean distclean
198+
cp config/examples/lpc55s69-tz-psa.config .config
199+
sed -i 's/^HWPUF?=0/HWPUF?=1/' .config
200+
sed -i 's/^WOLFBOOT_HWPUF_PROVISION?=0/WOLFBOOT_HWPUF_PROVISION?=1/' .config
201+
sed -i 's/^WOLFBOOT_UDS_UID_FALLBACK_FORTEST?=1/WOLFBOOT_UDS_UID_FALLBACK_FORTEST?=0/' .config
202+
grep -q '^HWPUF?=1' .config
203+
grep -q '^WOLFBOOT_HWPUF_PROVISION?=1' .config
204+
grep -q '^WOLFBOOT_UDS_UID_FALLBACK_FORTEST?=0' .config
205+
make MCUXSDK=1 MCUXPRESSO="$GITHUB_WORKSPACE/mcuxpresso-sdk/mcuxsdk" MCUXPRESSO_CMSIS="$GITHUB_WORKSPACE/CMSIS_5/CMSIS"
206+
207+
# Single boot: enroll the PUF, store the record, attest.
208+
# TODO: add a second --persist boot checking the stored record is reused
209+
# (same UEID) once the CI image ships an m33mu with lpc55s69 --persist
210+
# support (m33mu c2d903e, after v1.23).
211+
- name: Run DICE attestation + HW PUF (lpc55s69)
212+
run: |
213+
set -o pipefail
214+
m33mu wolfboot.bin test-app/image_v1_signed.bin:0x48000 --cpu lpc55s69 --uart-stdout --expect-bkpt 0x7f --timeout 300 \
215+
| tee /tmp/m33mu-lpc55s69-dice-hwpuf.log
216+
grep -q "Booting version:" /tmp/m33mu-lpc55s69-dice-hwpuf.log
217+
grep -q "Checking integrity...done" /tmp/m33mu-lpc55s69-dice-hwpuf.log
218+
grep -q "Verifying signature...done" /tmp/m33mu-lpc55s69-dice-hwpuf.log
219+
grep -q "attest: token size" /tmp/m33mu-lpc55s69-dice-hwpuf.log
220+
grep -q "state=0x00" /tmp/m33mu-lpc55s69-dice-hwpuf.log
221+
grep -q "\\[EXPECT BKPT\\] Success" /tmp/m33mu-lpc55s69-dice-hwpuf.log

‎arch.mk‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2153,6 +2153,7 @@ ifeq ($(TARGET),lpc55s69)
21532153
-I$(MCUXPRESSO)/drivers/iap1 \
21542154
-I$(MCUXPRESSO)/drivers/lpc_gpio \
21552155
-I$(MCUXPRESSO)/drivers/lpc_iocon \
2156+
-I$(MCUXPRESSO)/drivers/puf \
21562157
-I$(MCUXPRESSO)/drivers/rng_1 \
21572158
-I$(MCUXPRESSO_CMSIS)/Include \
21582159
-I$(MCUXPRESSO_CMSIS)/Core/Include
@@ -2169,10 +2170,10 @@ ifeq ($(TARGET),lpc55s69)
21692170
$(MCUXPRESSO)/drivers/common/fsl_common_arm.o \
21702171
$(MCUXPRESSO)/drivers/iap1/fsl_iap.o \
21712172
$(MCUXPRESSO)/drivers/lpc_gpio/fsl_gpio.o \
2172-
$(MCUXPRESSO)/drivers/rng_1/fsl_rng.o
2173+
$(MCUXPRESSO)/drivers/rng_1/fsl_rng.o \
2174+
$(MCUXPRESSO_DRIVERS)/drivers/fsl_reset.o
21732175
ifeq ($(DEBUG_UART),1)
21742176
OBJS+=\
2175-
$(MCUXPRESSO_DRIVERS)/drivers/fsl_reset.o \
21762177
$(MCUXPRESSO)/drivers/flexcomm/fsl_flexcomm.o \
21772178
$(MCUXPRESSO)/drivers/flexcomm/usart/fsl_usart.o
21782179
endif
@@ -2184,6 +2185,12 @@ ifeq ($(TARGET),lpc55s69)
21842185
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/nxp/casper_port.o \
21852186
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/nxp/hashcrypt_port.o
21862187
endif
2188+
ifeq ($(HWPUF),1)
2189+
CFLAGS+=-DWOLFSSL_NXP_HWPUF
2190+
OBJS+=\
2191+
$(MCUXPRESSO)/drivers/puf/fsl_puf.o \
2192+
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/nxp/hwpuf_port.o
2193+
endif
21872194
endif
21882195

21892196
ifeq ($(TARGET),psoc6)

‎config/examples/lpc55s69-benchmark.config‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@ FLASH_MULTI_SECTOR_ERASE?=1
3030

3131
# Turn on or off hw acceleration of crypto algs in the lpc55s69
3232
PKA?=0
33+
# Turn on or off hw puf
34+
HWPUF?=0
3335

34-
# use 1024-byte sector to accommodate RSA4096 signature
35-
# WOLFBOOT_SECTOR_SIZE?=0x400
3636
WOLFBOOT_SECTOR_SIZE?=0x200
3737

3838
# use these for test/benchmark
39-
WOLFBOOT_PARTITION_SIZE?=0x2b000
39+
WOLFBOOT_PARTITION_SIZE?=0x30000
4040
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0x10000
41-
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x3b000
42-
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x66000
41+
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x40000
42+
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x70000
4343

4444
WOLFCRYPT_TEST?=1
4545
WOLFCRYPT_BENCHMARK?=1
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
ARCH?=ARM
2+
TZEN?=1
3+
TARGET?=lpc55s69
4+
SIGN?=ECC384
5+
HASH?=SHA256
6+
MCUXSDK?=1
7+
MCUXPRESSO?=$(PWD)/../NXP/mcuxpresso-sdk/mcuxsdk
8+
MCUXPRESSO_CMSIS?=$(PWD)/../NXP/CMSIS_5/CMSIS
9+
MCUXPRESSO_CPU?=LPC55S69JBD100_cm33_core0
10+
MCUXPRESSO_DRIVERS?=$(MCUXPRESSO)/devices/LPC/LPC5500/LPC55S69
11+
MCUXPRESSO_PROJECT_TEMPLATE?=$(MCUXPRESSO)/examples/_boards/lpcxpresso55s69/project_template
12+
DEBUG?=0
13+
DEBUG_UART?=1
14+
VTOR?=1
15+
CORTEX_M0?=0
16+
CORTEX_M33?=1
17+
NO_ASM?=0
18+
NO_MPU=1
19+
EXT_FLASH?=0
20+
SPI_FLASH?=0
21+
ALLOW_DOWNGRADE?=0
22+
NVM_FLASH_WRITEONCE?=1
23+
NO_ARM_ASM=1
24+
WOLFBOOT_VERSION?=0
25+
V?=0
26+
SPMATH?=1
27+
RAM_CODE?=1
28+
DUALBANK_SWAP?=0
29+
FLASH_MULTI_SECTOR_ERASE?=1
30+
WOLFCRYPT_TZ?=1
31+
WOLFCRYPT_TZ_PSA?=1
32+
33+
WOLFBOOT_ATTESTATION_TEST?=1
34+
WOLFBOOT_UDS_UID_FALLBACK_FORTEST?=1
35+
36+
# Turn on or off hw acceleration of crypto algs in the lpc55s69
37+
PKA?=0
38+
# Turn on or off hw puf
39+
HWPUF?=0
40+
WOLFBOOT_HWPUF_PROVISION?=0
41+
42+
WOLFBOOT_SECTOR_SIZE?=0x200
43+
44+
# 200KB boot, 80KB keyvault, 8KB NSC, 56KB partitions, 512 swap
45+
WOLFBOOT_KEYVAULT_ADDRESS?=0x10032000
46+
WOLFBOOT_KEYVAULT_SIZE?=0x14000
47+
WOLFBOOT_NSC_ADDRESS?=0x10046000
48+
WOLFBOOT_NSC_SIZE?=0x2000
49+
WOLFBOOT_PARTITION_SIZE?=0xE000
50+
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0x00048000
51+
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x00056000
52+
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x00064000

‎config/examples/lpc55s69-tz.config‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ WOLFCRYPT_TZ_PKCS11?=1
3232

3333
# Turn on or off hw acceleration of crypto algs in the lpc55s69
3434
PKA?=0
35+
# Turn on or off hw puf
36+
HWPUF?=0
3537

36-
# use 1024-byte sector to accommodate RSA4096 signature
37-
# WOLFBOOT_SECTOR_SIZE?=0x400
3838
WOLFBOOT_SECTOR_SIZE?=0x200
3939

40-
# 200KB boot, 80KB keyvault, 8KB NSC, 56KB partitions, 512/1024 swap
40+
# 200KB boot, 80KB keyvault, 8KB NSC, 56KB partitions, 512 swap
4141
WOLFBOOT_KEYVAULT_ADDRESS?=0x10032000
4242
WOLFBOOT_KEYVAULT_SIZE?=0x14000
4343
WOLFBOOT_NSC_ADDRESS?=0x10046000

‎config/examples/lpc55s69.config‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ FLASH_MULTI_SECTOR_ERASE?=1
3030

3131
# Turn on or off hw acceleration of crypto algs in the lpc55s69
3232
PKA?=0
33+
# Turn on or off hw puf
34+
HWPUF?=0
3335

34-
# use 1024-byte sector to accommodate RSA4096 signature
35-
# WOLFBOOT_SECTOR_SIZE?=0x400
3636
WOLFBOOT_SECTOR_SIZE?=0x200
3737

3838
# Default configuration
39-
# 44KB boot, 52KB partitions, 512/1024 swap
39+
# 44KB boot, 52KB partitions, 512 swap
4040
WOLFBOOT_PARTITION_SIZE?=0xB000
4141
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0xD000
4242
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x18000

‎docs/Targets.md‎

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3428,14 +3428,74 @@ Basic hardware acceleration supported:
34283428
- AES-ECB (128, 192, 256 key sizes)
34293429
- AES-CBC (128, 192, 256 key sizes)
34303430
- AES-OFB (128, 192, 256 key sizes)
3431-
- Only supports full 16-byte blocks
34323431
- AES-CFB (128, 192, 256 key sizes)
3433-
- Only supports full 16-byte blocks
34343432
- AES-CTR (128, 192, 256 key sizes)
34353433
- User must avoid counter wrap of all ff's to 0, as this fails in the hardware
34363434

34373435
See [Test and Benchmark](#lpc55s69-test-and-benchmark) for a comparison with and without hardware acceleration.
34383436

3437+
### LPC55S69: Hardware PUF (HWPUF)
3438+
3439+
wolfBoot / wolfCrypt provide support for the LPC55S69's SRAM PUF (Physically
3440+
Unclonable Function), which provides root of trust, identity, and key
3441+
generation & storage, without the need to expose keys during manufacturing.
3442+
Keys of size 128, 192, and 256 bits are supported.
3443+
To turn on HWPUF, set HWPUF=1 in the config file (see below).
3444+
3445+
### LPC55S69: Example Configurations
3446+
3447+
#### The following example configurations are provided:
3448+
3449+
- [lpc55s69.config](/config/examples/lpc55s69.config):
3450+
- Both wolfBoot and the test-app live in the non-secure realm
3451+
- Set PKA=1 in the config file to turn on hardware acceleration
3452+
(off by default)
3453+
3454+
- [lpc55s69-benchmark.config](/config/examples/lpc55s69-benchmark.config):
3455+
- Same as `lpc55s69.config`, but turns on test and benchmark code
3456+
- Set PKA=1 in the config file to turn on hardware acceleration
3457+
(off by default)
3458+
3459+
- [lpc55s69-tz.config](/config/examples/lpc55s69-tz.config):
3460+
- wolfBoot lives in the secure realm, test-app lives in the non-secure realm
3461+
- Provides a standard PKCS #11 api to interface with crypto algs in the secure
3462+
realm
3463+
3464+
- [lpc55s69-tz-psa.config](/config/examples/lpc55s69-tz-psa.config):
3465+
- wolfBoot lives in the secure realm, test-app lives in the non-secure realm
3466+
- Provides a standard PSA api to interface with crypto algs in the secure
3467+
realm
3468+
- Provides an example of PSA Attestation
3469+
- To turn on HWPUF for use with attestation, set the following in the config
3470+
file:
3471+
- WOLFBOOT_UDS_UID_FALLBACK_FORTEST=0
3472+
- HWPUF=1
3473+
- WOLFBOOT_HWPUF_PROVISION=1
3474+
3475+
#### Summary of configurables applicable to all lpc55s69 example configurations:
3476+
- `PKA` : Turn on/off hardware acceleration of crypto algs
3477+
- `HWPUF` : Turn on/off support for the hardware PUF
3478+
- `WOLFBOOT_HWPUF_PROVISION` : Turn on/off auto-provisioning of the HWPUF on
3479+
first boot. Performs PUF enrollment and generates a UDS key for device
3480+
attestation. Stores PUF keycodes in a known flash location and uses them when
3481+
necessary.
3482+
- `WOLFBOOT_HWPUF_PROV_ADDRESS` : Flash address of the 4 KB PUF provisioning
3483+
record (default `0x80000`, page aligned). The build fails if it overlaps the
3484+
boot, update or swap partition or the protected flash region (`0x9DE00` and
3485+
up), or if it lies below the boot partition (wolfBoot, keyvault and NSC).
3486+
The activation code and key code are written first and verified, then a
3487+
commit word is written in the last page of the record. Provisioning only
3488+
runs when that commit page is erased (or all `0xFF`), so a provisioning
3489+
interrupted before the commit is redone on the next boot. A record in any
3490+
other state is never silently replaced, because that would change the device
3491+
identity: attestation fails until the region is erased. This includes the
3492+
rare case where power is lost while the commit page itself is being erased or
3493+
programmed.
3494+
3495+
`HWPUF=1` cannot be combined with `WOLFBOOT_UDS_UID_FALLBACK_FORTEST=1`. With
3496+
`TZEN=1` the PUF is reachable only from the secure world (it is excluded from
3497+
the non-secure SAU regions and is not linked into the non-secure test-app).
3498+
34393499
### LPC55S69: Configuring and compiling
34403500

34413501
Copy the example configuration file and build with make:
@@ -3445,9 +3505,6 @@ cp config/examples/lpc55s69.config .config
34453505
make
34463506
```
34473507

3448-
We also provide a TrustZone configuration at `config/examples/lpc55s69-tz.config`
3449-
and a benchmarking configuration at `config/examples/lpc55s69-benchmark.config`.
3450-
34513508
### LPC55S69: Loading the firmware
34523509

34533510
Download and install the LinkServer tool:

0 commit comments

Comments
 (0)