Skip to content

Commit d1a71eb

Browse files
authored
Merge pull request #3088 from andresag01/mbedtls-preoprocessor-checks
Add checks for NULL_ENTROPY and SSL_TLS in mbed OS
2 parents a6e199a + 509a72c commit d1a71eb

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

features/mbedtls/importer/adjust-config.sh

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,21 @@ add_code
5555
"\n" \
5656
"#else\n"
5757

58-
add_code \
59-
"#include \"check_config.h\"\n" \
60-
"\n" \
61-
"#endif \/* !MBEDTLS_ENTROPY_HARDWARE_ALT && !MBEDTLS_TEST_NULL_ENTROPY *\/"
58+
add_code \
59+
"#include \"check_config.h\"\n" \
60+
"\n" \
61+
"#endif \/* !MBEDTLS_ENTROPY_HARDWARE_ALT && !MBEDTLS_TEST_NULL_ENTROPY *\/\n" \
62+
"\n" \
63+
"#if defined(MBEDTLS_TEST_NULL_ENTROPY)\n" \
64+
"#warning \"MBEDTLS_TEST_NULL_ENTROPY has been enabled. This \" \\\\\n" \
65+
" \"configuration is not secure and is not suitable for production use\"\n" \
66+
"#endif\n" \
67+
"\n" \
68+
"#if defined(MBEDTLS_SSL_TLS_C) && !defined(MBEDTLS_TEST_NULL_ENTROPY) && \\\\\n" \
69+
" !defined(MBEDTLS_ENTROPY_HARDWARE_ALT)\n" \
70+
"#error \"No entropy source was found at build time, so TLS \" \\\\\n" \
71+
" \"functionality is not available\"\n" \
72+
"#endif\n"
6273

6374
# not supported on mbed OS, nor used by mbed Client
6475
conf unset MBEDTLS_NET_C

features/mbedtls/inc/mbedtls/config.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2613,4 +2613,16 @@
26132613
#include "check_config.h"
26142614

26152615
#endif /* !MBEDTLS_ENTROPY_HARDWARE_ALT && !MBEDTLS_TEST_NULL_ENTROPY */
2616+
2617+
#if defined(MBEDTLS_TEST_NULL_ENTROPY)
2618+
#warning "MBEDTLS_TEST_NULL_ENTROPY has been enabled. This " \
2619+
"configuration is not secure and is not suitable for production use"
2620+
#endif
2621+
2622+
#if defined(MBEDTLS_SSL_TLS_C) && !defined(MBEDTLS_TEST_NULL_ENTROPY) && \
2623+
!defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
2624+
#error "No entropy source was found at build time, so TLS " \
2625+
"functionality is not available"
2626+
#endif
2627+
26162628
#endif /* MBEDTLS_CONFIG_H */

0 commit comments

Comments
 (0)