-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Backport 3.6: Make some edge cases of not-supported or invalid mechanisms more uniform #9782
Merged
yanesca
merged 8 commits into
Mbed-TLS:mbedtls-3.6
from
gilles-peskine-arm:psa-storage-test-cases-never-supported-preliminaries-3.6
Dec 10, 2024
Merged
Backport 3.6: Make some edge cases of not-supported or invalid mechanisms more uniform #9782
yanesca
merged 8 commits into
Mbed-TLS:mbedtls-3.6
from
gilles-peskine-arm:psa-storage-test-cases-never-supported-preliminaries-3.6
Dec 10, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Uniformly return PSA_ERROR_NOT_SUPPORTED if given an algorithm that includes a hash, but that hash algorithm is not supported. This will make it easier to have a uniform treatment of unsupported hashes in automatically generated tests. Signed-off-by: Gilles Peskine <[email protected]>
Allow imports of an ECC public key on an unsupported curve to return INVALID_ARGUMENT rather than NOT_SUPPORTED. This can happen in our library code in edge cases when only certain curve families are supported, and it's acceptable. The new code does not trigger yet, but it will be useful for a future commit "Do run not-supported test cases on not-implemented mechanisms" (forward port of 995d7d4). Signed-off-by: Gilles Peskine <[email protected]>
gilles-peskine-arm
added
component-crypto
Crypto primitives and low-level interfaces
needs-ci
Needs to pass CI tests
priority-high
High priority - will be reviewed soon
size-xs
Estimated task size: extra small (a few hours at most)
labels
Nov 19, 2024
5 tasks
gilles-peskine-arm
force-pushed
the
psa-storage-test-cases-never-supported-preliminaries-3.6
branch
from
November 19, 2024 17:42
0d712f9
to
25f5eb7
Compare
Following "PSA sign/verify: more uniform error on an unsupported hash", some error cases are detected earlier, so there is some sloppiness in test case dependencies that is not longer acceptable. * In test_suite_psa_crypto, one test case for a hash+sign algorithm now returns NOT_SUPPORTED rather than INVALID_ARGUMENT when the hash is not supported and the key is invalid. * In test_suite_psa_crypto_se_driver_hal_mocks, some test cases now error out before reaching the mocks rather than after when they attempt to use an unsupported hash. Signed-off-by: Gilles Peskine <[email protected]>
gilles-peskine-arm
force-pushed
the
psa-storage-test-cases-never-supported-preliminaries-3.6
branch
from
November 19, 2024 21:12
25f5eb7
to
009f517
Compare
gilles-peskine-arm
force-pushed
the
psa-storage-test-cases-never-supported-preliminaries-3.6
branch
from
November 20, 2024 19:35
76939b7
to
8144435
Compare
ECDSA has two variants: deterministic (PSA_ALG_DETERMINISTIC_ECDSA) and randomized (PSA_ALG_ECDSA). The two variants are different for signature but identical for verification. Mbed TLS accepts either variant as the algorithm parameter for verification even when only the other variant is supported, so we need to handle this as a special case when generating not-supported test cases. In this commit: * Add manually written not-supported test cases for the signature operation when exactly one variant is supported. * Add manually written positive test cases for the verification operation when exactly one variant is supported. * Register that !ECDSA but DETERMINISTIC_ECDSA is not tested yet (Mbed-TLS#9592). A commit in the framework will take care of automatically generated test cases. Signed-off-by: Gilles Peskine <[email protected]>
Signed-off-by: Gilles Peskine <[email protected]>
In particular, if interruptible ECDSA is supported but not the deterministic variant, detect this in psa_sign_hash_start(), whereas before start() would succeed and psa_sign_hash_complete() would fail. This avoids an inconsistency between psa_sign_hash() and psa_sign_hash_start() that would be annoying to handle in test_suite_psa_crypto_op_fail. Signed-off-by: Gilles Peskine <[email protected]>
For ECDSA verification, there is no difference between the deterministic and randomized algorithm. The PSA core consider the two variants as identical as far as key policies are concerned, and the built-in implementation accepts either variant even if only the other variant is supported for signature. In p256-m, accept to perform an ECDSA verification when the algorithm is specified as deterministic ECDSA. This makes the behavior identical to the built-in implementation, which is less surprising for users and saves us from having to cope with a difference in our testing. Signed-off-by: Gilles Peskine <[email protected]>
gilles-peskine-arm
force-pushed
the
psa-storage-test-cases-never-supported-preliminaries-3.6
branch
from
November 21, 2024 08:48
8144435
to
ad04f96
Compare
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
Nov 21, 2024
Merged
5 tasks
Signed-off-by: Gilles Peskine <[email protected]>
Merged
5 tasks
davidhorstmann-arm
approved these changes
Dec 3, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, faithful backport!
gilles-peskine-arm
removed
the
needs-reviewer
This PR needs someone to pick it up for review
label
Dec 10, 2024
yanesca
approved these changes
Dec 10, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a faithful backport of the original.
Merged
via the queue into
Mbed-TLS:mbedtls-3.6
with commit Dec 10, 2024
a770f30
4 of 6 checks passed
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
needs-review
Every commit must be reviewed by at least two team members,
priority-high
High priority - will be reviewed soon
size-xs
Estimated task size: extra small (a few hours at most)
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix a few edge cases related to invalid or not-supported cryptographic mechanisms in PSA. These are not user-level bugs, but the changes here make testing easier, in particular allowing more uniform automatically generated test cases.
This is the (small) part of the forward port of #9025 that goes into each branch. Most of the changes will be in the framework repository.
PR checklist