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

Legacy-PSA bridge design: symmetric #8769

Conversation

gilles-peskine-arm
Copy link
Contributor

Document requirements for bridging legacy APIs and PSA APIs. The scope of this pull request is symmetric crytography (cipher/AEAD, MAC, key derivation, random generation). Together with #8657, it represents all the classes of cryptographic mechanisms that exist in some form in both APIs.

Follow-up to #8657, to be rebased once that is merged.

PR checklist

Please tick as appropriate and edit the reasons (e.g.: "backport: not needed because this is a new feature")

  • changelog no
  • backport no
  • tests no

Signed-off-by: Gilles Peskine <[email protected]>
Signed-off-by: Gilles Peskine <[email protected]>
Signed-off-by: Gilles Peskine <[email protected]>
Signed-off-by: Gilles Peskine <[email protected]>
@gilles-peskine-arm gilles-peskine-arm added needs-design-approval needs-review Every commit must be reviewed by at least two team members, component-crypto Crypto primitives and low-level interfaces needs-reviewer This PR needs someone to pick it up for review size-xs Estimated task size: extra small (a few hours at most) labels Jan 30, 2024
@mpg
Copy link
Contributor

mpg commented Jan 31, 2024

Sorry for picking on names, but if it's about symmetric crypto it's hardly about PK, but rather legacy-PSA?

@mpg mpg self-requested a review January 31, 2024 09:24
@gilles-peskine-arm gilles-peskine-arm changed the title PK-PSA bridge design: symmetric Legacy-PSA bridge design: symmetric Jan 31, 2024
@gilles-peskine-arm
Copy link
Contributor Author

Er, yeah, too much copy-paste. Too late for the branch name but I've changed the title.

Copy link
Contributor

@mpg mpg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.


Applications transitioning to the PSA API may wish to take advantage of PSA accelerated ciphers or opaque keys, while still constrained to provide the legacy `cipher.h` interface.

Mbed TLS 3.5 offers `mbedtls_cipher_setup_psa()` for this transition.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notes about this function:

  • it's marked as deprecated;
  • it only works for a limited number of ciphers / mechanisms : only AES with GCM, CCM, CCM*, CBC, ECB;
  • it doesn't when AES is driver-only (it should take advantage of a driver when present, tough, probably just won't work unless AES_C is also defined because sorting out the dependencies for this was not a priority considering this function is deprecated).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we can reasonably lift these limitations in 3.6.x if there's demand?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I don't foresee any problem here. The main reason it wasn't done is it didn't look like a priority.

* We do not seem to need this much in our own code. TLS has its own conversion, limited to the subset of mechanisms that it uses.
* The [“Symmetric encryption” section of the transition guide](../../psa-transition.md#symmetric-encryption) does not demonstrate the need for applications to write complex code to bridge the gap, the way it does with asymmetric crytography in Mbed TLS 3.5. However, there is arguably an omission there, since the transition guide does not show how to translate metadata.

[OPEN] Do we need conversion functions between encodings of cipher mechanisms?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm weakly inclined to say no. OTOH, those would be rather easy to provide. Also, I'll note we could easily add those in 3.6.x if requested.

@valeriosetti valeriosetti self-requested a review February 7, 2024 11:22
@valeriosetti valeriosetti removed the needs-reviewer This PR needs someone to pick it up for review label Feb 8, 2024
Copy link
Contributor

@valeriosetti valeriosetti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look good to me, but I was wondering if we have to address (by creating proper issues) open points 1 and 2 before merging this PR. Wdyt?

@gilles-peskine-arm
Copy link
Contributor Author

For the open points, we're currently planning no action, so I don't think we need issues.

@mpg mpg added approved Design and code approved - may be waiting for CI or backports and removed needs-design-approval needs-review Every commit must be reviewed by at least two team members, labels Feb 8, 2024
@mpg mpg merged commit e78c975 into Mbed-TLS:dev/gilles-peskine-arm/pk-psa-bridge-design Feb 8, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Design and code approved - may be waiting for CI or backports component-crypto Crypto primitives and low-level interfaces size-xs Estimated task size: extra small (a few hours at most)
Projects
Status: [3.6] Legacy-to-PSA migration helpers
Development

Successfully merging this pull request may close these issues.

3 participants