From 0810108f1208050caf3ab369001415fc251f579c Mon Sep 17 00:00:00 2001 From: Przemyslaw Stekiel Date: Fri, 22 Oct 2021 10:39:56 +0200 Subject: [PATCH] Fix issues pointed by CI Signed-off-by: Przemyslaw Stekiel --- tests/scripts/generate_psa_tests.py | 13 ++++++++++--- .../test_suite_psa_crypto_generate_key.function | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/scripts/generate_psa_tests.py b/tests/scripts/generate_psa_tests.py index 9bee98597..1a35af96e 100755 --- a/tests/scripts/generate_psa_tests.py +++ b/tests/scripts/generate_psa_tests.py @@ -88,9 +88,11 @@ def read_implemented_dependencies(filename: str) -> FrozenSet[str]: return frozenset(symbol for line in open(filename) for symbol in re.findall(r'\bPSA_WANT_\w+\b', line)) -IMPLEMENTED_DEPENDENCIES = read_implemented_dependencies('include/psa/crypto_config.h') def hack_dependencies_not_implemented(dependencies: List[str]) -> None: - if not all(dep.lstrip('!') in IMPLEMENTED_DEPENDENCIES + if _implemented_dependencies is None: + _implemented_dependencies = \ + read_implemented_dependencies('include/psa/crypto_config.h') + if not all((dep.lstrip('!') in _implemented_dependencies or 'PSA_WANT' not in dep) for dep in dependencies): dependencies.append('DEPENDENCY_NOT_IMPLEMENTED_YET') @@ -254,8 +256,11 @@ class KeyGenerate: ECC_KEY_TYPES = ('PSA_KEY_TYPE_ECC_KEY_PAIR', 'PSA_KEY_TYPE_ECC_PUBLIC_KEY') - @staticmethod + RSA_KEY_TYPES = ('PSA_KEY_TYPE_RSA_KEY_PAIR', + 'PSA_KEY_TYPE_RSA_PUBLIC_KEY') + def test_cases_for_key_type_key_generation( + self, kt: crypto_knowledge.KeyType ) -> Iterator[test_case.TestCase]: """Return test cases exercising key generation. @@ -274,6 +279,8 @@ class KeyGenerate: result = 'PSA_ERROR_INVALID_ARGUMENT' else: generate_dependencies = import_dependencies + if kt.name in self.RSA_KEY_TYPES: + generate_dependencies.append("MBEDTLS_GENPRIME") for bits in kt.sizes_to_test(): yield test_case_for_key_generation( kt.expression, bits, diff --git a/tests/suites/test_suite_psa_crypto_generate_key.function b/tests/suites/test_suite_psa_crypto_generate_key.function index 7404d382a..d30c0e487 100644 --- a/tests/suites/test_suite_psa_crypto_generate_key.function +++ b/tests/suites/test_suite_psa_crypto_generate_key.function @@ -38,7 +38,7 @@ void generate_key( int key_type, int bits, int result) // Verify attributes of the created key on success if (_result == PSA_SUCCESS) { - psa_key_attributes_t key_attributes = {0}; + psa_key_attributes_t key_attributes = PSA_KEY_ATTRIBUTES_INIT; PSA_ASSERT( psa_get_key_attributes( key_id, &key_attributes ) ); TEST_EQUAL( psa_get_key_lifetime( &key_attributes ), 0 ); TEST_EQUAL( psa_get_key_usage_flags( &key_attributes ), 0 );