Skip to content

DRAFT: Enable MBEDTLS_FS_IO when this feature can be used #3955

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 24 additions & 18 deletions features/mbedtls/importer/adjust-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,36 +37,42 @@ add_code() {

# add an #ifndef to include config-no-entropy.h when the target does not have
# an entropy source we can use.
add_code \
"#ifndef MBEDTLS_CONFIG_H\n" \
"\n" \
"#include \"platform\/inc\/platform_mbed.h\"\n" \
"\n" \
"\/*\n" \
" * Only use features that do not require an entropy source when\n" \
" * DEVICE_ENTROPY_SOURCE is not defined in mbed OS.\n" \
" *\/\n" \
"#if !defined(MBEDTLS_ENTROPY_HARDWARE_ALT) && !defined(MBEDTLS_TEST_NULL_ENTROPY)\n" \
"#include \"mbedtls\/config-no-entropy.h\"\n" \
"\n" \
"#if defined(MBEDTLS_USER_CONFIG_FILE)\n" \
"#include MBEDTLS_USER_CONFIG_FILE\n" \
"#endif\n" \
"\n" \
add_code \
"#ifndef MBEDTLS_CONFIG_H\n" \
"\n" \
"#include \"platform\/inc\/platform_mbed.h\"\n" \
"\n" \
"\/*\n" \
" * Only use features that do not require an entropy source when\n" \
" * this is not available in Mbed OS. For more information on\n" \
" * Mbed TLS entropy options please refer to entropy.h\n" \
" *\/\n" \
"#if !defined(MBEDTLS_ENTROPY_HARDWARE_ALT) && \\\\\n" \
" !defined(MBEDTLS_TEST_NULL_ENTROPY) && \\\\\n" \
" !defined(MBEDTLS_ENTROPY_NV_SEED)\n" \
"#include \"mbedtls\/config-no-entropy.h\"\n" \
"\n" \
"#if defined(MBEDTLS_USER_CONFIG_FILE)\n" \
"#include MBEDTLS_USER_CONFIG_FILE\n" \
"#endif\n" \
"\n" \
"#else\n"

add_code \
"#include \"check_config.h\"\n" \
"\n" \
"#endif \/* !MBEDTLS_ENTROPY_HARDWARE_ALT && !MBEDTLS_TEST_NULL_ENTROPY *\/\n" \
"#endif \/* !MBEDTLS_ENTROPY_HARDWARE_ALT &&\n" \
" * !MBEDTLS_TEST_NULL_ENTROPY &&\n" \
" * !MBEDTLS_ENTROPY_NV_SEED *\/\n" \
"\n" \
"#if defined(MBEDTLS_TEST_NULL_ENTROPY)\n" \
"#warning \"MBEDTLS_TEST_NULL_ENTROPY has been enabled. This \" \\\\\n" \
" \"configuration is not secure and is not suitable for production use\"\n" \
"#endif\n" \
"\n" \
"#if defined(MBEDTLS_SSL_TLS_C) && !defined(MBEDTLS_TEST_NULL_ENTROPY) && \\\\\n" \
" !defined(MBEDTLS_ENTROPY_HARDWARE_ALT)\n" \
" !defined(MBEDTLS_ENTROPY_HARDWARE_ALT) && \\\\\n" \
" !defined(MBEDTLS_ENTROPY_NV_SEED)\n" \
"#error \"No entropy source was found at build time, so TLS \" \\\\\n" \
" \"functionality is not available\"\n" \
"#endif\n"
Expand Down
14 changes: 10 additions & 4 deletions features/mbedtls/inc/mbedtls/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@

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

#if defined(MBEDTLS_USER_CONFIG_FILE)
Expand Down Expand Up @@ -2731,15 +2734,18 @@

#include "check_config.h"

#endif /* !MBEDTLS_ENTROPY_HARDWARE_ALT && !MBEDTLS_TEST_NULL_ENTROPY */
#endif /* !MBEDTLS_ENTROPY_HARDWARE_ALT &&
* !MBEDTLS_TEST_NULL_ENTROPY &&
* !MBEDTLS_ENTROPY_NV_SEED */

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

#if defined(MBEDTLS_SSL_TLS_C) && !defined(MBEDTLS_TEST_NULL_ENTROPY) && \
!defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
!defined(MBEDTLS_ENTROPY_HARDWARE_ALT) && \
!defined(MBEDTLS_ENTROPY_NV_SEED)
#error "No entropy source was found at build time, so TLS " \
"functionality is not available"
#endif
Expand Down
4 changes: 4 additions & 0 deletions features/mbedtls/platform/inc/platform_mbed.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
#define MBEDTLS_ENTROPY_HARDWARE_ALT
#endif

#if defined(MBED_CONF_FILESYSTEM_PRESENT)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is it documented what this option entails? Does it ensure the presence of FS IO functions that Mbed TLS is using, with the same (standard) signatures?

#define MBEDTLS_FS_IO
#endif

#if defined(MBEDTLS_CONFIG_HW_SUPPORT)
#include "mbedtls_device.h"
#endif