Addapt psa_generate_key() tests

Signed-off-by: Przemyslaw Stekiel <przemyslaw.stekiel@mobica.com>
This commit is contained in:
Przemyslaw Stekiel 2021-10-08 12:26:21 +02:00
parent 770153e836
commit d9d630cdf3
3 changed files with 31 additions and 7 deletions

View file

@ -133,7 +133,7 @@ class Information:
return constructors
def test_case_for_key_type_not_supported(
def test_case_for_key_type_not_supported_invalid_arg(
verb: str, key_type: str, bits: int,
dependencies: List[str],
*args: str,
@ -148,10 +148,15 @@ def test_case_for_key_type_not_supported(
adverb = 'not' if dependencies else 'never'
if param_descr:
adverb = param_descr + ' ' + adverb
tc.set_description('PSA {} {} {}-bit {} supported'
.format(verb, short_key_type, bits, adverb))
if (verb == "generate") and ("PUBLIC" in short_key_type):
tc.set_description('PSA {} {} {}-bit invalid argument'
.format(verb, short_key_type, bits))
tc.set_function(verb + '_invalid_arg')
else:
tc.set_description('PSA {} {} {}-bit {} supported'
.format(verb, short_key_type, bits, adverb))
tc.set_function(verb + '_not_supported')
tc.set_dependencies(dependencies)
tc.set_function(verb + '_not_supported')
tc.set_arguments([key_type] + list(args))
return tc
@ -192,7 +197,7 @@ class NotSupported:
else:
generate_dependencies = import_dependencies
for bits in kt.sizes_to_test():
yield test_case_for_key_type_not_supported(
yield test_case_for_key_type_not_supported_invalid_arg(
'import', kt.expression, bits,
finish_family_dependencies(import_dependencies, bits),
test_case.hex_string(kt.key_material(bits)),
@ -203,7 +208,7 @@ class NotSupported:
# supported or not depending on implementation capabilities,
# only generate the test case once.
continue
yield test_case_for_key_type_not_supported(
yield test_case_for_key_type_not_supported_invalid_arg(
'generate', kt.expression, bits,
finish_family_dependencies(generate_dependencies, bits),
str(bits),