calc_verify is only called in some configurations

If MBEDTLS_SSL_EXTENDED_MASTER_SECRET is disabled or the feature is disabled
at runtime, and if client authentication is not used, then calc_verify is not
called, so don't require the corresponding debug trace.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
Gilles Peskine 2022-03-14 17:55:04 +01:00
parent 4c3f24046a
commit 309ca65846

View File

@ -876,6 +876,38 @@ is_gnutls() {
esac esac
} }
# Determine what calc_verify trace is to be expected, if any.
#
# calc_verify is only called for two things: to calculate the
# extended master secret, and to process client authentication.
#
# Warning: the current implementation assumes that extended_ms is not
# disabled on the client or on the server.
#
# Inputs:
# * $1: 'required' or 1 if client authentication is expected,
# 'none' or 0 or absent if not.
# * $CONFIGS_ENABLED
#
# Outputs:
# * $maybe_calc_verify: set to a trace expected in the debug logs
set_maybe_calc_verify() {
maybe_calc_verify=
case $CONFIGS_ENABLED in
*\ MBEDTLS_SSL_EXTENDED_MASTER_SECRET\ *) :;;
*)
case ${1-} in
''|0|none) return;;
1|required) :;;
*) echo "Bad parameter 1 to set_maybe_calc_verify: $1"; exit 1;;
esac
esac
case $CONFIGS_ENABLED in
*\ MBEDTLS_USE_PSA_CRYPTO\ *) maybe_calc_verify="PSA calc verify";;
*) maybe_calc_verify="<= calc verify";;
esac
}
# Compare file content # Compare file content
# Usage: find_in_both pattern file1 file2 # Usage: find_in_both pattern file1 file2
# extract from file1 the first line matching the pattern # extract from file1 the first line matching the pattern
@ -1272,37 +1304,41 @@ run_test() {
run_test_psa() { run_test_psa() {
requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2 requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
requires_config_enabled MBEDTLS_USE_PSA_CRYPTO requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
set_maybe_calc_verify none
run_test "PSA-supported ciphersuite: $1" \ run_test "PSA-supported ciphersuite: $1" \
"$P_SRV debug_level=3 force_version=tls12" \ "$P_SRV debug_level=3 force_version=tls12" \
"$P_CLI debug_level=3 force_version=tls12 force_ciphersuite=$1" \ "$P_CLI debug_level=3 force_version=tls12 force_ciphersuite=$1" \
0 \ 0 \
-c "PSA calc verify" \ -c "$maybe_calc_verify" \
-c "calc PSA finished" \ -c "calc PSA finished" \
-s "PSA calc verify" \ -s "$maybe_calc_verify" \
-s "calc PSA finished" \ -s "calc PSA finished" \
-s "Protocol is TLSv1.2" \ -s "Protocol is TLSv1.2" \
-c "Perform PSA-based ECDH computation."\ -c "Perform PSA-based ECDH computation."\
-c "Perform PSA-based computation of digest of ServerKeyExchange" \ -c "Perform PSA-based computation of digest of ServerKeyExchange" \
-S "error" \ -S "error" \
-C "error" -C "error"
unset maybe_calc_verify
} }
run_test_psa_force_curve() { run_test_psa_force_curve() {
requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2 requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
requires_config_enabled MBEDTLS_USE_PSA_CRYPTO requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
set_maybe_calc_verify none
run_test "PSA - ECDH with $1" \ run_test "PSA - ECDH with $1" \
"$P_SRV debug_level=4 force_version=tls12 curves=$1" \ "$P_SRV debug_level=4 force_version=tls12 curves=$1" \
"$P_CLI debug_level=4 force_version=tls12 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-GCM-SHA256 curves=$1" \ "$P_CLI debug_level=4 force_version=tls12 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-GCM-SHA256 curves=$1" \
0 \ 0 \
-c "PSA calc verify" \ -c "$maybe_calc_verify" \
-c "calc PSA finished" \ -c "calc PSA finished" \
-s "PSA calc verify" \ -s "$maybe_calc_verify" \
-s "calc PSA finished" \ -s "calc PSA finished" \
-s "Protocol is TLSv1.2" \ -s "Protocol is TLSv1.2" \
-c "Perform PSA-based ECDH computation."\ -c "Perform PSA-based ECDH computation."\
-c "Perform PSA-based computation of digest of ServerKeyExchange" \ -c "Perform PSA-based computation of digest of ServerKeyExchange" \
-S "error" \ -S "error" \
-C "error" -C "error"
unset maybe_calc_verify
} }
# Test that the server's memory usage after a handshake is reduced when a client specifies # Test that the server's memory usage after a handshake is reduced when a client specifies