Hi,
Trying to implement ECDH I struggled creating the random seed. Using Nordic Security Backend and Vanilla Mbedtls on the nRF5340 I get the following errors:
path/mbedtls/ecdh-p256/build/../src/main.c:19: undefined reference to `mbedtls_entropy_init' path/mbedtls/ecdh-p256/build/../src/main.c:25: undefined reference to `mbedtls_entropy_func'
Minimal non working example:
prj.conf
CONFIG_NORDIC_SECURITY_BACKEND=y CONFIG_ENTROPY_GENERATOR=y CONFIG_MBEDTLS_ENTROPY_ENABLED=y CONFIG_NRF_SECURITY_RNG=y CONFIG_MBEDTLS_ENABLE_HEAP=y CONFIG_MBEDTLS_HEAP_SIZE=4096
main.c
#include <mbedtls/ctr_drbg.h> #include <mbedtls/entropy.h> #include <stdio.h> #include <zephyr.h> void main(void) { mbedtls_entropy_context entropy; mbedtls_ctr_drbg_context ctr_drbg; // random number generator mbedtls_ctr_drbg_init(&ctr_drbg); mbedtls_entropy_init(&entropy); int res = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, NULL, 0); printf("%d", res); }
I assume there is an error or in my configuration, or in the Nordic Security Backend - since it seems that <mbedtls/entropy.h> does not work correctly.
Following change lets the example compile (but is not what I want, since I later woud like to change to CC-312):
prj.conf
CONFIG_MBEDTLS=y CONFIG_ENTROPY_GENERATOR=y CONFIG_MBEDTLS_ENTROPY_ENABLED=y CONFIG_NRF_SECURITY_RNG=y CONFIG_MBEDTLS_ENABLE_HEAP=y CONFIG_MBEDTLS_HEAP_SIZE=4096