Skip to content
Permalink
Browse files

ext: mbedtls: Don't define MBEDTLS_PLATFORM_NO_STD_FUNCTIONS

That means that when mbedTLS will need functions like snprintf(),
printf(), a few others, they will be used from libc, as done
normally by most of software. Note that mentioned functions
aren't normally used on code paths doing TLS communication per se.
Instead, they are used by debug logging, additional "print info"
style functions, etc.

Before, when MBEDTLS_PLATFORM_NO_STD_FUNCTIONS was defined, those
functions were stubbed out, so silently didn't work as expected
(a specific symptom seen was that some debug messages were printed
as garbage, because an buffer on stack was passed to dummy snprintf
stub, which didn't do anything to it, and its uninitialized contents
were printed afterwards. Instead, the expectation was that an
application would call a "setter" function to set snprintf, etc.
implementations as provided by application itself.

For Zephyr, we clearly don't need to burden applications with such
setup, instead Zephyr, as an OS, provides integrated environment
were matters like that "just work". So, we just switch to libc-based
functions. If there ever will be usecases for
MBEDTLS_PLATFORM_NO_STD_FUNCTIONS, it can be made configurable later.

Fixes: #16303

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
  • Loading branch information...
pfalcon authored and nashif committed May 22, 2019
1 parent 6b9e160 commit f0ea13d2a2242f7ff19ec9febefbbdbcd8077b8c
Showing with 0 additions and 3 deletions.
  1. +0 −3 ext/lib/crypto/mbedtls/configs/config-tls-generic.h
@@ -15,12 +15,9 @@
#define MBEDTLS_PLATFORM_C
#define MBEDTLS_PLATFORM_MEMORY
#define MBEDTLS_MEMORY_BUFFER_ALLOC_C
#define MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
#define MBEDTLS_PLATFORM_EXIT_ALT
#define MBEDTLS_NO_PLATFORM_ENTROPY
#define MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
#define MBEDTLS_PLATFORM_PRINTF_ALT
#define MBEDTLS_PLATFORM_SNPRINTF_ALT

#if defined(CONFIG_MBEDTLS_HAVE_ASM)
#define MBEDTLS_HAVE_ASM

0 comments on commit f0ea13d

Please sign in to comment.
You can’t perform that action at this time.