mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-12-24 13:25:37 +00:00
generate_psa_tests.py: add key generation result to test case argument list, add comments
Signed-off-by: Przemyslaw Stekiel <przemyslaw.stekiel@mobica.com>
This commit is contained in:
parent
0810108f12
commit
1ab3a5ca98
|
@ -42,7 +42,6 @@ class TestCase:
|
|||
self.dependencies = [] #type: List[str]
|
||||
self.function = None #type: Optional[str]
|
||||
self.arguments = [] #type: List[str]
|
||||
self.result = '' #type: str
|
||||
|
||||
def add_comment(self, *lines: str) -> None:
|
||||
self.comments += lines
|
||||
|
@ -59,9 +58,6 @@ class TestCase:
|
|||
def set_arguments(self, arguments: List[str]) -> None:
|
||||
self.arguments = arguments
|
||||
|
||||
def set_result(self, result: str) -> None:
|
||||
self.result = result
|
||||
|
||||
def check_completeness(self) -> None:
|
||||
if self.description is None:
|
||||
raise MissingDescription
|
||||
|
@ -86,10 +82,6 @@ class TestCase:
|
|||
if self.dependencies:
|
||||
out.write('depends_on:' + ':'.join(self.dependencies) + '\n')
|
||||
out.write(self.function + ':' + ':'.join(self.arguments))
|
||||
if self.result:
|
||||
out.write(':' + self.result + '\n')
|
||||
else:
|
||||
out.write('\n')
|
||||
|
||||
def write_data_file(filename: str,
|
||||
test_cases: Iterable[TestCase],
|
||||
|
|
|
@ -199,7 +199,8 @@ class NotSupported:
|
|||
# supported or not depending on implementation capabilities,
|
||||
# only generate the test case once.
|
||||
continue
|
||||
# Public key cannot be generated
|
||||
# For public key we expect that key generation fails with
|
||||
# INVALID_ARGUMENT. It is handled by KeyGenerate class.
|
||||
if not kt.name.endswith('_PUBLIC_KEY'):
|
||||
yield test_case_for_key_type_not_supported(
|
||||
'generate', kt.expression, bits,
|
||||
|
@ -242,8 +243,7 @@ def test_case_for_key_generation(
|
|||
.format(short_key_type, bits))
|
||||
tc.set_dependencies(dependencies)
|
||||
tc.set_function('generate_key')
|
||||
tc.set_arguments([key_type] + list(args))
|
||||
tc.set_result(result)
|
||||
tc.set_arguments([key_type] + list(args) + [result])
|
||||
|
||||
return tc
|
||||
|
||||
|
@ -256,11 +256,8 @@ class KeyGenerate:
|
|||
ECC_KEY_TYPES = ('PSA_KEY_TYPE_ECC_KEY_PAIR',
|
||||
'PSA_KEY_TYPE_ECC_PUBLIC_KEY')
|
||||
|
||||
RSA_KEY_TYPES = ('PSA_KEY_TYPE_RSA_KEY_PAIR',
|
||||
'PSA_KEY_TYPE_RSA_PUBLIC_KEY')
|
||||
|
||||
@staticmethod
|
||||
def test_cases_for_key_type_key_generation(
|
||||
self,
|
||||
kt: crypto_knowledge.KeyType
|
||||
) -> Iterator[test_case.TestCase]:
|
||||
"""Return test cases exercising key generation.
|
||||
|
@ -275,11 +272,14 @@ class KeyGenerate:
|
|||
import_dependencies += [psa_want_symbol(sym)
|
||||
for i, sym in enumerate(kt.params)]
|
||||
if kt.name.endswith('_PUBLIC_KEY'):
|
||||
# The library checks whether the key type is a public key generically,
|
||||
# before it reaches a point where it needs support for the specific key
|
||||
# type, so it returns INVALID_ARGUMENT for unsupported public key types.
|
||||
generate_dependencies = []
|
||||
result = 'PSA_ERROR_INVALID_ARGUMENT'
|
||||
else:
|
||||
generate_dependencies = import_dependencies
|
||||
if kt.name in self.RSA_KEY_TYPES:
|
||||
if kt.name == 'PSA_KEY_TYPE_RSA_KEY_PAIR':
|
||||
generate_dependencies.append("MBEDTLS_GENPRIME")
|
||||
for bits in kt.sizes_to_test():
|
||||
yield test_case_for_key_generation(
|
||||
|
|
Loading…
Reference in a new issue