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

Allow PSA hash operations without psa_crypto_init #6470

Draft
wants to merge 6 commits into
base: development
Choose a base branch
from

Conversation

gilles-peskine-arm
Copy link
Contributor

@gilles-peskine-arm gilles-peskine-arm commented Oct 21, 2022

Status: proposal — it turns out #6549 doesn't actually need this, at least at the moment.

Officially allow PSA hash operations (psa_hash_compute, psa_hash_verify, psa_hash_setup, and functions on multipart hash operations) even if the library hasn't been initialized with psa_crypto_init. This has always worked (with the exception of drivers requiring initialization), but was documented as “implementation-defined” (which doesn't really make sense since we are the implementation and our documentation should be defining the implementation-defined behavior).

This is possibly on the critical path for simplifying the handling of builds where some algorithms are provided via PSA and others via legacy crypto, especially in algorithms such as RSA and deterministic ECDSA that use a hash inside.

Changelog: yes

Backport: maybe (it's technically a new feature, but the library code isn't changing)

Our implementation of hash functions does not check whether the library has
been initialized. Other implementations (including services built on top of
Mbed TLS) might require initialization, but it's not our job to mention
that (it's the job of these other implementations' documentation and of the
PSA specification).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
…alization

The documentation dates back from when it doubled as the PSA specification.
Nowadays this is just the documentation of Mbed TLS, so it should document
implementation-specific behavior. All functions that access a key or the
random generator require library initialization.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Hash functions don't actually require initializing the library. So don't do
it when testing.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
When testing hash operations in situations that can return
PSA_ERROR_BAD_STATE, do the testing both with an uninitialized library and
with an initialized library, in case there was some interference between
BAD_STATE due to the library initialization state and BAD_STATE due to the
operation state.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This is now tested, so we can promise it.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
@gilles-peskine-arm gilles-peskine-arm added enhancement needs-review Every commit must be reviewed by at least two team members, needs-reviewer This PR needs someone to pick it up for review component-psa PSA keystore/dispatch layer (storage, drivers, …) size-s Estimated task size: small (~2d) priority-medium Medium priority - this can be reviewed as time permits labels Oct 21, 2022
@@ -0,0 +1,4 @@
Features
* Document that PSA hash operations don't require psa_crypto_init(). This
has always been possible, but was not previously explicitly stated. This
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Except when there's a driver that requires initialization, but that's a preexisting bug. Making this promise makes the bug more pressing though, so it would be good to fix it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I disagree with the reasoning here. As you say, it's technically a new feature, so I'm not sure how 6469 can be considered a pre-existing bug.

Regardless, we really shouldn't write things that we know to be false, so we need to either mention 6469 as temporary limitation that will be lifted in the future, or (much preferred) solve 6469 before we merge this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am taking advantage of the fact that MBEDTLS_PSA_CRYPTO_DRIVERS is still considered experimental to declare that this a feature, not a bug.

It's still not clear to me that lifting the limitation is worth the effort (not in terms of coding, but in terms of impact).

In general terms:

* Which operations are supported.
* What entry point call sequences are possible.
* What drivers can expect in terms of input validity.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
@tom-daubney-arm
Copy link
Contributor

We are now converting older PRs to draft PRs where the following conditions are met: They have not been updated in the last 3 months, and they need work to complete; in this case there are conflicts.

@tom-daubney-arm tom-daubney-arm added needs-work historical-reviewed Reviewed & agreed to keep legacy PR/issue and removed needs-review Every commit must be reviewed by at least two team members, needs-reviewer This PR needs someone to pick it up for review historical-reviewing Currently reviewing (for legacy PR/issues) labels Jul 14, 2023
@tom-daubney-arm tom-daubney-arm marked this pull request as draft July 14, 2023 13:30
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, …) DO-NOT-MERGE enhancement historical-reviewed Reviewed & agreed to keep legacy PR/issue needs-work priority-medium Medium priority - this can be reviewed as time permits size-s Estimated task size: small (~2d)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants