Rename variables and funcions

Signed-off-by: gabor-mezei-arm <gabor.mezei@arm.com>
This commit is contained in:
gabor-mezei-arm 2021-06-28 17:40:32 +02:00
parent e84d321317
commit acfcc18697
No known key found for this signature in database
GPG Key ID: 106F5A41ECC305BD
2 changed files with 12 additions and 13 deletions

View File

@ -123,7 +123,7 @@ class Key:
bits: int,
usage: Exprable, alg: Exprable, alg2: Exprable,
material: bytes, #pylint: disable=used-before-assignment
usage_extension: bool = True
implicit_usage: bool = True
) -> None:
self.version = self.LATEST_VERSION if version is None else version
self.id = id #pylint: disable=invalid-name #type: Optional[int]
@ -136,7 +136,7 @@ class Key:
self.alg2 = as_expr(alg2) #type: Expr
self.material = material #type: bytes
if usage_extension:
if implicit_usage:
for flag, extension in self.IMPLICIT_USAGE_FLAGS.items():
if self.original_usage.value() & Expr(flag).value() and \
self.original_usage.value() & Expr(extension).value() == 0:

21
tests/scripts/generate_psa_tests.py Executable file → Normal file
View File

@ -236,11 +236,10 @@ class StorageKey(psa_storage.Key):
"""Prepare to generate a key.
* `description`: used for the the test case names
* `expected_usage`: the usage flags generated as the expected usage
flags in the test cases. When testing usage
extension the usage flags can differ in the
generated key and the expected usage flags
in the test cases.
* `implicit_usage`: the usage flags generated as the expected usage
flags in the test cases. When testing implicit
usage flags, they can differ in the generated keys
and the expected usage flags in the test cases.
"""
super().__init__(**kwargs)
self.description = description #type: str
@ -253,7 +252,7 @@ class StorageKeyBuilder:
self.usage_extension = usage_extension #type: bool
def build(self, **kwargs) -> StorageKey:
return StorageKey(usage_extension=self.usage_extension, **kwargs)
return StorageKey(implicit_usage=self.usage_extension, **kwargs)
class StorageFormat:
"""Storage format stability test cases."""
@ -518,7 +517,7 @@ class StorageFormatV0(StorageFormat):
self.key_builder = prev_builder
return keys
def keys_for_usage_extension(
def keys_for_implicit_usage(
self,
implyer_usage: str,
alg: str,
@ -544,7 +543,7 @@ class StorageFormatV0(StorageFormat):
key_type_expression = re.sub(r'\bPSA_(?:KEY_TYPE|ECC_FAMILY)_',
r'',
kt.expression)
description = 'extend {}: {} {} {}-bit'.format(
description = 'implied by {}: {} {} {}-bit'.format(
usage_expression, alg_expression, key_type_expression, bits)
keys.append(self.key_builder.build(version=self.version,
id=1, lifetime=0x00000001,
@ -604,7 +603,7 @@ class StorageFormatV0(StorageFormat):
alg_with_keys[alg] = [key_type]
return alg_with_keys
def all_keys_for_usage_extension(self) -> List[StorageKey]:
def all_keys_for_implicit_usage(self) -> List[StorageKey]:
"""Generate test keys for usage flag extensions."""
# Generate a key type and algorithm pair for each extendable usage
# flag to generate a valid key for exercising. The key is generated
@ -623,14 +622,14 @@ class StorageFormatV0(StorageFormat):
for usage in sorted(StorageKey.IMPLICIT_USAGE_FLAGS, key=str)
for alg in sorted(alg_with_keys)
for key_type in sorted(alg_with_keys[alg]) if re.match(key_filter[usage], key_type)
for key in self.keys_for_usage_extension(usage, alg, key_type)]
for key in self.keys_for_implicit_usage(usage, alg, key_type)]
self.key_builder = prev_builder
return keys
def generate_all_keys(self) -> List[StorageKey]:
keys = super().generate_all_keys()
keys += self.all_keys_for_usage_extension()
keys += self.all_keys_for_implicit_usage()
return keys
class TestGenerator: