MbedTLS configuration STD functions

Hello,

I am building an example app that uses MbedTLS and non-offloaded sockets, because offloaded ones do not fit my needs - updating security credentials needs disabling the modem, while I perform a Bootstrap operation being connected to one server and obtain credentials for a Management server connection that need to be applied before Bootstrap connection. Also I intend to do runtime certificate provisioning that could not be achieved with offloaded sockets.

I use nRF9160DK. I had a working application on nCS 2.5 and I am trying to switch to nCS 3.1 but I can't figure out the MbedTLS configuration that will compile, because every time I get these errors:

/home/tomasz/zephyrproject/modules/crypto/mbedtls/include/mbedtls/check_config.h:637:2: error: #error "MBEDTLS_PLATFORM_STD_EXIT defined, but not all prerequisites"
637 | #error "MBEDTLS_PLATFORM_STD_EXIT defined, but not all prerequisites"
| ^~~~~
/home/tomasz/zephyrproject/modules/crypto/mbedtls/include/mbedtls/check_config.h:643:2: error: #error "MBEDTLS_PLATFORM_STD_TIME defined, but not all prerequisites"
643 | #error "MBEDTLS_PLATFORM_STD_TIME defined, but not all prerequisites"
| ^~~~~
/home/tomasz/zephyrproject/modules/crypto/mbedtls/include/mbedtls/check_config.h:648:2: error: #error "MBEDTLS_PLATFORM_STD_FPRINTF defined, but not all prerequisites"
648 | #error "MBEDTLS_PLATFORM_STD_FPRINTF defined, but not all prerequisites"
| ^~~~~
/home/tomasz/zephyrproject/modules/crypto/mbedtls/include/mbedtls/check_config.h:653:2: error: #error "MBEDTLS_PLATFORM_STD_PRINTF defined, but not all prerequisites"
653 | #error "MBEDTLS_PLATFORM_STD_PRINTF defined, but not all prerequisites"
| ^~~~~
/home/tomasz/zephyrproject/modules/crypto/mbedtls/include/mbedtls/check_config.h:658:2: error: #error "MBEDTLS_PLATFORM_STD_SNPRINTF defined, but not all prerequisites"
658 | #error "MBEDTLS_PLATFORM_STD_SNPRINTF defined, but not all prerequisites"
| ^~~~~

I have experimented with changes in these switches

CONFIG_NORDIC_SECURITY_BACKEND=y
CONFIG_OBERON_BACKEND=y
CONFIG_NRF_SECURITY=y
CONFIG_MBEDTLS_TLS_LIBRARY=y
CONFIG_MBEDTLS=y
CONFIG_MBEDTLS_PLATFORM_NO_STD_FUNCTIONS=y

but I always get these errors. I can't manually define CONFIG_MBEDTLS_PLATFORM_C, I can't manually set anything like
CONFIG_MBEDTLS_PLATFORM_EXIT_ALT=y
CONFIG_MBEDTLS_PLATFORM_PRINTF_ALT=y
CONFIG_MBEDTLS_PLATFORM_FPRINTF_ALT=y
CONFIG_MBEDTLS_PLATFORM_SNPRINTF_ALT=y
CONFIG_MBEDTLS_PLATFORM_TIME_ALT=y
or
CONFIG_MBEDTLS_PLATFORM_EXIT=y
CONFIG_MBEDTLS_PLATFORM_PRINTF=y
CONFIG_MBEDTLS_PLATFORM_FPRINTF=y
CONFIG_MBEDTLS_PLATFORM_SNPRINTF=y
CONFIG_MBEDTLS_PLATFORM_TIME=y
Using #defines in headers instead of prj.conf didn't work either.

I can't find any example of that in nCS repo. I found a pretty similar issue here Can't build Google IOT MQTT Sample for nRF9160 with nRF Connect SDK 2.3.0
but I found the related file https://github.com/nrfconnect/sdk-nrf/blob/v2.3.0/samples/net/mqtt/overlay-tls-native_posix.conf
and it does not seem to be anyhow related to my problem.
I must be missing something and I ask for help on how to enable non-offloaded, compiled in MbedTLS on nCS 3.1
Parents
  • Hello,

    you can look at the mbedtls related configs in this file.

    Also, the legacy crypto API is being deprecated and will be removed in future releases. You can read about it here.

  • Hi,

    Thanks for the reference, although it turned out to be not related to this...

    Oh dear lord. It took me 2 days but I think I got this.
    My application included 

    # include <mbedtls/platform.h>
    which appears to introduce some of these MBEDTLS_PLATFORM_PRINTF and similar definitions not where it's expected. With a chain
    my_header.h ->platform.h + ssl.h -> platform_util.h -> build_info.h -> check_config.h
    MbedTLS check config found this conflict and gave compile time errors. Commenting out include platform.h helped.
    I have no idea how and where these defines should be then, but I guess I don't care now.
    Also this worked perfectly fine in older nCS version, so I could not expect such mess.
Reply
  • Hi,

    Thanks for the reference, although it turned out to be not related to this...

    Oh dear lord. It took me 2 days but I think I got this.
    My application included 

    # include <mbedtls/platform.h>
    which appears to introduce some of these MBEDTLS_PLATFORM_PRINTF and similar definitions not where it's expected. With a chain
    my_header.h ->platform.h + ssl.h -> platform_util.h -> build_info.h -> check_config.h
    MbedTLS check config found this conflict and gave compile time errors. Commenting out include platform.h helped.
    I have no idea how and where these defines should be then, but I guess I don't care now.
    Also this worked perfectly fine in older nCS version, so I could not expect such mess.
Children
Related