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

Tighten context management in ALT implementations #4451

Closed
gilles-peskine-arm opened this issue Apr 30, 2021 · 0 comments · Fixed by #4595
Closed

Tighten context management in ALT implementations #4451

gilles-peskine-arm opened this issue Apr 30, 2021 · 0 comments · Fixed by #4595
Assignees
Labels
component-crypto Crypto primitives and low-level interfaces size-s Estimated task size: small (~2d)

Comments

@gilles-peskine-arm
Copy link
Contributor

gilles-peskine-arm commented Apr 30, 2021

Context and rationale

Alternative implementations of whole modules may define their own context type. We do not explicitly specify whether an alternative implementation is allowed to maintain a pointer to contexts while no function using this context is active, or to remember the address of a context inside the context itself. As a consequence, it is not permitted for applications to move a context structure in memory, which can happen if the structure lives in managed memory.

Our own implementation of mbedtls_aes_context takes advantage of this implicit permission to maintain a pointer to the context: ctx->rk points inside ctx->buf (this is done for the sole sake of the MBEDTLS_PADLOCK_C implementation, because it requires a particular alignment in memory). This is a problem in practice: #2147.

Proposal

Document that in Mbed TLS 3, alternative implementations must allow moving a context structure in memory while no function operating on this context is active.

The reason this needs to be done in 3.0 is that it can break some existing applications.

This is a sort of extension of #4371.

Work items for 3.0

  • Write the requisite documentation. It's basically one paragraph, but I don't know where it would go.

Work items for 3.x

@gilles-peskine-arm gilles-peskine-arm added component-crypto Crypto primitives and low-level interfaces mbedtls-3 size-s Estimated task size: small (~2d) labels Apr 30, 2021
gilles-peskine-arm added a commit to gilles-peskine-arm/mbedtls that referenced this issue Jun 1, 2021
Fix Mbed-TLS#4451.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
gilles-peskine-arm added a commit to gilles-peskine-arm/mbedtls that referenced this issue Jun 14, 2021
Fix Mbed-TLS#4451.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
gilles-peskine-arm added a commit to gilles-peskine-arm/mbedtls that referenced this issue Jun 14, 2021
Fix Mbed-TLS#4451.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
@mpg mpg closed this as completed in #4595 Jun 15, 2021
Kazuyuki-Kimura pushed a commit to Kazuyuki-Kimura/mbedtls that referenced this issue Jun 20, 2021
Fix Mbed-TLS#4451.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
@bensze01 bensze01 modified the milestone: Mbed TLS 4.0 Jul 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component-crypto Crypto primitives and low-level interfaces size-s Estimated task size: small (~2d)
Projects
None yet
2 participants