Add MBEDTLS_PLATFORM_DEV_RANDOM as a compile-time option

Document when this is not used. This was the case in TF-PSA-Crypto 1.0.0,
but not yet in Mbed TLS 3.6.

Signed-off-by: Gilles Peskine <[email protected]>
This commit is contained in:
Gilles Peskine
2026-02-25 22:43:19 +01:00
parent 2ccda0f48c
commit 8f962c1b22
3 changed files with 32 additions and 3 deletions
+4
View File
@@ -0,0 +1,4 @@
Features
* The device for reading entropy on platforms without a dedicated system
call can now be configured with MBEDTLS_PLATFORM_DEV_RANDOM or
mbedtls_platform_dev_random.
+26
View File
@@ -1204,6 +1204,20 @@
* This is useful if your platform does not support
* standards like the /dev/urandom or Windows CryptoAPI.
*
* If you enable this macro, you will probably need to enable
* #MBEDTLS_ENTROPY_HARDWARE_ALT and provide a function
* mbedtls_hardware_poll().
*
* \note The default platform entropy function supports the following
* sources:
* - getrandom() on Linux (if syscall() is available at compile time);
* - getrandom() on FreeBSD and DragonFlyBSD (if available at compile
* time);
* - `sysctl(KERN_ARND)` on FreeBSD and NetBSD;
* - #MBEDTLS_PLATFORM_DEV_RANDOM on Unix-like platforms
* (unless one of the above is used);
* - BCryptGenRandom() on Windows.
*
* Uncomment this macro to disable the built-in platform entropy functions.
*/
//#define MBEDTLS_NO_PLATFORM_ENTROPY
@@ -4140,6 +4154,18 @@
//#define MBEDTLS_PLATFORM_MS_TIME_TYPE_MACRO int64_t //#define MBEDTLS_PLATFORM_MS_TIME_TYPE_MACRO int64_t /**< Default milliseconds time macro to use, can be undefined. MBEDTLS_HAVE_TIME must be enabled. It must be signed, and at least 64 bits. If it is changed from the default, MBEDTLS_PRINTF_MS_TIME must be updated to match.*/
//#define MBEDTLS_PRINTF_MS_TIME PRId64 /**< Default fmt for printf. That's avoid compiler warning if mbedtls_ms_time_t is redefined */
/*** \def MBEDTLS_PLATFORM_DEV_RANDOM
*
* Path to a special file that returns cryptographic-quality random bytes
* when read. This is used by the default platform entropy source on
* non-Windows platforms unless a dedicated system call is available
* (see #MBEDTLS_NO_PLATFORM_ENTROPY).
*
* This is the default value of ::mbedtls_platform_dev_random, which
* can be changed at run time.
*/
//#define MBEDTLS_PLATFORM_DEV_RANDOM "/dev/urandom"
/** \def MBEDTLS_CHECK_RETURN
*
* This macro is used at the beginning of the declaration of a function
+2 -3
View File
@@ -401,11 +401,10 @@ int mbedtls_platform_set_exit(void (*exit_func)(int status));
#if defined(MBEDTLS_PLATFORM_HAVE_DEV_RANDOM)
/**
* Path to a special file that returns cryptographic-quality random bytes
* when read. This is used by the default platform entropy source on
* non-Windows platforms unless a dedicated system call is available
* (see #MBEDTLS_NO_PLATFORM_ENTROPY).
* when read.
*
* The default value is #MBEDTLS_PLATFORM_DEV_RANDOM.
* See the documentation of this option for guidance.
*/
extern const char *mbedtls_platform_dev_random;
#endif