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

Remove RNG parameters from LMS #168

Open
gilles-peskine-arm opened this issue Jan 24, 2025 · 2 comments · May be fixed by #182
Open

Remove RNG parameters from LMS #168

gilles-peskine-arm opened this issue Jan 24, 2025 · 2 comments · May be fixed by #182
Assignees
Labels
api-break This issue/PR breaks the API and must wait for a new major version size-s Estimated task size: small (~2d)

Comments

@gilles-peskine-arm
Copy link
Contributor

gilles-peskine-arm commented Jan 24, 2025

In TF-PSA-Crypto 1.0, all RNG calls will go to the PSA RNG. So public functions must no longer take an RNG callback (it would not be honored).

Legacy RNG callbacks have the following form:

int (*f_rng)(void *, unsigned char *, size_t), void *p_rng

The goal of this task is to update the functions in include/mbedtls/lms.h and src/{lms,lmots}.* that take an RNG argument:

  • Remove the f_rng and p_rng arguments from the function prototypes.
  • Change calls to f_rng to instead call psa_generate_random.
  • Change calling code accordingly.
  • Optional, may be done in a follow-up: where the calling code is setting up an entropy context and a DRBG context, and those are no longer needed, remove those contexts.
@gilles-peskine-arm gilles-peskine-arm added api-break This issue/PR breaks the API and must wait for a new major version size-s Estimated task size: small (~2d) labels Jan 24, 2025
@gilles-peskine-arm gilles-peskine-arm moved this to Implementation needed in Mbed TLS 4.0 planning Jan 24, 2025
@gilles-peskine-arm gilles-peskine-arm added the needs-design-approval Needs design discussion / approval label Jan 27, 2025
@gilles-peskine-arm gilles-peskine-arm moved this from Implementation needed to Design needed in Mbed TLS 4.0 planning Jan 27, 2025
@gilles-peskine-arm
Copy link
Contributor Author

Task on hold during rethink

A possible wrinkle: in the long term, we'd like to support explicit PSA contexts in non-PSA APIs, as requested in ARM-software/psa-api#77. Under that design, functions that take an RNG argument and no key argument should take a PSA context argument, and should make RNG calls through that context. Functions that have a key argument would use that key to determine the PSA context.

In many places, we already track a “context” in the form of RNG arguments that are passed down from API functions to legacy crypto calls. Rather than completely remove those RNG arguments, it could make sense to rewrite f_rng, p_rng to psa_context, and pass the psa_context down. When we reach a PSA API, we'd still only support the default context for now, in which the RNG is psa_get_random.

By the time of the 1.0 release, it's unlikely that the PSA crypto context API extension will be finalized, and in any case we do not intend to implement that context API until well after 1.0. So in 1.0, we would have a context parameter where the only supported value is NULL, and other values would be silently ignored. That doesn't seem very nice. But on the other hand, if we don't do it, then later we'll have to reintroduce a context parameter that's passed down, and more annoyingly, we'd have to add a with_psa_context variant of all the functions involved with an extra parameter. Is it worth having this temporarily in TF-PSA-Crypto 1.x and Mbed TLS 4.x, in order to avoid having to extend mbedtls APIs when we implement the context feature?

@gilles-peskine-arm
Copy link
Contributor Author

We do not currently consider multiple crypto contexts to be high priority in TF-PSA-Crypto and Mbed TLS, and it will likely have consequences on the API that go beyond the functions that take an RNG argument. Therefore it's unlikely that whatever we can do before 1.0 would be sufficient to finish the for multiple crypto contexts in 4.x. Hence, let's not bother with them at all, and go ahead and remove the RNG parameters.

@gilles-peskine-arm gilles-peskine-arm removed the needs-design-approval Needs design discussion / approval label Feb 17, 2025
@gilles-peskine-arm gilles-peskine-arm moved this from Design needed to Implementation needed in Mbed TLS 4.0 planning Feb 17, 2025
@bjwtaylor bjwtaylor self-assigned this Feb 24, 2025
@bjwtaylor bjwtaylor linked a pull request Feb 25, 2025 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-break This issue/PR breaks the API and must wait for a new major version size-s Estimated task size: small (~2d)
Projects
Status: Implementation needed
Development

Successfully merging a pull request may close this issue.

2 participants