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

nrf_security: cracen: Exclude functions that are not needed #21033

Merged
merged 2 commits into from
Mar 26, 2025

Conversation

degjorva
Copy link
Contributor

@degjorva degjorva commented Mar 19, 2025

Add IS_ENABLED checks to ensure a given key type is needed. This improves rom usage for many standard use cases.

To make the sonar cloud pass I had to refactor export_ecc_public_key so added that as a separate commit to make it easy to see what was the intended functional change and what is refactoring.

@degjorva degjorva requested a review from a team as a code owner March 19, 2025 13:21
@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 19, 2025
@NordicBuilder
Copy link
Contributor

NordicBuilder commented Mar 19, 2025

CI Information

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

Inputs:

Sources:

sdk-nrf: PR head: bc6380fd62bab491c4920fc0e7b758e24a5d01c2

more details

sdk-nrf:

PR head: bc6380fd62bab491c4920fc0e7b758e24a5d01c2
merge base: ad1c5e6681f650195073cbaa2630705ee1252c24
target head (main): aa4c8e24d07063f2677724d95d56aee280d53ec0
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 (1)
subsys
│  ├── nrf_security
│  │  ├── src
│  │  │  ├── drivers
│  │  │  │  ├── cracen
│  │  │  │  │  ├── cracenpsa
│  │  │  │  │  │  ├── src
│  │  │  │  │  │  │  │ key_management.c

Outputs:

Toolchain

Version:
Build docker image:

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

  • ◻️ Toolchain
  • ◻️ Build twister
  • ◻️ Integration tests
    • ◻️ test-fw-nrfconnect-chip
    • ◻️ test-fw-nrfconnect-nrf-iot_cloud
    • ◻️ test-fw-nrfconnect-nrf_crypto
    • ◻️ test-fw-nrfconnect-tfm
    • ◻️ test-sdk-find-my
    • ◻️ test-sdk-dfu
Disabled integration tests
    • desktop52_verification
    • doc-internal
    • test-fw-nrfconnect-apps
    • test-fw-nrfconnect-ble_mesh
    • test-fw-nrfconnect-ble_samples
    • test-fw-nrfconnect-boot
    • test-fw-nrfconnect-fem
    • test-fw-nrfconnect-nfc
    • test-fw-nrfconnect-nrf-iot_libmodem-nrf
    • 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-mcuboot
    • test-sdk-pmic-samples
    • test-sdk-wifi
    • test-secdom-samples-public

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

@degjorva degjorva force-pushed the simple-rom-optimizations branch 3 times, most recently from 664a10d to 76db5d7 Compare March 19, 2025 15:57
if (psa_status != PSA_SUCCESS) {
return psa_status;
}
if (psa_curve != PSA_ECC_FAMILY_TWISTED_EDWARDS) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I see that in the handle_curve_family only the ed25519 is handled there, not the ed448. So could we use this check for both?

Not very strong opinion but I have a suggestion, it would be nice if the function handle_cracen_key_location does the same thing for every curve and not handle special cases. So it would be more readable for me if you place the logic for the ed25519 in this function and not inside the handle_curve_family. But as I said, this is a suggestion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Talked about this offline, but just a summary: ed448 does currently not work/is not supported for cracen, but a lot of the code for it exists. Removing that code sees counter productive as we might want to support it in the future. This is why I left it in, but it does not actually work.

The reason for the split between handle_curve_family and handle_identity_key is just that you need the attributes to separate between them, and am already at seven inputs to the handle_curve_family. Can make it work, but when I tried it I found it to be less readable than having a separate function.

Once sicrypto is fully removed this function will look a lot nicer as we don't need the entire last if statement for si_task creation, but at least this way of doing it makes it easier to #ifdef it out when not used, which I have done in a later commit

@degjorva degjorva force-pushed the simple-rom-optimizations branch from 76db5d7 to 47148a4 Compare March 20, 2025 15:11
@degjorva degjorva force-pushed the simple-rom-optimizations branch from 47148a4 to 9d9f90e Compare March 26, 2025 11:45
@degjorva degjorva requested review from Vge0rge and tomi-font March 26, 2025 11:45
Comment on lines +608 to +611
static psa_status_t handle_identity_key(const uint8_t *key_buffer, size_t key_buffer_size,
const struct sx_pk_ecurve *sx_curve, uint8_t *data,
struct si_sig_privkey *priv_key,
struct si_sig_pubkey *pub_key)
Copy link
Contributor

Choose a reason for hiding this comment

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

alignment off

Add IS_ENABLED checks to ensure a given key type is needed
This improves rom usage for many standard use cases

Signed-off-by: Dag Erik Gjørvad <dag.erik.gjorvad@nordicsemi.no>
Refactor export_ecc_public_key_from_keypair.
Split support functionality into separate functions

Signed-off-by: Dag Erik Gjørvad <dag.erik.gjorvad@nordicsemi.no>
@degjorva degjorva force-pushed the simple-rom-optimizations branch from 9d9f90e to bc6380f Compare March 26, 2025 13:50
@degjorva
Copy link
Contributor Author

Rebase for compliance

@endre-nordic endre-nordic merged commit d008975 into nrfconnect:main Mar 26, 2025
13 checks passed
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.

5 participants