|
| 1 | +# DICE attestation sample on MCXN947 |
| 2 | + |
| 3 | +General concept of wolfBoot in TrustZone secure domain is explained in `docs/STM32-TZ.md`. |
| 4 | +This focuses on a sample of PSA initial attestation for MCXN947. |
| 5 | +Sample application is implemented in `test-app/app_mcxn.c`. |
| 6 | +This supports hardware-based DICE using EdgeLock Secure Subsystem. |
| 7 | + |
| 8 | +## How to build |
| 9 | +Please use `config/examples/mcxn-tz-psa-hw.config` to build wolfBoot. |
| 10 | +You need to update the path of SDK inside the config for your build environment. |
| 11 | +``` |
| 12 | +cp config/examples/mcxn-tz-psa-hw.config .config |
| 13 | +make |
| 14 | +``` |
| 15 | + |
| 16 | +## How to run |
| 17 | +MCXN947 requires us to enable secure boot to use DICE functionality of ELS. |
| 18 | +So, We need to prepare the specific image file of wolfBoot binary and configuration files of CMPA/CFPA for secure bootROM and ELS. |
| 19 | +Fortunately NXP provides the [secure provisioning tool](https://www.nxp.com/design/design-center/software/development-software/mcuxpresso-software-and-tools-/mcuxpresso-secure-provisioning-tool:MCUXPRESSO-SECURE-PROVISIONING) for such purpose. |
| 20 | + |
| 21 | +At a minimum, you shall configure the following settings and encode the image with signature: |
| 22 | +- Enable Image verification for secure boot (SEC_BOOT_EN == 0b10) |
| 23 | +- Enable DICE (SKIP_DICE == 0b0) |
| 24 | +All of these can be done using the NXP secure provisioning tool. |
| 25 | + |
| 26 | +If you use secure provisioning tool, you can download the prepared image with configuration files to hardware as well. |
| 27 | +Regarding to application image like image_v1_signed.bin, we don't need to encode it like the wolfBoot binary because it's verified by wolfBoot as usual. |
| 28 | +But, we still recommend you to download the application image using the flash programmer tool in the secure provisioning tool for a safe download. You can access it via `Tools > Flash Programmer` on GUI. |
| 29 | + |
| 30 | +Once both images are downloaded successfully, you'll see the log after reboot: |
| 31 | +``` |
| 32 | +Boot partition: 0x60000 (sz 31508, ver 0x1, type 0x601) |
| 33 | +Partition 1 header magic 0xFFFFFFFF invalid at 0x72000 |
| 34 | +Boot partition: 0x60000 (sz 31508, ver 0x1, type 0x601) |
| 35 | +Booting version: 0x1 |
| 36 | +Checking integrity...done |
| 37 | +Verifying signature...done |
| 38 | +Hello from firmware version 1 |
| 39 | +Today's lucky number: 0xAF |
| 40 | +PSA crypto init ok |
| 41 | +Start attestation verify test |
| 42 | +[ATTEST] GET_TOKEN: challenge_len=32 out_len=1024 |
| 43 | +Boot partition: 0x60000 (sz 31508, ver 0x1, type 0x601) |
| 44 | +Boot partition: 0x60000 (sz 31508, ver 0x1, type 0x601) |
| 45 | +[ATTEST] GET_TOKEN: dice_rc=0 token_len=356 |
| 46 | +attest_verify: token_len=356 |
| 47 | + 84 43 A1 01 26 A0 59 01 19 A5 0A 58 20 01 02 03 | .C..&.Y....X ... |
| 48 | + 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 | ................ |
| 49 | + 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 19 01 00 | ............ ... |
| 50 | + 58 21 01 AD 74 46 22 0C D0 5B 7A 1B 33 5E 37 28 | X!..tF"..[z.3^7( |
| 51 | + 0A 54 E6 DF 55 5B 40 A4 57 A0 43 0A 6D A5 AB E7 | .T..U[@.W.C.m... |
| 52 | + 5A 2B 5F 19 09 5C 58 30 E4 F9 83 72 7F A9 C5 CE | Z+_..\X0...r.... |
| 53 | + DD E0 79 A0 AD 0E 32 59 0A EA D3 10 43 BA 12 DD | ..y...2Y....C... |
| 54 | + 76 47 59 D1 42 8B 3A 75 F2 7E 75 CF 7D EE A2 B9 | vGY.B.:u.~u.}... |
| 55 | + AA AB 7E E9 91 27 F7 21 19 09 5E 19 30 00 19 09 | ..~..'.!..^.0... |
| 56 | + 5F 82 A3 01 67 73 68 61 2D 33 38 34 02 58 30 E4 | _...gsha-384.X0. |
| 57 | + F9 83 72 7F A9 C5 CE DD E0 79 A0 AD 0E 32 59 0A | ..r......y...2Y. |
| 58 | + EA D3 10 43 BA 12 DD 76 47 59 D1 42 8B 3A 75 F2 | ...C...vGY.B.:u. |
| 59 | + 7E 75 CF 7D EE A2 B9 AA AB 7E E9 91 27 F7 21 05 | ~u.}.....~..'.!. |
| 60 | + 68 77 6F 6C 66 62 6F 6F 74 A3 01 67 73 68 61 2D | hwolfboot..gsha- |
| 61 | + 33 38 34 02 58 30 D4 F2 89 AD E4 4E 6E EB F4 C6 | 384.X0.....Nn... |
| 62 | + 7D 24 13 AD 6C E6 DC A6 E9 FC 67 4F CC CB DE 52 | }$..l.....gO...R |
| 63 | + 4D FD E2 73 9D 2A D7 B3 DD DF B8 51 F4 43 C5 59 | M..s.*.....Q.C.Y |
| 64 | + 48 8A 30 46 D7 E3 05 6A 62 6F 6F 74 2D 69 6D 61 | H.0F...jboot-ima |
| 65 | + 67 65 58 40 E8 3F 76 44 15 7C 62 76 33 56 6D F7 | geX@.?vD.|bv3Vm. |
| 66 | + 2B E1 57 40 C4 F1 7D 21 D3 E9 90 57 25 8F A3 14 | +.W@..}!...W%... |
| 67 | + 44 ED 1B CE 01 CA EF 52 6B 41 4C 44 DF 4E 04 D4 | D......RkALD.N.. |
| 68 | + AA CC A8 7F 20 3D AA 39 CA 3A 9F C2 B1 C0 28 43 | .... =.9.:....(C |
| 69 | + DF BB 82 53 | ...S |
| 70 | +[ATTEST] GET_IAK_PUBKEY: out_len=65 |
| 71 | +[ATTEST] GET_IAK_PUBKEY: dice_rc=0 key_len=65 |
| 72 | +attest_verify: IAK pubkey (65 bytes): |
| 73 | + 04 42 9B 43 75 BE B0 E9 A0 39 61 64 68 20 1E FC | .B.Cu....9adh .. |
| 74 | + B6 68 F4 3E 25 74 F1 E2 CB 3D BD 09 A6 45 A7 E2 | .h.>%t...=...E.. |
| 75 | + 6F E1 54 B8 20 61 96 79 6A E8 31 83 3A 82 DE 1C | o.T. a.yj.1.:... |
| 76 | + 87 46 E1 45 49 3D 6F 56 78 F4 14 B6 42 47 DD F1 | .F.EI=oVx...BG.. |
| 77 | + AC | . |
| 78 | +attest_verify: IAK signature verified OK |
| 79 | +``` |
0 commit comments