Skip to content

Commit 077f4c3

Browse files
committed
Move code additions to end of adjust_config.sh
The config.py script that adjusts config.h in Mbed TLS doesn't handle having configurations being defined in it multiple times very well. As Mbed OS needs to have certain configurations settings based on what features are set, these code additions to config.h are moved to being added after the rest of the configuration is adjusted.
1 parent a6207ca commit 077f4c3

File tree

1 file changed

+43
-43
lines changed

1 file changed

+43
-43
lines changed

features/mbedtls/importer/adjust-config.sh

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -47,49 +47,6 @@ append_code() {
4747
"$FILE"
4848
}
4949

50-
# add an #ifndef to include config-no-entropy.h when the target does not have
51-
# an entropy source we can use.
52-
append_code \
53-
"#ifndef MBEDTLS_CONFIG_H\n" \
54-
"\n" \
55-
"#include \"platform\/inc\/platform_mbed.h\"\n" \
56-
"\n" \
57-
"\/*\n" \
58-
" * Only use features that do not require an entropy source when\n" \
59-
" * DEVICE_ENTROPY_SOURCE is not defined in mbed OS.\n" \
60-
" *\/\n" \
61-
"#if !defined(MBEDTLS_ENTROPY_HARDWARE_ALT) && !defined(MBEDTLS_TEST_NULL_ENTROPY) && \\\\\n" \
62-
" !defined(MBEDTLS_ENTROPY_NV_SEED)\n" \
63-
"#include \"mbedtls\/config-no-entropy.h\"\n" \
64-
"\n" \
65-
"#if defined(MBEDTLS_USER_CONFIG_FILE)\n" \
66-
"#include MBEDTLS_USER_CONFIG_FILE\n" \
67-
"#endif\n" \
68-
"\n" \
69-
"#else\n"
70-
71-
prepend_code \
72-
"#endif \/\* MBEDTLS_CONFIG_H \*\/" \
73-
"\n" \
74-
"#endif \/* !MBEDTLS_ENTROPY_HARDWARE_ALT && !MBEDTLS_TEST_NULL_ENTROPY && !MBEDTLS_ENTROPY_NV_SEED *\/\n" \
75-
"\n" \
76-
"#if defined(MBEDTLS_TEST_NULL_ENTROPY)\n" \
77-
"#warning \"MBEDTLS_TEST_NULL_ENTROPY has been enabled. This \" \\\\\n" \
78-
" \"configuration is not secure and is not suitable for production use\"\n" \
79-
"#endif\n" \
80-
"\n" \
81-
"#if defined(MBEDTLS_SSL_TLS_C) && !defined(MBEDTLS_TEST_NULL_ENTROPY) && \\\\\n" \
82-
" !defined(MBEDTLS_ENTROPY_HARDWARE_ALT) && !defined(MBEDTLS_ENTROPY_NV_SEED)\n" \
83-
"#error \"No entropy source was found at build time, so TLS \" \\\\\n" \
84-
" \"functionality is not available\"\n" \
85-
"#endif\n" \
86-
"\n" \
87-
"#if defined(FEATURE_EXPERIMENTAL_API) && defined(FEATURE_PSA)\n" \
88-
" #define MBEDTLS_PSA_HAS_ITS_IO\n" \
89-
" #define MBEDTLS_USE_PSA_CRYPTO\n" \
90-
"#endif\n" \
91-
"\n"
92-
9350
# not supported on mbed OS, nor used by mbed Client
9451
conf unset MBEDTLS_NET_C
9552
conf unset MBEDTLS_TIMING_C
@@ -165,3 +122,46 @@ conf unset MBEDTLS_PLATFORM_TIME_TYPE_MACRO
165122
# Reduce the maximal MBEDTLS_MPI_MAX_SIZE to 512 bytes,
166123
# which should fit RSA 4096 bit keys.
167124
conf set MBEDTLS_MPI_MAX_SIZE 512
125+
126+
# add an #ifndef to include config-no-entropy.h when the target does not have
127+
# an entropy source we can use.
128+
append_code \
129+
"#ifndef MBEDTLS_CONFIG_H\n" \
130+
"\n" \
131+
"#include \"platform\/inc\/platform_mbed.h\"\n" \
132+
"\n" \
133+
"\/*\n" \
134+
" * Only use features that do not require an entropy source when\n" \
135+
" * DEVICE_ENTROPY_SOURCE is not defined in mbed OS.\n" \
136+
" *\/\n" \
137+
"#if !defined(MBEDTLS_ENTROPY_HARDWARE_ALT) && !defined(MBEDTLS_TEST_NULL_ENTROPY) && \\\\\n" \
138+
" !defined(MBEDTLS_ENTROPY_NV_SEED)\n" \
139+
"#include \"mbedtls\/config-no-entropy.h\"\n" \
140+
"\n" \
141+
"#if defined(MBEDTLS_USER_CONFIG_FILE)\n" \
142+
"#include MBEDTLS_USER_CONFIG_FILE\n" \
143+
"#endif\n" \
144+
"\n" \
145+
"#else\n"
146+
147+
prepend_code \
148+
"#endif \/\* MBEDTLS_CONFIG_H \*\/" \
149+
"\n" \
150+
"#endif \/* !MBEDTLS_ENTROPY_HARDWARE_ALT && !MBEDTLS_TEST_NULL_ENTROPY && !MBEDTLS_ENTROPY_NV_SEED *\/\n" \
151+
"\n" \
152+
"#if defined(MBEDTLS_TEST_NULL_ENTROPY)\n" \
153+
"#warning \"MBEDTLS_TEST_NULL_ENTROPY has been enabled. This \" \\\\\n" \
154+
" \"configuration is not secure and is not suitable for production use\"\n" \
155+
"#endif\n" \
156+
"\n" \
157+
"#if defined(MBEDTLS_SSL_TLS_C) && !defined(MBEDTLS_TEST_NULL_ENTROPY) && \\\\\n" \
158+
" !defined(MBEDTLS_ENTROPY_HARDWARE_ALT) && !defined(MBEDTLS_ENTROPY_NV_SEED)\n" \
159+
"#error \"No entropy source was found at build time, so TLS \" \\\\\n" \
160+
" \"functionality is not available\"\n" \
161+
"#endif\n" \
162+
"\n" \
163+
"#if defined(FEATURE_EXPERIMENTAL_API) && defined(FEATURE_PSA)\n" \
164+
" #define MBEDTLS_PSA_HAS_ITS_IO\n" \
165+
" #define MBEDTLS_USE_PSA_CRYPTO\n" \
166+
"#endif\n" \
167+
"\n"

0 commit comments

Comments
 (0)