You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
psa_crypto_init (and specifically, mbedtls_psa_crypto_init_subsystem) pass &global_data.rng to mbedtls_psa_random_init and mbedtls_psa_random_seed. If platform entropy is disabled, there is no way to provide a random generator to these methods.
System information
Mbed TLS version (number or commit id): 3.6.2
Operating system and version: HorizonOS 19.0.1 (Nintendo Switch)
Configuration (if not default, please attach mbedtls_config.h): Too big for pasting contents, .h extension not allowed.
Compiler and options (if you used a pre-built binary, please indicate how you obtained it): devkitpro
Additional environment information: N/A
Expected behavior
mbedtls_ssl_handshake uses the configured entropy source (following the guide) to which I've provided my source with mbedtls_entropy_add_source.
Actual behavior
A different entropy source is used which returns -64 (MBEDTLS_ERR_ENTROPY_NO_SOURCES_DEFINED)
Steps to reproduce
Follow the guide linked above with MBEDTLS_NO_PLATFORM_ENTROPY enabled in config, and add your own entropy source to your entropy context.
The PSA subsystem has its own random generator. It doesn't use the RNG passed to mbedtls_ssl_conf_rng, and more generally it does not support runtime configuration. This was a deliberate design choice, because very few scenarios require a runtime-configurable RNG: highly constrained platforms typically have an entropy source that's configured by the system integrator as mbedtls_hardware_poll(), and higher-end platforms such as Linux or Windows have an entropy source in the operating system. Conversely, experience shows that giving application writers the ability to configure entropy sources tends to result is misconfigurations.
I'm afraid the tutorial is somewhat out of date. The recommended way to configure a platform-specific entropy source is through MBEDTLS_ENTROPY_HARDWARE_ALT.
gilles-peskine-arm
changed the title
psa_crypto_init does not use provided entropy source
The explanation of entropy configuration in the tutorial is incompatible with PSA
Feb 16, 2025
Summary
psa_crypto_init (and specifically, mbedtls_psa_crypto_init_subsystem) pass
&global_data.rng
to mbedtls_psa_random_init and mbedtls_psa_random_seed. If platform entropy is disabled, there is no way to provide a random generator to these methods.System information
Mbed TLS version (number or commit id): 3.6.2
Operating system and version: HorizonOS 19.0.1 (Nintendo Switch)
Configuration (if not default, please attach
mbedtls_config.h
): Too big for pasting contents, .h extension not allowed.Compiler and options (if you used a pre-built binary, please indicate how you obtained it): devkitpro
Additional environment information: N/A
Expected behavior
mbedtls_ssl_handshake uses the configured entropy source (following the guide) to which I've provided my source with mbedtls_entropy_add_source.
Actual behavior
A different entropy source is used which returns -64 (MBEDTLS_ERR_ENTROPY_NO_SOURCES_DEFINED)
Steps to reproduce
Follow the guide linked above with MBEDTLS_NO_PLATFORM_ENTROPY enabled in config, and add your own entropy source to your entropy context.
Additional information
expand for source file
The text was updated successfully, but these errors were encountered: