From 00a9b6df773f482e4ea3d79fa8a3fc5d8342ce2a Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Wed, 24 Jul 2019 09:43:44 +0100 Subject: [PATCH] tinyCrypt: Enforce global RNG tinyCrypt uses a global RNG without context parameter while Mbed TLS in its default configuration uses RNG+CTX bound to the SSL configuration. This commit restricts the use of tinyCrypt to configurations that use a global RNG function with NULL context by setting MBEDTLS_SSL_CONF_RNG in the configuration. This allows to define a wrapper RNG to be used by tinyCrypt which maps to this global hardcoded RNG. --- include/mbedtls/check_config.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/mbedtls/check_config.h b/include/mbedtls/check_config.h index 29e61db84..647e7c1b2 100644 --- a/include/mbedtls/check_config.h +++ b/include/mbedtls/check_config.h @@ -103,6 +103,11 @@ #error "MBEDTLS_USE_TINYCRYPT defined, but it cannot be defined with MBEDTLS_NO_64BIT_MULTIPLICATION" #endif +#if defined(MBEDTLS_USE_TINYCRYPT) && \ + !defined(MBEDTLS_SSL_CONF_RNG) +#error "MBEDTLS_USE_TINYCRYPT defined, but not all prerequesites" +#endif + #if defined(MBEDTLS_NIST_KW_C) && \ ( !defined(MBEDTLS_AES_C) || !defined(MBEDTLS_CIPHER_C) ) #error "MBEDTLS_NIST_KW_C defined, but not all prerequisites"