mirror of
https://github.com/Mbed-TLS/mbedtls-framework.git
synced 2026-10-01 22:37:23 +00:00
Merge pull request #1121 from gilles-peskine-arm/psa-buffers-test-poison
Memory poisoning function for Asan
This commit is contained in:
@@ -6,7 +6,8 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
@@ -86,22 +87,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.
|
||||||
AES_128BIT_ONLY_DEP_REGEX = r'AES\s(192|256)'
|
|
||||||
AES_128BIT_ONLY_DEP = ["!MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH"]
|
|
||||||
|
|
||||||
DEPENDENCY_FROM_KEY = {
|
# Skip AES test cases which require 192- or 256-bit key
|
||||||
AES_128BIT_ONLY_DEP_REGEX: AES_128BIT_ONLY_DEP
|
# if MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH defined
|
||||||
}#type: Dict[str, List[str]]
|
AES_128BIT_ONLY_DEP_REGEX = re.compile(r'AES\s(192|256)')
|
||||||
def generate_key_dependencies(description: str) -> List[str]:
|
AES_128BIT_ONLY_DEP = ['!MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH']
|
||||||
"""Return additional dependencies based on pairs of REGEX and dependencies.
|
# 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 = re.compile(r'(AES|ARIA|CAMELLIA).*ECB_NO_PADDING')
|
||||||
|
ECB_NO_PADDING_DEP = ['!MBEDTLS_BLOCK_CIPHER_NO_DECRYPT']
|
||||||
|
|
||||||
|
DEPENDENCY_FROM_DESCRIPTION = OrderedDict()
|
||||||
|
DEPENDENCY_FROM_DESCRIPTION[AES_128BIT_ONLY_DEP_REGEX] = AES_128BIT_ONLY_DEP
|
||||||
|
DEPENDENCY_FROM_DESCRIPTION[ECB_NO_PADDING_DEP_REGEX] = ECB_NO_PADDING_DEP
|
||||||
|
def generate_deps_from_description(
|
||||||
|
description: str
|
||||||
|
) -> List[str]:
|
||||||
|
"""Return additional dependencies based on test case description and REGEX.
|
||||||
"""
|
"""
|
||||||
deps = []
|
dep_list = []
|
||||||
for regex, dep in DEPENDENCY_FROM_KEY.items():
|
for regex, deps in DEPENDENCY_FROM_DESCRIPTION.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
|
||||||
|
|||||||
Reference in New Issue
Block a user