mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-01-30 15:32:58 +00:00
Merge pull request #9604 from gilles-peskine-arm/config-full-booleans-only
config.py: don't rely on section names
This commit is contained in:
commit
560265154c
@ -1 +1 @@
|
|||||||
Subproject commit 8c488b1b8f86384450c922f22cd1bee0b996be13
|
Subproject commit 4e9e8391cd64974d16234160532ef2d6dec9ced6
|
@ -19,26 +19,33 @@ import framework_scripts_path # pylint: disable=unused-import
|
|||||||
from mbedtls_framework import config_common
|
from mbedtls_framework import config_common
|
||||||
|
|
||||||
|
|
||||||
def is_full_section(section):
|
def is_boolean_setting(name, value):
|
||||||
"""Is this section affected by "config.py full" and friends?
|
"""Is this a boolean setting?
|
||||||
|
|
||||||
In a config file where the sections are not used the whole config file
|
Mbed TLS boolean settings are enabled if the preprocessor macro is
|
||||||
is an empty section (with value None) and the whole file is affected.
|
defined, and disabled if the preprocessor macro is not defined. The
|
||||||
|
macro definition line in the configuration file has an empty expansion.
|
||||||
|
|
||||||
|
PSA_WANT_xxx settings are also boolean, but when they are enabled,
|
||||||
|
they expand to a nonzero value. We leave them undefined when they
|
||||||
|
are disabled. (Setting them to 0 currently means to enable them, but
|
||||||
|
this might change to mean disabling them. Currently we just never set
|
||||||
|
them to 0.)
|
||||||
"""
|
"""
|
||||||
return section is None or section.endswith('support') or section.endswith('modules')
|
if name.startswith('PSA_WANT_'):
|
||||||
|
return True
|
||||||
|
if not value:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def realfull_adapter(_name, active, section):
|
def realfull_adapter(_name, _value, _active):
|
||||||
"""Activate all symbols found in the global and boolean feature sections.
|
"""Activate all symbols.
|
||||||
|
|
||||||
This is intended for building the documentation, including the
|
This is intended for building the documentation, including the
|
||||||
documentation of settings that are activated by defining an optional
|
documentation of settings that are activated by defining an optional
|
||||||
preprocessor macro.
|
preprocessor macro. There is no expectation that the resulting
|
||||||
|
configuration can be built.
|
||||||
Do not activate definitions in the section containing symbols that are
|
|
||||||
supposed to be defined and documented in their own module.
|
|
||||||
"""
|
"""
|
||||||
if section == 'Module configuration options':
|
|
||||||
return active
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
PSA_UNSUPPORTED_FEATURE = frozenset([
|
PSA_UNSUPPORTED_FEATURE = frozenset([
|
||||||
@ -138,9 +145,9 @@ def include_in_full(name):
|
|||||||
return is_seamless_alt(name)
|
return is_seamless_alt(name)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def full_adapter(name, active, section):
|
def full_adapter(name, value, active):
|
||||||
"""Config adapter for "full"."""
|
"""Config adapter for "full"."""
|
||||||
if not is_full_section(section):
|
if not is_boolean_setting(name, value):
|
||||||
return active
|
return active
|
||||||
return include_in_full(name)
|
return include_in_full(name)
|
||||||
|
|
||||||
@ -176,9 +183,9 @@ def keep_in_baremetal(name):
|
|||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def baremetal_adapter(name, active, section):
|
def baremetal_adapter(name, value, active):
|
||||||
"""Config adapter for "baremetal"."""
|
"""Config adapter for "baremetal"."""
|
||||||
if not is_full_section(section):
|
if not is_boolean_setting(name, value):
|
||||||
return active
|
return active
|
||||||
if name == 'MBEDTLS_NO_PLATFORM_ENTROPY':
|
if name == 'MBEDTLS_NO_PLATFORM_ENTROPY':
|
||||||
# No OS-provided entropy source
|
# No OS-provided entropy source
|
||||||
@ -195,10 +202,10 @@ EXCLUDE_FOR_SIZE = frozenset([
|
|||||||
'MBEDTLS_TEST_HOOKS', # only useful with the hosted test framework, increases code size
|
'MBEDTLS_TEST_HOOKS', # only useful with the hosted test framework, increases code size
|
||||||
])
|
])
|
||||||
|
|
||||||
def baremetal_size_adapter(name, active, section):
|
def baremetal_size_adapter(name, value, active):
|
||||||
if name in EXCLUDE_FOR_SIZE:
|
if name in EXCLUDE_FOR_SIZE:
|
||||||
return False
|
return False
|
||||||
return baremetal_adapter(name, active, section)
|
return baremetal_adapter(name, value, active)
|
||||||
|
|
||||||
def include_in_crypto(name):
|
def include_in_crypto(name):
|
||||||
"""Rules for symbols in a crypto configuration."""
|
"""Rules for symbols in a crypto configuration."""
|
||||||
@ -219,15 +226,15 @@ def include_in_crypto(name):
|
|||||||
def crypto_adapter(adapter):
|
def crypto_adapter(adapter):
|
||||||
"""Modify an adapter to disable non-crypto symbols.
|
"""Modify an adapter to disable non-crypto symbols.
|
||||||
|
|
||||||
``crypto_adapter(adapter)(name, active, section)`` is like
|
``crypto_adapter(adapter)(name, value, active)`` is like
|
||||||
``adapter(name, active, section)``, but unsets all X.509 and TLS symbols.
|
``adapter(name, value, active)``, but unsets all X.509 and TLS symbols.
|
||||||
"""
|
"""
|
||||||
def continuation(name, active, section):
|
def continuation(name, value, active):
|
||||||
if not include_in_crypto(name):
|
if not include_in_crypto(name):
|
||||||
return False
|
return False
|
||||||
if adapter is None:
|
if adapter is None:
|
||||||
return active
|
return active
|
||||||
return adapter(name, active, section)
|
return adapter(name, value, active)
|
||||||
return continuation
|
return continuation
|
||||||
|
|
||||||
DEPRECATED = frozenset([
|
DEPRECATED = frozenset([
|
||||||
@ -237,34 +244,34 @@ DEPRECATED = frozenset([
|
|||||||
def no_deprecated_adapter(adapter):
|
def no_deprecated_adapter(adapter):
|
||||||
"""Modify an adapter to disable deprecated symbols.
|
"""Modify an adapter to disable deprecated symbols.
|
||||||
|
|
||||||
``no_deprecated_adapter(adapter)(name, active, section)`` is like
|
``no_deprecated_adapter(adapter)(name, value, active)`` is like
|
||||||
``adapter(name, active, section)``, but unsets all deprecated symbols
|
``adapter(name, value, active)``, but unsets all deprecated symbols
|
||||||
and sets ``MBEDTLS_DEPRECATED_REMOVED``.
|
and sets ``MBEDTLS_DEPRECATED_REMOVED``.
|
||||||
"""
|
"""
|
||||||
def continuation(name, active, section):
|
def continuation(name, value, active):
|
||||||
if name == 'MBEDTLS_DEPRECATED_REMOVED':
|
if name == 'MBEDTLS_DEPRECATED_REMOVED':
|
||||||
return True
|
return True
|
||||||
if name in DEPRECATED:
|
if name in DEPRECATED:
|
||||||
return False
|
return False
|
||||||
if adapter is None:
|
if adapter is None:
|
||||||
return active
|
return active
|
||||||
return adapter(name, active, section)
|
return adapter(name, value, active)
|
||||||
return continuation
|
return continuation
|
||||||
|
|
||||||
def no_platform_adapter(adapter):
|
def no_platform_adapter(adapter):
|
||||||
"""Modify an adapter to disable platform symbols.
|
"""Modify an adapter to disable platform symbols.
|
||||||
|
|
||||||
``no_platform_adapter(adapter)(name, active, section)`` is like
|
``no_platform_adapter(adapter)(name, value, active)`` is like
|
||||||
``adapter(name, active, section)``, but unsets all platform symbols other
|
``adapter(name, value, active)``, but unsets all platform symbols other
|
||||||
``than MBEDTLS_PLATFORM_C.
|
``than MBEDTLS_PLATFORM_C.
|
||||||
"""
|
"""
|
||||||
def continuation(name, active, section):
|
def continuation(name, value, active):
|
||||||
# Allow MBEDTLS_PLATFORM_C but remove all other platform symbols.
|
# Allow MBEDTLS_PLATFORM_C but remove all other platform symbols.
|
||||||
if name.startswith('MBEDTLS_PLATFORM_') and name != 'MBEDTLS_PLATFORM_C':
|
if name.startswith('MBEDTLS_PLATFORM_') and name != 'MBEDTLS_PLATFORM_C':
|
||||||
return False
|
return False
|
||||||
if adapter is None:
|
if adapter is None:
|
||||||
return active
|
return active
|
||||||
return adapter(name, active, section)
|
return adapter(name, value, active)
|
||||||
return continuation
|
return continuation
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user