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

mbedtls: make PSA_WANT_KEY_TYPE_xxx_KEY_PAIR_BASIC promptless #82862

Conversation

valeriosetti
Copy link
Collaborator

PSA_WANT_KEY_TYPE_xxx_KEY_PAIR_BASIC will be selected by any of:

  • PSA_WANT_KEY_TYPE_xxx_KEY_PAIR_IMPORT
  • PSA_WANT_KEY_TYPE_xxx_KEY_PAIR_EXPORT
  • PSA_WANT_KEY_TYPE_xxx_KEY_PAIR_GENERATE
  • PSA_WANT_KEY_TYPE_xxx_KEY_PAIR_DERIVE.

This mechanism mimic what Mbed TLS already does internally with the corresponding build symbols.

modules/mbedtls/Kconfig.psa Outdated Show resolved Hide resolved
modules/mbedtls/Kconfig.psa.logic Show resolved Hide resolved
@valeriosetti valeriosetti force-pushed the set-psa-want-key-pair-basic-promptless branch from 29b7f97 to d910be5 Compare December 12, 2024 09:53
tomi-font
tomi-font previously approved these changes Dec 12, 2024
Comment on lines +60 to +67
# In Mbed TLS the PSA_WANT_KEY_TYPE_[ECC|RSA|DH]_KEY_PAIR_BASIC build symbols
# are automatically enabled whenever any other _IMPORT, _EXPORT, _GENERATE or
# _DERIVE feature is set for the same key type
# (see "modules/crypto/mbedtls/include/psa/crypto_adjust_config_key_pair_types.h").
# Therefore we mimic the same pattern with Kconfigs as follows:
# - do not add _BASIC Kconfigs to the automatic generated file (KCONFIG_PATH);
# - add _BASIC Kconfigs to Kconfig.psa.logic and let them "default y" as soon as
# any other _IMPORT, _EXPORT, _GENERATE or _DERIVE Kconfigs are enabled.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure such a length comment was needed (could have been more generic), but it's good as is to me. 🙂

tomi-font
tomi-font previously approved these changes Dec 12, 2024
PSA_WANT_KEY_TYPE_xxx_KEY_PAIR_BASIC build symbols are automatically
enabled in Mbed TLS header files whenever any key pair feature between
IMPORT,EXPORT, GENERATE,DERIVE is set. So we mimic the same behavior with
Kconfig symbols:
- do not add BASIC to the automatic generated Kconfig file;
- let BASIC be auto-enabled as soon as any other feature (IMPORT,EXPORT,
  GENERATE,DERIVE) is enabled for the same key type.

The 2nd point is achieved by adding a new Kconfig file which is meant
to hold the logic between PSA_WANT symbols. This is necessary because
Kconfig.psa is automatically generated.

Signed-off-by: Valerio Setti <[email protected]>
Rename Kconfig.psa to Kconfig.psa.auto to emphasize that this file
is automatically generated.

Signed-off-by: Valerio Setti <[email protected]>
@valeriosetti valeriosetti force-pushed the set-psa-want-key-pair-basic-promptless branch from 098b37c to b0e02bc Compare December 12, 2024 11:52
CONFIG_PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_BASIC is promptless so it cannot
be selected. Moreover it's also automatically enabled by
CONFIG_PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_GENERATE in the same overlay file
so there would be no need to explicitly enable it.

As for the IMPORT, EXPORT, DERIVE they are needed for the TLS connection
to work properly. Previously it was working because at least IMPORT and
EXPORT are internally enabled by Mbed TLS at build time. So here we
are basically doing the same enablements with Kconfigs in clear.

Signed-off-by: Valerio Setti <[email protected]>
Copy link
Collaborator

@frkv frkv left a comment

Choose a reason for hiding this comment

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

LGTM

@kartben kartben merged commit ff8b970 into zephyrproject-rtos:main Dec 16, 2024
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants