From df620dae4304e6e8a6226624969e8ea1cc7d33a3 Mon Sep 17 00:00:00 2001 From: Etienne Carriere Date: Fri, 28 Mar 2025 18:07:19 +0100 Subject: [PATCH] Fix build warning related to DTLS connect ID Between mbedtls version 3.6.2 and 3.6.3, some header files inclusion scheme have changed (P-R [1] and specifically [2]) leading to the build warning shown below when building libmbedtls as a user TA library in OP-TEE OS package [3]: In file included from lib/libmbedtls/mbedtls/library/ssl_misc.h:18, from lib/libmbedtls/mbedtls/library/ssl_debug_helpers_generated.c:14: lib/libmbedtls/mbedtls/include/mbedtls/ssl.h:659:5: warning: "MBEDTLS_SSL_DTLS_CONNECTION_ID_COMPAT" is not defined, evaluates to 0 [-Wundef] 659 | #if MBEDTLS_SSL_DTLS_CONNECTION_ID_COMPAT == 0 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Fix this by considering MBEDTLS_SSL_DTLS_CONNECTION_ID_COMPAT only when MBEDTLS_SSL_DTLS_CONNECTION_ID is defined. The build warning is related to the definition of MBEDTLS_TLS_EXT_CID that is meaningful only when MBEDTLS_SSL_DTLS_CONNECTION_ID is defined which is relevant only when MBEDTLS_SSL_DTLS_CONNECTION_ID_COMPAT is defined. Fixes #10207. Link: https://github.com/Mbed-TLS/mbedtls/pull/9671 [1] Link: https://github.com/Mbed-TLS/mbedtls/pull/9671/commits/b81cd1af6418823a2b5ffbd3710ceac9b0e0afa4 [2] Link: https://github.com/OP-TEE/optee_os/pull/7337 [3] Signed-off-by: Etienne Carriere --- ChangeLog.d/fix-dtls-connection-id-compat-build.txt | 3 +++ include/mbedtls/ssl.h | 6 ++++++ 2 files changed, 9 insertions(+) create mode 100644 ChangeLog.d/fix-dtls-connection-id-compat-build.txt diff --git a/ChangeLog.d/fix-dtls-connection-id-compat-build.txt b/ChangeLog.d/fix-dtls-connection-id-compat-build.txt new file mode 100644 index 0000000000..2f4becd393 --- /dev/null +++ b/ChangeLog.d/fix-dtls-connection-id-compat-build.txt @@ -0,0 +1,3 @@ +Bugfix + * Fix a compilation warning in ssl.h when MBEDTLS_SSL_DTLS_CONNECTION_ID + and MBEDTLS_SSL_DTLS_CONNECTION_ID_COMPAT are not defined. Fixes #10207. diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index f9b103e382..86ab0cf142 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -656,11 +656,17 @@ #define MBEDTLS_TLS_EXT_SIG_ALG_CERT 50 /* RFC 8446 TLS 1.3 */ #define MBEDTLS_TLS_EXT_KEY_SHARE 51 /* RFC 8446 TLS 1.3 */ +/* + * MBEDTLS_TLS_EXT_CID is required only when + * MBEDTLS_SSL_DTLS_CONNECTION_ID is defined. + */ +#if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID) #if MBEDTLS_SSL_DTLS_CONNECTION_ID_COMPAT == 0 #define MBEDTLS_TLS_EXT_CID 54 /* RFC 9146 DTLS 1.2 CID */ #else #define MBEDTLS_TLS_EXT_CID 254 /* Pre-RFC 9146 DTLS 1.2 CID */ #endif +#endif #define MBEDTLS_TLS_EXT_ECJPAKE_KKPP 256 /* experimental */