Skip to content

Update ECDSA key policies to PSA API 1.4#535

Open
gilles-peskine-arm wants to merge 7 commits intoMbed-TLS:developmentfrom
gilles-peskine-arm:psa-verify-policy-relax
Open

Update ECDSA key policies to PSA API 1.4#535
gilles-peskine-arm wants to merge 7 commits intoMbed-TLS:developmentfrom
gilles-peskine-arm:psa-verify-policy-relax

Conversation

@gilles-peskine-arm
Copy link
Contributor

@gilles-peskine-arm gilles-peskine-arm commented Oct 17, 2025

Treat randomized and deterministic ECDSA as equivalent when verifying. This is a new requirement in the upcoming PSA Crypto 1.4 specification. A similar relaxation will apply to ML-DSA and SLH-DSA. Resolves #534

Stop allowing PSA_ALG_ECDSA_ANY when the policy is PSA_ALG_ECDSA(PSA_ALG_ANY_HASH). This was made an explicit requirement in the PSA Crypto 1.1 specification. Resolves #533

PR checklist

  • changelog provided
  • framework PR not required
  • mbedtls development PR not required because: crypto only
  • mbedtls 3.6 PR TODO (only the tests)
  • tests provided

This makes more sense than having the usage enforcement directly inside
the state-modifying function `psa_get_and_lock_key_slot_with_policy()`.

No intended behavior change.

Signed-off-by: Gilles Peskine <[email protected]>
We have C code that calculates the expected usage flags in the key policy
based on the usage flags passed in the key attributes during key creation.
Don't use `asymmetric_signature_key_policy` to validate that C code against
test data. It's fairly simple, and duplicated in Python code used in
automatically generated crypto storage and operation failure tests.

No change in test coverage of the library.

Signed-off-by: Gilles Peskine <[email protected]>
In `asymmetric_signature_key_policy` tests, express whether a given usage is
valid through a mask of usage flags. Formerly this was expressed as a mix of
test data (`payload_length_arg=0` to convey that no usage was allowed) and
logic in the code (to determine which usage was allowed).

Now we always use a valid payload length, even in tests that expect a policy
violation.

No change in test coverage of the library.

Signed-off-by: Gilles Peskine <[email protected]>
Descriptions get truncated at 66 columns and some had relevant information
after or near that limit.

Signed-off-by: Gilles Peskine <[email protected]>
Deterministic ECDSA with a hash, randomized ECDSA with a hash, and the
special case `PSA_ALG_DETERMINISTIC_ECDSA`, are three separate families of
algorithms, and the policy determines which one to use. Test that this is
enforced.

As a special case, `PSA_ALG_ECDSA(PSA_ALG_ANY_HASH)` allows
`PSA_ALG_DETERMINISTIC_ECDSA`. This is our historical behavior, but no
longer allowed by the PSA specification.
Mbed-TLS#533

Signed-off-by: Gilles Peskine <[email protected]>
Stop allowing `PSA_ALG_ECDSA_ANY` when the policy is
`PSA_ALG_ECDSA(PSA_ALG_ANY_HASH)`. This was our historical behavior,
but no longer allowed by the PSA specification.
Fixes Mbed-TLS#533.

Document this and the other similar case `PSA_ALG_RSA_PKCS1V15_SIGN_RAW`
(which `PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_ANY_HASH)` does allow).

Signed-off-by: Gilles Peskine <[email protected]>
@gilles-peskine-arm gilles-peskine-arm added size-s Estimated task size: small (~2d) priority-medium Medium priority - this can be reviewed as time permits needs-ci Needs to pass CI tests labels Oct 17, 2025
If a key policy specifies the deterministic variant of ECDSA, the key
now allows verification with the randomized variant (which has
identical behavior), and vice versa.

Mbed-TLS#534

Signed-off-by: Gilles Peskine <[email protected]>
@gilles-peskine-arm gilles-peskine-arm added 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 and removed needs-ci Needs to pass CI tests labels Oct 17, 2025
@gilles-peskine-arm gilles-peskine-arm changed the title Psa verify policy relax Update ECDSA key policies to PSA API 1.4 Oct 17, 2025
@bjwtaylor bjwtaylor removed the needs-review Every commit must be reviewed by at least two team members label Jan 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-reviewer This PR needs someone to pick it up for review priority-medium Medium priority - this can be reviewed as time permits size-s Estimated task size: small (~2d)

Projects

Status: In Development

Development

Successfully merging this pull request may close these issues.

Treat randomized and deterministic ECDSA as equivalent when verifying PSA_ALG_ECDSA(PSA_ALG_ANY_HASH) should not allow PSA_ALG_ECDSA_ANY

2 participants