mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-03-29 13:20:21 +00:00
psa_information.py: generate dep for AES/ARIA/CAMELLIA ECB test case
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
This commit is contained in:
parent
eefd2695d2
commit
6b190d4f27
@ -17,7 +17,8 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import re
|
import re
|
||||||
from typing import Dict, FrozenSet, List, Optional
|
from collections import OrderedDict
|
||||||
|
from typing import FrozenSet, List, Optional
|
||||||
|
|
||||||
from . import macro_collector
|
from . import macro_collector
|
||||||
|
|
||||||
@ -97,22 +98,31 @@ def automatic_dependencies(*expressions: str) -> List[str]:
|
|||||||
return sorted(psa_want_symbol(name) for name in used)
|
return sorted(psa_want_symbol(name) for name in used)
|
||||||
|
|
||||||
# Define set of regular expressions and dependencies to optionally append
|
# Define set of regular expressions and dependencies to optionally append
|
||||||
# extra dependencies for test case.
|
# extra dependencies for test case based on key description.
|
||||||
|
|
||||||
|
# Skip AES test cases which require 192- or 256-bit key
|
||||||
|
# if MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH defined
|
||||||
AES_128BIT_ONLY_DEP_REGEX = r'AES\s(192|256)'
|
AES_128BIT_ONLY_DEP_REGEX = r'AES\s(192|256)'
|
||||||
AES_128BIT_ONLY_DEP = ["!MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH"]
|
AES_128BIT_ONLY_DEP = ['!MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH']
|
||||||
|
# Skip AES/ARIA/CAMELLIA test cases which require decrypt operation in ECB mode
|
||||||
|
# if MBEDTLS_BLOCK_CIPHER_NO_DECRYPT enabled.
|
||||||
|
ECB_NO_PADDING_DEP_REGEX = r'(AES|ARIA|CAMELLIA).*ECB_NO_PADDING'
|
||||||
|
ECB_NO_PADDING_DEP = ['!MBEDTLS_BLOCK_CIPHER_NO_DECRYPT']
|
||||||
|
|
||||||
DEPENDENCY_FROM_KEY = {
|
DEPENDENCY_FROM_DESCRIPTION = OrderedDict()
|
||||||
AES_128BIT_ONLY_DEP_REGEX: AES_128BIT_ONLY_DEP
|
DEPENDENCY_FROM_DESCRIPTION[AES_128BIT_ONLY_DEP_REGEX] = AES_128BIT_ONLY_DEP
|
||||||
}#type: Dict[str, List[str]]
|
DEPENDENCY_FROM_DESCRIPTION[ECB_NO_PADDING_DEP_REGEX] = ECB_NO_PADDING_DEP
|
||||||
def generate_key_dependencies(description: str) -> List[str]:
|
def generate_description_dependencies(
|
||||||
"""Return additional dependencies based on pairs of REGEX and dependencies.
|
dep_list: List[str],
|
||||||
|
description: str
|
||||||
|
) -> List[str]:
|
||||||
|
"""Return additional dependencies based on test case description and REGEX.
|
||||||
"""
|
"""
|
||||||
deps = []
|
for regex, deps in DEPENDENCY_FROM_DESCRIPTION.items():
|
||||||
for regex, dep in DEPENDENCY_FROM_KEY.items():
|
|
||||||
if re.search(regex, description):
|
if re.search(regex, description):
|
||||||
deps += dep
|
dep_list += deps
|
||||||
|
|
||||||
return deps
|
return dep_list
|
||||||
|
|
||||||
# A temporary hack: at the time of writing, not all dependency symbols
|
# A temporary hack: at the time of writing, not all dependency symbols
|
||||||
# are implemented yet. Skip test cases for which the dependency symbols are
|
# are implemented yet. Skip test cases for which the dependency symbols are
|
||||||
|
@ -508,7 +508,8 @@ class StorageFormat:
|
|||||||
key.alg.string, key.alg2.string,
|
key.alg.string, key.alg2.string,
|
||||||
)
|
)
|
||||||
dependencies = psa_information.finish_family_dependencies(dependencies, key.bits)
|
dependencies = psa_information.finish_family_dependencies(dependencies, key.bits)
|
||||||
dependencies += psa_information.generate_key_dependencies(key.description)
|
dependencies = psa_information.generate_description_dependencies(dependencies,
|
||||||
|
key.description)
|
||||||
dependencies = psa_information.fix_key_pair_dependencies(dependencies, 'BASIC')
|
dependencies = psa_information.fix_key_pair_dependencies(dependencies, 'BASIC')
|
||||||
tc.set_dependencies(dependencies)
|
tc.set_dependencies(dependencies)
|
||||||
tc.set_function('key_storage_' + verb)
|
tc.set_function('key_storage_' + verb)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user