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: drivers: cracen: adding support for ed25519 without sicrypto #19812

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

Conversation

degjorva
Copy link
Contributor

@degjorva degjorva commented Jan 9, 2025

Removing the sicrypto implementation of ed25519 and ed25519ph.
Added implementation in cracenpsa of ed25519 and ed25519ph
Updated cracenpsa to support new implementation and
remove references to old

…rypto

Adding support directly using silexpk/sxsymcrypt files for ed25519
This bypasses sicrypto, which saves on flash usage
Primarily intended for bootloader usecase

Signed-off-by: Dag Erik Gjørvad <[email protected]>
@degjorva degjorva added the DNM label Jan 9, 2025
@degjorva degjorva requested review from a team as code owners January 9, 2025 09:02
@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 Jan 9, 2025
@degjorva degjorva removed the changelog-entry-required Update changelog before merge. Remove label if entry is not needed or already added. label Jan 9, 2025
@NordicBuilder
Copy link
Contributor

NordicBuilder commented Jan 9, 2025

CI Information

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

Inputs:

Sources:

sdk-nrf: PR head: 26c4896cb0337a6bffdd0274d36c192cc24840c4

more details

sdk-nrf:

PR head: 26c4896cb0337a6bffdd0274d36c192cc24840c4
merge base: 6e0cb3a5efefa5417863050198c99afacfcd9686
target head (main): f38d3119502c014935538628b3305009dd0697ff
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 (6)
subsys
│  ├── nrf_security
│  │  ├── src
│  │  │  ├── drivers
│  │  │  │  ├── cracen
│  │  │  │  │  ├── cracenpsa
│  │  │  │  │  │  ├── cracenpsa.cmake
│  │  │  │  │  │  ├── include
│  │  │  │  │  │  │  │ cracen_psa.h
│  │  │  │  │  │  ├── src
│  │  │  │  │  │  │  ├── ed25519.c
│  │  │  │  │  │  │  ├── key_management.c
│  │  │  │  │  │  │  │ sign.c
│  │  │  │  │  │ psa_driver.Kconfig

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_crypto
    • 🟠 test-fw-nrfconnect-tfm
    • 🟠 test-sdk-find-my
    • 🟠 test-sdk-sidewalk
    • 🟠 test-sdk-dfu
    • ⚠️ test-fw-nrfconnect-nrf-iot_cloud
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-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_nrf_provisioning
    • 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-ps
    • test-fw-nrfconnect-rpc
    • test-fw-nrfconnect-rs
    • test-fw-nrfconnect-thread
    • test-fw-nrfconnect-zigbee
    • 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

@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.

@degjorva degjorva force-pushed the no-sicrypto-ED25519 branch from 0c0a5d5 to 933f5a8 Compare January 9, 2025 13:36
@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 Jan 9, 2025
@degjorva degjorva force-pushed the no-sicrypto-ED25519 branch 3 times, most recently from 21feb07 to e54e7e5 Compare January 13, 2025 14:12
@@ -400,3 +400,10 @@ config PSA_WANT_KEY_TYPE_SRP_PUBLIC_KEY
bool "SRP public key support" if !MBEDTLS_PROMPTLESS
help
SRP public key support.

comment "Nordic added alternative cracen driver"
Copy link
Contributor

Choose a reason for hiding this comment

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

why does this need a comment and why is it using comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does not, which is why it has been removed? That is an old commit that will be squashed before pull, but lives there since it the old commit might have a bootloader usecase

Comment on lines 365 to 371
const uint8_t *message);

int ed25519_verify(const uint8_t *pubkey, const char *message,
size_t message_length, const char *signature);

int create_ed25519_pubkey(const uint8_t *ed25519,
uint8_t *pubkey);
Copy link
Contributor

Choose a reason for hiding this comment

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

the secondary lines of these seem indented to odd lengths, plus the line length is 100 so why are these being chopped into 2 lines even when combined they don't reach 100 characters?

Comment on lines 15 to 17
char workmem[160];
struct sxhash hashopctx;
char pointr_buffer[64];
Copy link
Contributor

Choose a reason for hiding this comment

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

use defines for lengths

Comment on lines 47 to 63
r = sx_hash_feed(&hashopctx, workmem+32, 32);
if (r != 0) {
return r;
}
r = sx_hash_feed(&hashopctx, message, 100);
if (r != 0) {
return r;
}
r = sx_hash_digest(&hashopctx, workmem+96);
if (r != 0) {
return r;
}

/* Perform point multiplication R = [r]B. This is the encoded point R,
* which is the first part of the signature.
*/
r = sx_ed25519_ptmult((const struct sx_ed25519_dgst *)(workmem + 96),
Copy link
Contributor

Choose a reason for hiding this comment

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

magic numbers everywhere, get rid of them

if (r != 0) {
return r;
}
r = sx_hash_feed(&hashopctx, workmem+32, 32);
Copy link
Contributor

Choose a reason for hiding this comment

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

x + x with spaces like below

Comment on lines 30 to 31
#if CONFIG_PSA_NEED_NO_SI_CRYPTO_ED25519
#else
Copy link
Contributor

Choose a reason for hiding this comment

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

first this is a define, secondly, if !defined(x) ?

@@ -605,8 +608,10 @@ static psa_status_t export_ecc_public_key_from_keypair(const psa_key_attributes_
int si_status = 0;
psa_algorithm_t key_alg = psa_get_key_algorithm(attributes);
const struct sx_pk_ecurve *sx_curve;
#if CONFIG_PSA_NEED_NO_SI_CRYPTO_ED25519
Copy link
Contributor

Choose a reason for hiding this comment

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

as above


#if CONFIG_PSA_NEED_NO_SI_CRYPTO_ED25519
si_status = create_ed25519_pubkey(key_buffer, data);
*data_length = 32;
Copy link
Contributor

Choose a reason for hiding this comment

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

as above

const struct sx_pk_ecurve *sx_curve;
#if CONFIG_PSA_NEED_NO_SI_CRYPTO_ED25519
#else

Copy link
Contributor

Choose a reason for hiding this comment

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

you just added these in the previous commit... squash changes

@degjorva degjorva force-pushed the no-sicrypto-ED25519 branch 5 times, most recently from 1b7981b to 719961c Compare January 14, 2025 09:46
Update the removes the sicrypto drivers when using ed25519
with cracen. Adds the functionality to cracenpsa
Also does the same for ed25519ph, as their
dependencies were interwoven

Signed-off-by: Dag Erik Gjørvad <[email protected]>
@degjorva degjorva force-pushed the no-sicrypto-ED25519 branch from 719961c to 26c4896 Compare January 14, 2025 09:50
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants