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

PSA core lite PR #2 with fake sample #20813

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

frkv
Copy link
Contributor

@frkv frkv commented Mar 9, 2025

This adds a fake sample in nrf/samples/crypto/psa_core_lite which can be used to compare build-sizes when enabling signature validation, encryption, hashing and RNG (with ED25519 optimizations for NSIB)

It is a draft-PR as it is not intended to be added. Please see #20812 for the code that can be added to NCS

@frkv frkv requested review from nvlsianpu, nordicjm and de-nordic March 9, 2025 21:05
@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 Mar 9, 2025
@NordicBuilder
Copy link
Contributor

NordicBuilder commented Mar 9, 2025

CI Information

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

Inputs:

Sources:

more details

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 (0)

Outputs:

Toolchain

Version:
Build docker image:

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

  • ❌ Toolchain
  • ❌ Build twister
  • ❌ Integration tests

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

Copy link

github-actions bot commented Mar 9, 2025

You can find the documentation preview for this PR here.

@frkv frkv force-pushed the psa_core_lite_2_with_sample branch from edb5b19 to fe16f55 Compare March 9, 2025 21:49
Copy link
Contributor

@nordicjm nordicjm left a comment

Choose a reason for hiding this comment

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

final commit OK

@NordicBuilder
Copy link
Contributor

NordicBuilder commented Mar 18, 2025

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

Name Old Revision New Revision Diff
zephyr nrfconnect/sdk-zephyr@a80a94e nrfconnect/sdk-zephyr#2637 nrfconnect/sdk-zephyr#2637/files

DNM label due to: 1 project with PR revision

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

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@frkv frkv force-pushed the psa_core_lite_2_with_sample branch from 3a8922d to 5a952f4 Compare March 27, 2025 13:00
frkv added 4 commits March 27, 2025 14:58
-Zephyr PR is work-in-progress. This message must be erased before
 it is ready to go in

-Adds convenience-macros for muliple combined configurations
 IS_ENABLED_ANY, IS_ENABLED_ALL
-Adds conenience-macros for aggregated configurations
 UTIL_CONCAT_OR and UTIL_CONCAT_AND

Signed-off-by: Frank Audun Kvamtrø <frank.kvamtro@nordicsemi.no>
-This adds a PSA core that is size optimized. Its intended usage is
 builds that are severely size-limited like bootloaders (NSIB and
 MCUboot).
-The functionality of the PSA core lite is limited to:
 -ECDSA/EdDSA verification (hash/message)
 -one-shot hash calculation
 -FW encryption/decryption (multi part operations)
-This core only supports resolving keys on PSA crypto driver level
 and only a limited set of key management functions (resolve, lock and
 destroy). There is no volatile key support or PSA ITS support.
-Added Kconfig PSA_CORE_LITE
-Added psa_core_lite (.c/.h)

NOTE: This commit requires a subsequent commit to allow for key and
attribute retrieval from KMU.

NOTE: PSA core lite is currently limited to nRF54L series devices

Signed-off-by: Frank Audun Kvamtrø <frank.kvamtro@nordicsemi.no>
-Adding an ifdef to prevent call to psa_verfy_message_builtin. This
 API is only possible to use in a full PSA core and is unnecessary
 when the driver(s) provides explict support for verify message

Signed-off-by: Frank Audun Kvamtrø <frank.kvamtro@nordicsemi.no>
-Providing an implementation for get_key_attributes (used for key
 management operations). When this API is called there are
 direct call to the following functions to populate
 psa_key_attributes_t:
 -cracen_kmu_get_key_slot
 -cracen_kmu_get_builtin_key
-Providing an implementation for get_key_buffer to get the keys in
 RAM for usage (if RAM is used).

The statement "old strategy" means that the convention of getting
information about keys available "in hardware" by doing the following
-Calling cracen_kmu_get_key_slot to get slot_number and lifetime
-Calling cracen_kmu_get_builtin_key using slot_number and lifetime to
 retrieve attributes and optionally key_buffer.

NOTE: This implementation uses direct calls to KMU APIs instead of
calling the Mbed TLS API mbedtls_psa_platform_get_builtin_key
to get slot_number and lifetime and using this in a call to
psa_driver_wrapper_get_builtin_key to retrieve attributes and optionally
the key buffer. This provides size optimization but prevent usage
of IKG keys (identity key, MKEK and MEXT)

Signed-off-by: Frank Audun Kvamtrø <frank.kvamtro@nordicsemi.no>
@frkv frkv force-pushed the psa_core_lite_2_with_sample branch from 5a952f4 to 8e4acf2 Compare March 27, 2025 14:04
frkv added 3 commits March 27, 2025 15:17
-This commit adds Kconfig PSA_CORE_LITE_NSIB_ED25519_OPTIMIZATIONS
 which (when enabled) calls low-level APIs for Ed25519 verify APIs
 without going through PSA Crypto Driver Wrappers. This gives
 optimized builds for NSIB, but doesn't promote reuse.

Signed-off-by: Frank Audun Kvamtrø <frank.kvamtro@nordicsemi.no>
-This sample is used to calculate the size of psa_core_lite version
 versus oberon-psa-core.
-This sample is currently only usable for nRF54L15
-This sample is only usable for CRACEN
-sample.yaml has targets for more and more enabled features:
 EDDSA
 -eddsa.cracen_lite/normal
 -eddsa_hash.cracen_lite/normal
 -eddsa_hash_encrypt.cracen_lite/normal
 -eddsa_hash_encrypt_rng.cracen_lite/normal
 ECDSA (verify_message)
 -ecdsa.cracen_lite/normal
 -ecdsa_hash.cracen_lite/normal
 -ecdsa_hash_encrypt.cracen_lite/normal
 -ecdsa_hash_encrypt_rng.cracen_lite/normal
 ECDSA (verify_hash)
 -ecdsa_verify_hash.cracen_lite/normal

Please utilize build targets rom_report and ram_report to compare the
build sizes between lite and normal

NOTE: This sample is not functional at the moment as it would require
provisioning keys on the device. It only ensures that all required APIs
are called and all code-paths are compiled

Signed-off-by: Frank Audun Kvamtrø <frank.kvamtro@nordicsemi.no>
-This commit adds a configuration in the lite.conf overlay to set
 CONFIG_PSA_CORE_LITE_NSIB_ED25519_OPTIMIZATIONS, which makes use
 of direct calls to Ed25519 APIs for CRACEN for optimized build-sizes.
 This adjustment makes the build-sizes slightly larger than the
 refactored CRACEN code in a coming pull request.

Signed-off-by: Frank Audun Kvamtrø <frank.kvamtro@nordicsemi.no>
@frkv frkv force-pushed the psa_core_lite_2_with_sample branch from 8e4acf2 to ff833be Compare March 27, 2025 14:18
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. DNM manifest manifest-zephyr
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants