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

[DI] Use interruptible sign/verify in X.509 & TLS #7292

Open
mpg opened this issue Mar 15, 2023 · 3 comments
Open

[DI] Use interruptible sign/verify in X.509 & TLS #7292

mpg opened this issue Mar 15, 2023 · 3 comments
Assignees
Labels
component-tls component-x509 size-l Estimated task size: large (2w+)

Comments

@mpg
Copy link
Contributor

mpg commented Mar 15, 2023

PSA recently gained interruptible functions for signing and verifying hash-based signatures. So far, these functions are not used by X.509 or TLS, but they should be used when MBEDTLS_USE_PSA_CRYPTO enabled, in all places that currently support restartable operations using the legacy API (that's currently just 1.2 with the ECDHE-ECDSA key exchange, including client authentication), in order to avoid feature gaps in PSA-based builds.

This task is to investigate how to achieve that goal, and break the work down in reasonnably-size and testable steps.

Note: execution of the work will probably depend on #7029

@mpg
Copy link
Contributor Author

mpg commented Mar 20, 2024

I've just been thinking: since the keys are held as PK contexts in X.509 and TLS so far, and those modules always use PK functions to operate on them (even when USE_PSA_CRYPTO is enabled), perhaps the easiest way to achieve what we want is to extend mbedtls_pk_verify_restartable() and mbedtls_pk_sign_restartable() so that they use the PSA interruptible API under the hood when USE_PSA_CRYPTO is enabled. That way absolutely no change to X.509 or TLS is needed.

This would probably involve providing an alternative definition of the type mbedtls_pk_restart_ctx when USE_PSA_CRYPTO is enabled, as well as providing PSA-based implementations of ecdsa_verify_rs_wrap and ecdsa_sign_rs_wrap when USE_PSA_CRYPTO is enabled.

@mpg
Copy link
Contributor Author

mpg commented Mar 20, 2024

Alternatively, as a completely different strategy, we can leave PK alone and instead change the TLS and X.509 code to:

  • create a PSA key from the PK context they have, using the newly introduced mbedtls_pk_import_into_psa(),
  • and then directly call PSA API functions on that PSA key.

I'm not sure which one is best. Perhaps changing PK is easier in the short term, but leaving it out of the equation is better in the long term?

@gilles-peskine-arm
Copy link
Contributor

In general I think pk is a good abstraction layer between X.509/TLS and crypto, and I think it can stay around for a while. I'd like to change some things about it in an incompatible way (in particular, make its concept of mechanism match the one in PSA), but I don't feel any need to remove it. Especially not until we have PSA functions to replace parse/write.

@paul-elliott-arm paul-elliott-arm self-assigned this Mar 20, 2024
@paul-elliott-arm paul-elliott-arm added the size-l Estimated task size: large (2w+) label May 17, 2024
@minosgalanakis minosgalanakis moved this to PSA Interruptible ECC (Part 2) in Mbed TLS Epics Jul 31, 2024
@yanesca yanesca moved this to 4.0 - PSA Crypto always on in Mbed TLS Backlog Aug 27, 2024
@yanesca yanesca removed this from Mbed TLS Epics Aug 27, 2024
@yanesca yanesca moved this to Design needed in Mbed TLS 4.0 planning Aug 29, 2024
@yanesca yanesca moved this from Design needed to Planning needed in Mbed TLS 4.0 planning Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component-tls component-x509 size-l Estimated task size: large (2w+)
Projects
Status: Planning needed
Status: No status
Development

No branches or pull requests

3 participants