Fix issues pointed by CI

Signed-off-by: Przemyslaw Stekiel <przemyslaw.stekiel@mobica.com>
This commit is contained in:
Przemyslaw Stekiel 2021-10-22 10:39:56 +02:00
parent c03b7c58d1
commit 0810108f12
2 changed files with 11 additions and 4 deletions

View File

@ -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,

View File

@ -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 );