mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-12-02 10:24:18 +01:00
Rename variables and funcions
Signed-off-by: gabor-mezei-arm <gabor.mezei@arm.com>
This commit is contained in:
parent
e84d321317
commit
acfcc18697
@ -123,7 +123,7 @@ class Key:
|
|||||||
bits: int,
|
bits: int,
|
||||||
usage: Exprable, alg: Exprable, alg2: Exprable,
|
usage: Exprable, alg: Exprable, alg2: Exprable,
|
||||||
material: bytes, #pylint: disable=used-before-assignment
|
material: bytes, #pylint: disable=used-before-assignment
|
||||||
usage_extension: bool = True
|
implicit_usage: bool = True
|
||||||
) -> None:
|
) -> None:
|
||||||
self.version = self.LATEST_VERSION if version is None else version
|
self.version = self.LATEST_VERSION if version is None else version
|
||||||
self.id = id #pylint: disable=invalid-name #type: Optional[int]
|
self.id = id #pylint: disable=invalid-name #type: Optional[int]
|
||||||
@ -136,7 +136,7 @@ class Key:
|
|||||||
self.alg2 = as_expr(alg2) #type: Expr
|
self.alg2 = as_expr(alg2) #type: Expr
|
||||||
self.material = material #type: bytes
|
self.material = material #type: bytes
|
||||||
|
|
||||||
if usage_extension:
|
if implicit_usage:
|
||||||
for flag, extension in self.IMPLICIT_USAGE_FLAGS.items():
|
for flag, extension in self.IMPLICIT_USAGE_FLAGS.items():
|
||||||
if self.original_usage.value() & Expr(flag).value() and \
|
if self.original_usage.value() & Expr(flag).value() and \
|
||||||
self.original_usage.value() & Expr(extension).value() == 0:
|
self.original_usage.value() & Expr(extension).value() == 0:
|
||||||
|
21
tests/scripts/generate_psa_tests.py
Executable file → Normal file
21
tests/scripts/generate_psa_tests.py
Executable file → Normal file
@ -236,11 +236,10 @@ class StorageKey(psa_storage.Key):
|
|||||||
"""Prepare to generate a key.
|
"""Prepare to generate a key.
|
||||||
|
|
||||||
* `description`: used for the the test case names
|
* `description`: used for the the test case names
|
||||||
* `expected_usage`: the usage flags generated as the expected usage
|
* `implicit_usage`: the usage flags generated as the expected usage
|
||||||
flags in the test cases. When testing usage
|
flags in the test cases. When testing implicit
|
||||||
extension the usage flags can differ in the
|
usage flags, they can differ in the generated keys
|
||||||
generated key and the expected usage flags
|
and the expected usage flags in the test cases.
|
||||||
in the test cases.
|
|
||||||
"""
|
"""
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
self.description = description #type: str
|
self.description = description #type: str
|
||||||
@ -253,7 +252,7 @@ class StorageKeyBuilder:
|
|||||||
self.usage_extension = usage_extension #type: bool
|
self.usage_extension = usage_extension #type: bool
|
||||||
|
|
||||||
def build(self, **kwargs) -> StorageKey:
|
def build(self, **kwargs) -> StorageKey:
|
||||||
return StorageKey(usage_extension=self.usage_extension, **kwargs)
|
return StorageKey(implicit_usage=self.usage_extension, **kwargs)
|
||||||
|
|
||||||
class StorageFormat:
|
class StorageFormat:
|
||||||
"""Storage format stability test cases."""
|
"""Storage format stability test cases."""
|
||||||
@ -518,7 +517,7 @@ class StorageFormatV0(StorageFormat):
|
|||||||
self.key_builder = prev_builder
|
self.key_builder = prev_builder
|
||||||
return keys
|
return keys
|
||||||
|
|
||||||
def keys_for_usage_extension(
|
def keys_for_implicit_usage(
|
||||||
self,
|
self,
|
||||||
implyer_usage: str,
|
implyer_usage: str,
|
||||||
alg: str,
|
alg: str,
|
||||||
@ -544,7 +543,7 @@ class StorageFormatV0(StorageFormat):
|
|||||||
key_type_expression = re.sub(r'\bPSA_(?:KEY_TYPE|ECC_FAMILY)_',
|
key_type_expression = re.sub(r'\bPSA_(?:KEY_TYPE|ECC_FAMILY)_',
|
||||||
r'',
|
r'',
|
||||||
kt.expression)
|
kt.expression)
|
||||||
description = 'extend {}: {} {} {}-bit'.format(
|
description = 'implied by {}: {} {} {}-bit'.format(
|
||||||
usage_expression, alg_expression, key_type_expression, bits)
|
usage_expression, alg_expression, key_type_expression, bits)
|
||||||
keys.append(self.key_builder.build(version=self.version,
|
keys.append(self.key_builder.build(version=self.version,
|
||||||
id=1, lifetime=0x00000001,
|
id=1, lifetime=0x00000001,
|
||||||
@ -604,7 +603,7 @@ class StorageFormatV0(StorageFormat):
|
|||||||
alg_with_keys[alg] = [key_type]
|
alg_with_keys[alg] = [key_type]
|
||||||
return alg_with_keys
|
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 test keys for usage flag extensions."""
|
||||||
# Generate a key type and algorithm pair for each extendable usage
|
# Generate a key type and algorithm pair for each extendable usage
|
||||||
# flag to generate a valid key for exercising. The key is generated
|
# 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 usage in sorted(StorageKey.IMPLICIT_USAGE_FLAGS, key=str)
|
||||||
for alg in sorted(alg_with_keys)
|
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_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
|
self.key_builder = prev_builder
|
||||||
return keys
|
return keys
|
||||||
|
|
||||||
def generate_all_keys(self) -> List[StorageKey]:
|
def generate_all_keys(self) -> List[StorageKey]:
|
||||||
keys = super().generate_all_keys()
|
keys = super().generate_all_keys()
|
||||||
keys += self.all_keys_for_usage_extension()
|
keys += self.all_keys_for_implicit_usage()
|
||||||
return keys
|
return keys
|
||||||
|
|
||||||
class TestGenerator:
|
class TestGenerator:
|
||||||
|
Loading…
Reference in New Issue
Block a user