Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tf-m: Add Attestation support for nRF54L15 #19040

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

hellesvik-nordic
Copy link
Contributor

Add support for PSA Attestation to the nRF54L15. Includes noup changes to TF-M repository.

Ref: NCSDK-22598

@NordicBuilder
Copy link
Contributor

NordicBuilder commented Nov 22, 2024

The following west manifest projects have changed revision in this Pull Request:

Name Old Revision New Revision Diff

All manifest checks OK

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@github-actions github-actions bot added the changelog-entry-required Update changelog before merge. Remove label if entry is not needed or already added. label Nov 22, 2024
@NordicBuilder
Copy link
Contributor

NordicBuilder commented Nov 22, 2024

CI Information

To view the history of this post, clich the 'edited' button above
Build number: 26

Inputs:

Sources:

sdk-nrf: PR head: 1337531253f473f79fa1a4ce72059ab2ed635268

more details

sdk-nrf:

PR head: 1337531253f473f79fa1a4ce72059ab2ed635268
merge base: 6dc332ec93525a1c40c1329c7449df659b9a6104
target head (main): 85bb3179eeda6d4c4aad9b7a3c745d072e38bf42
Diff

Github labels

Enabled Name Description
ci-disabled Disable the ci execution
ci-all-test Run all of ci, no test spec filtering will be done
ci-force-downstream Force execution of downstream even if twister fails
ci-run-twister Force run twister
ci-run-zephyr-twister Force run zephyr twister
List of changed files detected by CI (13)
lib
│  ├── identity_key
│  │  │ Kconfig
modules
│  ├── trusted-firmware-m
│  │  ├── CMakeLists.txt
│  │  ├── Kconfig.tfm.defconfig
│  │  ├── tfm_boards
│  │  │  ├── CMakeLists.txt
│  │  │  ├── common
│  │  │  │  │ attest_hal.c
│  │  │  ├── nrf54l15_cpuapp
│  │  │  │  │ config.cmake
samples
│  ├── tfm
│  │  ├── tfm_psa_template
│  │  │  ├── boards
│  │  │  │  │ nrf54l15dk_nrf54l15_cpuapp_ns.conf
│  │  │  ├── prj.conf
│  │  │  ├── sysbuild
│  │  │  │  ├── mcuboot
│  │  │  │  │  ├── boards
│  │  │  │  │  │  │ nrf54l15dk_nrf54l15_cpuapp.conf
subsys
│  ├── bootloader
│  │  ├── bl_storage
│  │  │  │ Kconfig
│  ├── nrf_security
│  │  ├── src
│  │  │  ├── drivers
│  │  │  │  ├── cracen
│  │  │  │  │  ├── sicrypto
│  │  │  │  │  │  ├── src
│  │  │  │  │  │  │  │ iksig.c
tests
│  ├── tfm
│  │  ├── tfm_psa_test
│  │  │  │ prj.conf
│  │  ├── tfm_regression_test
│  │  │  │ prj.conf

Outputs:

Toolchain

Version: aedb4c0245
Build docker image: docker-dtr.nordicsemi.no/sw-production/ncs-build:aedb4c0245_bece0367df

Test Spec & Results: ✅ Success; ❌ Failure; 🟠 Queued; 🟡 Progress; ◻️ Skipped; ⚠️ Quarantine

  • ◻️ Toolchain - Skipped: existing toolchain is used
  • ✅ Build twister
    • sdk-nrf test count: 1762
  • ❌ Integration tests
    • ✅ test-fw-nrfconnect-boot
    • ✅ test-fw-nrfconnect-chip
    • ❌ test-fw-nrfconnect-nrf-iot_cloud
    • ✅ test-fw-nrfconnect-nrf_crypto
    • ✅ test-fw-nrfconnect-tfm
    • ✅ test-fw-nrfconnect-zigbee
    • ✅ test-sdk-find-my
    • ✅ test-sdk-sidewalk
    • ✅ test-sdk-mcuboot
    • ✅ test-sdk-dfu
    • ⚠️ test-fw-nrfconnect-fw-update
Disabled integration tests
    • desktop52_verification
    • doc-internal
    • test_ble_nrf_config
    • test-fw-nrfconnect-apps
    • test-fw-nrfconnect-ble_mesh
    • test-fw-nrfconnect-ble_samples
    • test-fw-nrfconnect-fem
    • test-fw-nrfconnect-nfc
    • test-fw-nrfconnect-nrf-iot_libmodem-nrf
    • test-fw-nrfconnect-nrf-iot_lwm2m
    • test-fw-nrfconnect-nrf-iot_mosh
    • test-fw-nrfconnect-nrf-iot_positioning
    • test-fw-nrfconnect-nrf-iot_samples
    • test-fw-nrfconnect-nrf-iot_serial_lte_modem
    • test-fw-nrfconnect-nrf-iot_thingy91
    • test-fw-nrfconnect-nrf-iot_zephyr_lwm2m
    • test-fw-nrfconnect-proprietary_esb
    • test-fw-nrfconnect-ps
    • test-fw-nrfconnect-rpc
    • test-fw-nrfconnect-rs
    • test-fw-nrfconnect-thread
    • test-low-level
    • test-sdk-audio
    • test-sdk-pmic-samples
    • test-sdk-wifi
    • test-secdom-samples-public

Note: This message is automatically posted and updated by the CI

@NordicBuilder
Copy link
Contributor

You can find the documentation preview for this PR at this link. It will be updated about 10 minutes after the documentation build succeeds.

Note: This comment is automatically posted by the Documentation Publish GitHub Action.

Comment on lines 17 to 18
set(CONFIG_NRFX_RRAMC ON CACHE BOOL "Enable nrfx drivers for RRAMC")
add_compile_definitions(CONFIG_NRFX_RRAMC)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, we are already using a very minimal homemade RRAMC driver in TF-M. What are you doing this for exactly?
(Also the add_compile_definitions() line seems a bit weird, why is it needed?)

Copy link
Contributor Author

@hellesvik-nordic hellesvik-nordic Nov 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CONFIG_NRFX_RRAMC is used in attest_hal.c, which is used in both Zephyr and TF-M. For example here.
If I remove add_compile_definitions(), I get errors such as "CONFIG_NRFX_RRAMC" not defined. I don't know if this is the correct way to add it, I just copied it from cpuarch.cmake.
Do you think I should look for alternative ways to get this config included?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahem you are linking to add_compile_definitions(__NRF_TFM__) in cpuarch.cmake?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ups. Edited to change file name.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm okay, you are still linking to the example of __NRF_TFM__, I thought you'd have an example with CONFIG_NRFX_RRAMC. (After grepping I see there is none).
I am not sure, but it seems like this add_compile_definitions() could be unconditionally adding CONFIG_NRFX_RRAMC as a define? Or does it somehow get its value from the set() line above? Do you know how it works?
I'm wondering why don't we do this via Kconfig, as this is a Kconfig option.
This doesn't seem like a natural (or proper) way to do that, but I'm not sure.
What is this needed for exactly? Where do you get errors from?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What Im trying to do:
attest_hal.c is a file that can be ran either from zephyr or from TF-M.
This file depends on the correct Kconfig options being set. (CONFIG_NRFX_RRAMC in this case)
add_compile_definitions() is the way I found to make sure that TF-M has CONFIG_NRFX_RRAMC defined.
What is the best way to do this?

Copy link
Contributor Author

@hellesvik-nordic hellesvik-nordic Dec 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do you get errors from?

My errors were pretty much "CONFIG_NRFX_RRAMC not defined".
I will spend some more time looking into this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I talked to Tomi and added a check around the add_compile_definitions(), so it is only included for attestation.

@hellesvik-nordic
Copy link
Contributor Author

Rebase

@hellesvik-nordic hellesvik-nordic force-pushed the nrf54l15_attestation branch 2 times, most recently from edc363c to 5b35e9a Compare December 19, 2024 13:12
@hellesvik-nordic
Copy link
Contributor Author

Rebase

tomi-font
tomi-font previously approved these changes Dec 23, 2024
@@ -13,3 +13,12 @@ include(${PLATFORM_PATH}/common/${NRF_SOC_VARIANT}/config.cmake)

# Override PS_CRYPTO_KDF_ALG
set(PS_CRYPTO_KDF_ALG PSA_ALG_SP800_108_COUNTER_CMAC CACHE STRING "KDF Algorithm to use")


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

t->params.ik.privkey = privkey;
t->params.ik.signature = signature;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

@@ -114,17 +115,12 @@ static int finish_ecdsa_ik_sign(struct sitask *t, struct siwq *wq)
return exit_ikg(t);
}

static int start_ecdsa_ik_sign(struct sitask *t, struct siwq *wq)
static int start_ecdsa_ik_sign(struct sitask *t)
{
struct sx_pk_acq_req pkreq;
struct sx_pk_inops_ik_ecdsa_sign inputs;
int opsz;
size_t digestsz = sx_hash_get_digestsz(&t->u.h);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting digest size from this hash context won't work when calling psa_sign_hash(). This is because the hash context is never created since sx_hash_create() is not needed and therefore not called. Changing this line to:
size_t digestsz = sx_hash_get_alg_digestsz(t->params.ik.privkey->hashalg);
makes my tests pass

Comment on lines 46 to 47
This option adds support for an identity key stored in the KMU to TF-M.
The key is stored in an encrypted form and is decrypted
by the identity key library.
The identity key is an ECC secp256r1 key pair.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

column is 100 chars so more text can be on each line

@@ -115,7 +115,7 @@ if (${TFM_PARTITION_CRYPTO})
tfm_sprt
)

if (${TFM_PARTITION_INITIAL_ATTESTATION})
if ((${TFM_PARTITION_INITIAL_ATTESTATION}) AND CONFIG_IDENTITY_KEY_TFM)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ((${TFM_PARTITION_INITIAL_ATTESTATION}) AND CONFIG_IDENTITY_KEY_TFM)
if((${TFM_PARTITION_INITIAL_ATTESTATION}) AND CONFIG_IDENTITY_KEY_TFM)

# This is because bl_storage is a lib intended to be run from either the bootloader (Zephyr) or from TF-M.
# This is independent from the NS image's CONFIG_NRFX_RRAMC, which must be disabled, so we can not inherit
# this from app Kconfig.
if (TFM_PARTITION_INITIAL_ATTESTATION)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (TFM_PARTITION_INITIAL_ATTESTATION)
if(TFM_PARTITION_INITIAL_ATTESTATION)

@hellesvik-nordic
Copy link
Contributor Author

Rebase

@hellesvik-nordic hellesvik-nordic force-pushed the nrf54l15_attestation branch 2 times, most recently from 834e149 to 56a214b Compare February 17, 2025 14:29
bool "Identity key support in TF-M"
depends on HAS_HW_NRF_CC3XX
depends on TRUSTED_EXECUTION_NONSECURE
default y if SOC_NRF5340_CPUAPP || SOC_SERIES_NRF91X
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this defaulting to y? This will default to on when someone builds hello world

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I removed the default

@hellesvik-nordic hellesvik-nordic force-pushed the nrf54l15_attestation branch 4 times, most recently from 83feae5 to 121be49 Compare February 19, 2025 09:24
Add support for PSA Attestation to the nRF54L15.

Ref: NCSDK-22598
Signed-off-by: Sigurd Hellesvik <sigurd.hellesvik@nordicsemi.no>
Add support for sign_digest support to silex sicrypto drivers for
iksign.c, making it possible to sign_digest for the IKG.

Signed-off-by: Sigurd Hellesvik <sigurd.hellesvik@nordicsemi.no>
Copy link

After documentation is built, you will find the preview for this PR here.

Preview links for modified nRF Connect SDK documents:

https://ncsdoc.z6.web.core.windows.net/PR-19040/nrf/app_dev/device_guides/fem/fem_nrf21540_gpio.html
https://ncsdoc.z6.web.core.windows.net/PR-19040/nrf/app_dev/device_guides/fem/fem_nrf21540_gpio_spi.html
https://ncsdoc.z6.web.core.windows.net/PR-19040/nrf/app_dev/device_guides/fem/fem_nrf2220.html
https://ncsdoc.z6.web.core.windows.net/PR-19040/nrf/app_dev/device_guides/fem/fem_simple_gpio.html
https://ncsdoc.z6.web.core.windows.net/PR-19040/nrf/app_dev/device_guides/fem/index.html
https://ncsdoc.z6.web.core.windows.net/PR-19040/nrf/app_dev/device_guides/nrf54h/index.html
https://ncsdoc.z6.web.core.windows.net/PR-19040/nrf/app_dev/device_guides/nrf54h/ug_nrf54h20_architecture_lifecycle.html
https://ncsdoc.z6.web.core.windows.net/PR-19040/nrf/app_dev/device_guides/nrf54h/ug_nrf54h20_custom_pcb.html
https://ncsdoc.z6.web.core.windows.net/PR-19040/nrf/app_dev/device_guides/nrf54h/ug_nrf54h20_gs.html
https://ncsdoc.z6.web.core.windows.net/PR-19040/nrf/app_dev/device_guides/wifi_coex.html
https://ncsdoc.z6.web.core.windows.net/PR-19040/nrf/dev_model_and_contributions/adding_code.html
https://ncsdoc.z6.web.core.windows.net/PR-19040/nrf/drivers/wifi.html
https://ncsdoc.z6.web.core.windows.net/PR-19040/nrf/libraries/networking/downloader.html
https://ncsdoc.z6.web.core.windows.net/PR-19040/nrf/protocols/bt/bt_mesh/dfu_over_bt_mesh.html
https://ncsdoc.z6.web.core.windows.net/PR-19040/nrf/protocols/lte/index.html
https://ncsdoc.z6.web.core.windows.net/PR-19040/nrf/protocols/matter/index.html
https://ncsdoc.z6.web.core.windows.net/PR-19040/nrf/releases_and_maturity/abi_compatibility.html
https://ncsdoc.z6.web.core.windows.net/PR-19040/nrf/releases_and_maturity/known_issues.html
https://ncsdoc.z6.web.core.windows.net/PR-19040/nrf/releases_and_maturity/migration/migration_guide_2.8.html
https://ncsdoc.z6.web.core.windows.net/PR-19040/nrf/releases_and_maturity/migration/migration_guide_2.9.0-nrf54h20-rc1.html
https://ncsdoc.z6.web.core.windows.net/PR-19040/nrf/releases_and_maturity/release_notes.html
https://ncsdoc.z6.web.core.windows.net/PR-19040/nrf/releases_and_maturity/releases/release-notes-2.9.0-nrf54h20-rc1.html
https://ncsdoc.z6.web.core.windows.net/PR-19040/nrf/releases_and_maturity/releases/release-notes-changelog.html
https://ncsdoc.z6.web.core.windows.net/PR-19040/nrf/samples/matter.html
doc/nrf/samples/matter.rst
https://ncsdoc.z6.web.core.windows.net/PR-19040/nrf/samples/bluetooth/fast_pair/locator_tag/README.html
https://ncsdoc.z6.web.core.windows.net/PR-19040/nrf/samples/cellular/nrf_cloud_multi_service/README.html
https://ncsdoc.z6.web.core.windows.net/PR-19040/nrf/samples/suit/recovery/README.html

Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog-entry-required Update changelog before merge. Remove label if entry is not needed or already added.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants