Support ML-DSA-87 public keys in the PSA API #899

Open
opened 2026-09-07 12:15:24 -05:00 by gilles-peskine-arm · 0 comments
gilles-peskine-arm commented 2026-09-07 12:15:24 -05:00 (Migrated from github.com)

Support the ML-DSA-87 public key type to the PSA API:

  • Move the definition of PSA_KEY_TYPE_ML_DSA_PUBLIC_KEY to include/psa/crypto_values.h.
  • Declare PSA_WANT_KEY_TYPE_ML_DSA_PUBLIC_KEY in include/psa/crypto_config.h, default off. It will automatically be enabled in the full config.
    • Use this macro to guard code that handles ML-DSA public keys generically.
      *Declare PSA_WANT_KEY_TYPE_ML_DSA_87 in include/psa/crypto_config.h, default off. It will automatically be enabled in the full config. This is somewhat similar to PSA_WANT_ECC_xxx for ECC key types: we have a specific macro for individual key sets.
    • Use this macro in addition to the applicable size-independent macros to guard code that handles ML-DSA-87 specifically.
  • Create a new header drivers/pqcp/include/tf-psa-crypto/private/crypto_adjust_config_enable_pqcp.h.
    • Include it in include/tf-psa-crypto/build_info.h, after mbedtls/private/crypto_adjust_config_enable_builtins.h.
    • Enable TF_PSA_CRYPTO_PQCP_MLDSA_ENABLED when PSA_WANT_KEY_TYPE_ML_DSA_PUBLIC_KEY is enabled, and TF_PSA_CRYPTO_PQCP_MLDSA_87 when PSA_WANT_KEY_TYPE_ML_DSA_87 is enabled.
  • When the corresponding key type and size is enabled, take MLDSA into account in PSA_KEY_EXPORT_xxx_SIZE macros in include/psa/crypto_sizes.h. Move and rename auxiliary macros from drivers/pqcp/**.h where useful.
  • Support MLDSA public keys in psa_import_key().
    • Public keys are stored as is.
    • Validate the key data length in the core.
  • Support MLDSA public keys in psa_export_key() and psa_export_public_key.

All functions and macros must have unit tests in test_suite_psa_crypto.mldsa.data (create a new data file because the test data is big and we're trying to split up test_suite_psa_crypto.data). This should require only new test data, not new test code. We want both positive and negative tests (bad key size, not supported, buffer too small, etc. as applicable). There is no need to duplicate tests that are automatically generated.

In comments, document that the support for ML-DSA is still incomplete. No changelog entry.

Next steps: https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/900 then https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/901 and https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/902, going towards https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/637

Support the ML-DSA-87 public key type to the PSA API: * Move the definition of `PSA_KEY_TYPE_ML_DSA_PUBLIC_KEY` to `include/psa/crypto_values.h`. * Declare `PSA_WANT_KEY_TYPE_ML_DSA_PUBLIC_KEY` in `include/psa/crypto_config.h`, default off. It will automatically be enabled in the `full` config. * Use this macro to guard code that handles ML-DSA public keys generically. *Declare `PSA_WANT_KEY_TYPE_ML_DSA_87` in `include/psa/crypto_config.h`, default off. It will automatically be enabled in the `full` config. This is somewhat similar to `PSA_WANT_ECC_xxx` for ECC key types: we have a specific macro for individual key sets. * Use this macro in addition to the applicable size-independent macros to guard code that handles ML-DSA-87 specifically. * Create a new header `drivers/pqcp/include/tf-psa-crypto/private/crypto_adjust_config_enable_pqcp.h`. * Include it in `include/tf-psa-crypto/build_info.h`, after `mbedtls/private/crypto_adjust_config_enable_builtins.h`. * Enable `TF_PSA_CRYPTO_PQCP_MLDSA_ENABLED` when `PSA_WANT_KEY_TYPE_ML_DSA_PUBLIC_KEY` is enabled, and `TF_PSA_CRYPTO_PQCP_MLDSA_87` when `PSA_WANT_KEY_TYPE_ML_DSA_87` is enabled. * When the corresponding key type and size is enabled, take MLDSA into account in `PSA_KEY_EXPORT_xxx_SIZE` macros in `include/psa/crypto_sizes.h`. Move and rename auxiliary macros from `drivers/pqcp/**.h` where useful. * Support MLDSA public keys in `psa_import_key()`. * Public keys are stored as is. * Validate the key data length in the core. * Support MLDSA public keys in `psa_export_key()` and `psa_export_public_key`. All functions and macros must have unit tests in `test_suite_psa_crypto.mldsa.data` (create a new data file because the test data is big and we're trying to split up `test_suite_psa_crypto.data`). This should require only new test data, not new test code. We want both positive and negative tests (bad key size, not supported, buffer too small, etc. as applicable). There is no need to duplicate tests that are automatically generated. In comments, document that the support for ML-DSA is still incomplete. No changelog entry. Next steps: https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/900 then https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/901 and https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/902, going towards https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/637
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-Mbed-TLS/TF-PSA-Crypto#899
No description provided.