Skip to content

Commit 8141968

Browse files
Fix edge case with half-supported ECDSA: automatic test cases
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, suppress generated test cases for operation failures due to unsupported ECDSA when exactly one of the two ECDSA variants is supported. This edge case will only be tested manually (done in mbedtls or TF-PSA-Crypto in the commit "Fix edge case with half-supported ECDSA (manual test cases)"). Changes to the generated output: in `test_suite_psa_crypto_op_fail.generated.data`, wherever one of `!PSA_WANT_ALG_DETERMINISTIC_ECDSA` or `!PSA_WANT_ALG_ECDSA` appears as a dependency, add the other one. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
1 parent 78e4c8a commit 8141968

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

scripts/generate_psa_tests.py

+15
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,21 @@ def make_test_case(
266266
if reason == self.Reason.NOT_SUPPORTED:
267267
assert not_supported is not None
268268
tc.assumes_not_supported(not_supported)
269+
# Special case: if one of deterministic/randomized
270+
# ECDSA is supported but not the other, then the one
271+
# that is not supported in the signature direction is
272+
# still supported in the verification direction,
273+
# because the two verification algorithms are
274+
# identical. This property is how Mbed TLS chooses to
275+
# behave, the specification would also allow it to
276+
# reject the algorithm. In the generated test cases,
277+
# we avoid this difficulty by not running the
278+
# not-supported test case when exactly one of the
279+
# two variants is supported.
280+
if not_supported == 'PSA_WANT_ALG_ECDSA':
281+
tc.add_dependencies(['!PSA_WANT_ALG_DETERMINISTIC_ECDSA'])
282+
if not_supported == 'PSA_WANT_ALG_DETERMINISTIC_ECDSA':
283+
tc.add_dependencies(['!PSA_WANT_ALG_ECDSA'])
269284
tc.set_arguments(arguments)
270285
return tc
271286

0 commit comments

Comments
 (0)