Use CONFIGS_ENABLED instead of repeatedly calling query_compile_time_config

It's faster and more readable.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
Gilles Peskine 2024-09-06 14:43:17 +02:00
parent 56ee69de5b
commit 9404169146

View File

@ -273,31 +273,39 @@ requires_config_disabled() {
} }
requires_all_configs_enabled() { requires_all_configs_enabled() {
if ! $P_QUERY -all $* 2>&1 > /dev/null for x in "$@"; do
then if ! is_config_enabled "$x"; then
SKIP_NEXT="YES" SKIP_NEXT="YES"
fi return
fi
done
} }
requires_all_configs_disabled() { requires_all_configs_disabled() {
if $P_QUERY -any $* 2>&1 > /dev/null for x in "$@"; do
then if is_config_enabled "$x"; then
SKIP_NEXT="YES" SKIP_NEXT="YES"
fi return
fi
done
} }
requires_any_configs_enabled() { requires_any_configs_enabled() {
if ! $P_QUERY -any $* 2>&1 > /dev/null for x in "$@"; do
then if is_config_enabled "$x"; then
SKIP_NEXT="YES" return
fi fi
done
SKIP_NEXT="YES"
} }
requires_any_configs_disabled() { requires_any_configs_disabled() {
if $P_QUERY -all $* 2>&1 > /dev/null for x in "$@"; do
then if ! is_config_enabled "$x"; then
SKIP_NEXT="YES" return
fi fi
done
SKIP_NEXT="YES"
} }
TLS1_2_KEY_EXCHANGES_WITH_CERT="MBEDTLS_KEY_EXCHANGE_RSA_ENABLED \ TLS1_2_KEY_EXCHANGES_WITH_CERT="MBEDTLS_KEY_EXCHANGE_RSA_ENABLED \
@ -318,10 +326,10 @@ TLS1_2_KEY_EXCHANGES_WITH_CERT_WO_ECDH="MBEDTLS_KEY_EXCHANGE_RSA_ENABLED \
MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED" MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED"
requires_key_exchange_with_cert_in_tls12_or_tls13_enabled() { requires_key_exchange_with_cert_in_tls12_or_tls13_enabled() {
if $P_QUERY -all MBEDTLS_SSL_PROTO_TLS1_2 if is_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
then then
requires_any_configs_enabled $TLS1_2_KEY_EXCHANGES_WITH_CERT requires_any_configs_enabled $TLS1_2_KEY_EXCHANGES_WITH_CERT
elif ! $P_QUERY -all MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED elif ! is_config_enabled MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED
then then
SKIP_NEXT="YES" SKIP_NEXT="YES"
fi fi
@ -1653,7 +1661,7 @@ get_tls_version() {
esac esac
# Third if the version is not forced, if TLS 1.3 is enabled then the test # Third if the version is not forced, if TLS 1.3 is enabled then the test
# is aimed to run a TLS 1.3 handshake. # is aimed to run a TLS 1.3 handshake.
if $P_QUERY -all MBEDTLS_SSL_PROTO_TLS1_3 if is_config_enabled MBEDTLS_SSL_PROTO_TLS1_3
then then
echo "TLS13" echo "TLS13"
else else