Skip to content

Conversation

@maxd-nordic
Copy link
Contributor

Add support to generate a key on-device.
Also: print usage instructions to make commands less painful to use.

We have a usecase to generate p256 keys for use with credentials shell on-device.
Possibly, the option to read the private key should be behind a Kconfig too.

size_t key_bits;

/* Initialize PSA Crypto */
status = psa_crypto_init();
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be better to add a mutex lock.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

psa_crypto_init can be called any number of times and will just return if already initialized. No mutex necessary.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, but it's more safe in multi-thread environment

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 do you mean? only one thread can access this function.

Copy link
Contributor

Choose a reason for hiding this comment

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

Other threads may call psa_crypto_init(), not only generate_ecdsa_keypair.
Anyway, as the doc said it can be called in multiple times, it's just a suggestion.

Print usage hint instead of unhelpful
"wrong parameter count" message.

Signed-off-by: Maximilian Deubel <[email protected]>
@maxd-nordic maxd-nordic force-pushed the tls_credentials_shell_generate_key_upstream branch from bc10d51 to e603035 Compare December 10, 2025 09:41
@maxd-nordic maxd-nordic requested a review from yvesll December 10, 2025 09:41
@maxd-nordic maxd-nordic force-pushed the tls_credentials_shell_generate_key_upstream branch from e603035 to aeaa27d Compare December 10, 2025 09:58
Add command to generate a key on-device.
Currently, only p256 keys are supported.

Signed-off-by: Maximilian Deubel <[email protected]>
@maxd-nordic maxd-nordic force-pushed the tls_credentials_shell_generate_key_upstream branch 3 times, most recently from f3c2a40 to 22923c5 Compare December 10, 2025 12:35
@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants