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

The PSA key store is too small for high-end platforms #9216

Closed
gilles-peskine-arm opened this issue May 31, 2024 · 3 comments · Fixed by #9240 or #9464
Closed

The PSA key store is too small for high-end platforms #9216

gilles-peskine-arm opened this issue May 31, 2024 · 3 comments · Fixed by #9240 or #9464
Labels
component-psa PSA keystore/dispatch layer (storage, drivers, …) enhancement size-s Estimated task size: small (~2d)

Comments

@gilles-peskine-arm
Copy link
Contributor

gilles-peskine-arm commented May 31, 2024

For high-end platforms such as Linux, the default size of the PSA key store is too small (32 entries).

This has a much bigger impact since Mbed TLS 3.6.0, which uses PSA for TLS 1.3 connections. So I'm filing this issue as a regression to solve in 3.6.1. If we end up not enabling TLS 1.3 by default at runtime in 3.6.1 for other reasons (needing psa_crypto_init, mandating server authentication, …) then this issue is less important.

For example, curl thinks 50 connections is reasonable, and I agree. 32 is too small in the default configuration.

High-end platforms really need a variable-size keystore. Unfortunately that's annoying to implement without realloc.

As of Mbed TLS 3.6.0, each key slot uses 56 bytes on a 64-bit platform, 40 bytes on a 32-bit platform.

@gilles-peskine-arm
Copy link
Contributor Author

By the way, the documentation of MBEDTLS_PSA_KEY_SLOT_COUNT is misleading:

Restrict the PSA library to supporting a maximum amount of simultaneously loaded keys.

Actually, the key store has a fixed size, and this is the size. Unlike what the current wording implies, there is currently no way to have an unrestricted key store size.

@bagder
Copy link

bagder commented Jun 1, 2024

curl not only thinks 50 connections is "reasonable". It has no specific upper limit in the number of parallel connections it can do (in a single thread), both in a command line tool use or by using the libcurl API directly. There are curl users using (tens of) thousands of parallel connections.

@gilles-peskine-arm
Copy link
Contributor Author

My proposal for 3.6.1: add a new compile-time boolean option MBEDTLS_PSA_KEY_SLOT_DYNAMIC, which the default config file defines. If undefined (as will be the case for users who have their own config file), you get the current behavior and code size. If defined, the key store will grow dynamically, so keys will effectively unlimited, at the cost of a little increase in code size and RAM usage (unacceptable for highly constrained platforms, but negligible for high-end platforms such as anything running Linux).

Given the time frame, I propose to do something that works for a large number of keys, but does not attempt to be efficient for a very large number of keys: there will be behavior that's linear in the number of keys. Performance should be acceptable for 1000 keys, not for 10000000 keys. We can revise this in 3.6.2 if there's a need.

@gilles-peskine-arm gilles-peskine-arm moved this to Design needed in Mbed TLS 4.0 planning Jun 5, 2024
@gilles-peskine-arm gilles-peskine-arm moved this from Design needed to Implementation in progress in Mbed TLS 4.0 planning Jun 19, 2024
@ronald-cron-arm ronald-cron-arm linked a pull request Jul 19, 2024 that will close this issue
5 tasks
@minosgalanakis minosgalanakis moved this to 3.6.1 patch release in Mbed TLS Epics Aug 2, 2024
@github-project-automation github-project-automation bot moved this to Done in Barriers Aug 26, 2024
@github-project-automation github-project-automation bot moved this from Implementation in progress to Done in Mbed TLS 4.0 planning Aug 26, 2024
@ronald-cron-arm ronald-cron-arm added the size-s Estimated task size: small (~2d) label Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component-psa PSA keystore/dispatch layer (storage, drivers, …) enhancement size-s Estimated task size: small (~2d)
Projects
Archived in project
Status: Done
Status: 3.6.1 patch release
3 participants