From c05158bf8604e4f4410de6253af86ea6592832d1 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 27 Apr 2021 20:40:10 +0200 Subject: [PATCH] New test suite for systematically generated operation failure tests The new test suite psa_crypto_op_fail is intended for systematically generated test cases that ensure that cryptographic operations with invalid parameters fail as expected. I intend invalid parameters to cover things like an invalid algorithm, an algorithm that is incompatible with the operation, a key type that is incompatible with the algorithm, etc. This commit just creates the infrastructure. Subsequent commits will add data generation and test code. Signed-off-by: Gilles Peskine --- tests/scripts/generate_psa_tests.py | 16 ++++++++++++++++ .../test_suite_psa_crypto_op_fail.function | 18 ++++++++++++++++++ ...est_suite_psa_crypto_op_fail.generated.data | 3 +++ 3 files changed, 37 insertions(+) create mode 100644 tests/suites/test_suite_psa_crypto_op_fail.function create mode 100644 tests/suites/test_suite_psa_crypto_op_fail.generated.data diff --git a/tests/scripts/generate_psa_tests.py b/tests/scripts/generate_psa_tests.py index b9a282f8a..c68841ea3 100755 --- a/tests/scripts/generate_psa_tests.py +++ b/tests/scripts/generate_psa_tests.py @@ -303,6 +303,20 @@ class KeyGenerate: kt = crypto_knowledge.KeyType(constr, [curve_family]) yield from self.test_cases_for_key_type_key_generation(kt) +class OpFail: + """Generate test cases for operations that must fail.""" + #pylint: disable=too-few-public-methods + + def __init__(self, info: Information) -> None: + self.constructors = info.constructors + + def all_test_cases(self) -> Iterator[test_case.TestCase]: + """Generate all test cases for operations that must fail.""" + #pylint: disable=no-self-use + return # To do + yield #pylint: disable=unreachable + + class StorageKey(psa_storage.Key): """Representation of a key for storage format testing.""" @@ -720,6 +734,8 @@ class TestGenerator: lambda info: KeyGenerate(info).test_cases_for_key_generation(), 'test_suite_psa_crypto_not_supported.generated': lambda info: NotSupported(info).test_cases_for_not_supported(), + 'test_suite_psa_crypto_op_fail.generated': + lambda info: OpFail(info).all_test_cases(), 'test_suite_psa_crypto_storage_format.current': lambda info: StorageFormatForward(info, 0).all_test_cases(), 'test_suite_psa_crypto_storage_format.v0': diff --git a/tests/suites/test_suite_psa_crypto_op_fail.function b/tests/suites/test_suite_psa_crypto_op_fail.function new file mode 100644 index 000000000..d72f2c3c7 --- /dev/null +++ b/tests/suites/test_suite_psa_crypto_op_fail.function @@ -0,0 +1,18 @@ +/* BEGIN_HEADER */ + +#include "psa/crypto.h" +#include "test/psa_crypto_helpers.h" + + +/* END_HEADER */ + +/* BEGIN_DEPENDENCIES + * depends_on:MBEDTLS_PSA_CRYPTO_C + * END_DEPENDENCIES + */ + +/* BEGIN_CASE depends_on:NEVER_USED */ +void test_suites_must_have_at_least_one_function( ) +{ +} +/* END_CASE */ diff --git a/tests/suites/test_suite_psa_crypto_op_fail.generated.data b/tests/suites/test_suite_psa_crypto_op_fail.generated.data new file mode 100644 index 000000000..24b5d599c --- /dev/null +++ b/tests/suites/test_suite_psa_crypto_op_fail.generated.data @@ -0,0 +1,3 @@ +# Automatically generated by generate_psa_tests.py. Do not edit! + +# End of automatically generated file.