Skip to content

Commit f922586

Browse files
Andres Amaya GarciaAndres Amaya Garcia
authored andcommitted
Modify mbed TLS config.h to use NV seed
The config.h now takes into consideration whether the mbed TLS NV Seed feature is present to decide which configuration is actually going to be used.
1 parent 4dea31d commit f922586

File tree

2 files changed

+34
-22
lines changed

2 files changed

+34
-22
lines changed

features/mbedtls/importer/adjust-config.sh

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,36 +37,42 @@ add_code() {
3737

3838
# add an #ifndef to include config-no-entropy.h when the target does not have
3939
# an entropy source we can use.
40-
add_code \
41-
"#ifndef MBEDTLS_CONFIG_H\n" \
42-
"\n" \
43-
"#include \"platform\/inc\/platform_mbed.h\"\n" \
44-
"\n" \
45-
"\/*\n" \
46-
" * Only use features that do not require an entropy source when\n" \
47-
" * DEVICE_ENTROPY_SOURCE is not defined in mbed OS.\n" \
48-
" *\/\n" \
49-
"#if !defined(MBEDTLS_ENTROPY_HARDWARE_ALT) && !defined(MBEDTLS_TEST_NULL_ENTROPY)\n" \
50-
"#include \"mbedtls\/config-no-entropy.h\"\n" \
51-
"\n" \
52-
"#if defined(MBEDTLS_USER_CONFIG_FILE)\n" \
53-
"#include MBEDTLS_USER_CONFIG_FILE\n" \
54-
"#endif\n" \
55-
"\n" \
40+
add_code \
41+
"#ifndef MBEDTLS_CONFIG_H\n" \
42+
"\n" \
43+
"#include \"platform\/inc\/platform_mbed.h\"\n" \
44+
"\n" \
45+
"\/*\n" \
46+
" * Only use features that do not require an entropy source when\n" \
47+
" * this is not available in Mbed OS. For more information on\n" \
48+
" * Mbed TLS entropy options please refer to entropy.h\n" \
49+
" *\/\n" \
50+
"#if !defined(MBEDTLS_ENTROPY_HARDWARE_ALT) && \\\\\n" \
51+
" !defined(MBEDTLS_TEST_NULL_ENTROPY) && \\\\\n" \
52+
" !defined(MBEDTLS_ENTROPY_NV_SEED)\n" \
53+
"#include \"mbedtls\/config-no-entropy.h\"\n" \
54+
"\n" \
55+
"#if defined(MBEDTLS_USER_CONFIG_FILE)\n" \
56+
"#include MBEDTLS_USER_CONFIG_FILE\n" \
57+
"#endif\n" \
58+
"\n" \
5659
"#else\n"
5760

5861
add_code \
5962
"#include \"check_config.h\"\n" \
6063
"\n" \
61-
"#endif \/* !MBEDTLS_ENTROPY_HARDWARE_ALT && !MBEDTLS_TEST_NULL_ENTROPY *\/\n" \
64+
"#endif \/* !MBEDTLS_ENTROPY_HARDWARE_ALT &&\n" \
65+
" * !MBEDTLS_TEST_NULL_ENTROPY &&\n" \
66+
" * !MBEDTLS_ENTROPY_NV_SEED *\/\n" \
6267
"\n" \
6368
"#if defined(MBEDTLS_TEST_NULL_ENTROPY)\n" \
6469
"#warning \"MBEDTLS_TEST_NULL_ENTROPY has been enabled. This \" \\\\\n" \
6570
" \"configuration is not secure and is not suitable for production use\"\n" \
6671
"#endif\n" \
6772
"\n" \
6873
"#if defined(MBEDTLS_SSL_TLS_C) && !defined(MBEDTLS_TEST_NULL_ENTROPY) && \\\\\n" \
69-
" !defined(MBEDTLS_ENTROPY_HARDWARE_ALT)\n" \
74+
" !defined(MBEDTLS_ENTROPY_HARDWARE_ALT) && \\\\\n" \
75+
" !defined(MBEDTLS_ENTROPY_NV_SEED)\n" \
7076
"#error \"No entropy source was found at build time, so TLS \" \\\\\n" \
7177
" \"functionality is not available\"\n" \
7278
"#endif\n"

features/mbedtls/inc/mbedtls/config.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,12 @@
3131

3232
/*
3333
* Only use features that do not require an entropy source when
34-
* DEVICE_ENTROPY_SOURCE is not defined in mbed OS.
34+
* this is not available in Mbed OS. For more information on
35+
* Mbed TLS entropy options please refer to entropy.h
3536
*/
36-
#if !defined(MBEDTLS_ENTROPY_HARDWARE_ALT) && !defined(MBEDTLS_TEST_NULL_ENTROPY)
37+
#if !defined(MBEDTLS_ENTROPY_HARDWARE_ALT) && \
38+
!defined(MBEDTLS_TEST_NULL_ENTROPY) && \
39+
!defined(MBEDTLS_ENTROPY_NV_SEED)
3740
#include "mbedtls/config-no-entropy.h"
3841

3942
#if defined(MBEDTLS_USER_CONFIG_FILE)
@@ -2731,15 +2734,18 @@
27312734

27322735
#include "check_config.h"
27332736

2734-
#endif /* !MBEDTLS_ENTROPY_HARDWARE_ALT && !MBEDTLS_TEST_NULL_ENTROPY */
2737+
#endif /* !MBEDTLS_ENTROPY_HARDWARE_ALT &&
2738+
* !MBEDTLS_TEST_NULL_ENTROPY &&
2739+
* !MBEDTLS_ENTROPY_NV_SEED */
27352740

27362741
#if defined(MBEDTLS_TEST_NULL_ENTROPY)
27372742
#warning "MBEDTLS_TEST_NULL_ENTROPY has been enabled. This " \
27382743
"configuration is not secure and is not suitable for production use"
27392744
#endif
27402745

27412746
#if defined(MBEDTLS_SSL_TLS_C) && !defined(MBEDTLS_TEST_NULL_ENTROPY) && \
2742-
!defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
2747+
!defined(MBEDTLS_ENTROPY_HARDWARE_ALT) && \
2748+
!defined(MBEDTLS_ENTROPY_NV_SEED)
27432749
#error "No entropy source was found at build time, so TLS " \
27442750
"functionality is not available"
27452751
#endif

0 commit comments

Comments
 (0)