zephyr/subsys/random/CMakeLists.txt
Stephanos Ioannidis 37c6d52f8c random: Fix non-random number generator warning condition
The `TEST_RANDOM_GENERATOR` symbol in itself does not imply that a
non-random number generator is selected -- that is indicated by the
`RNG_GENERATOR_CHOICE` choices, of which only `TIMER_RANDOM_GENERATOR`
is a non-random generator.

This commit updates the Random subsystem to print the "non-random
number generator usage warning" when `TIMER_RANDOM_GENERATOR` is
selected, as opposed to when `TEST_RANDOM_GENERATOR` is selected.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2022-12-15 22:35:31 +01:00

31 lines
1.3 KiB
CMake

# SPDX-License-Identifier: Apache-2.0
if (CONFIG_ENTROPY_DEVICE_RANDOM_GENERATOR OR
CONFIG_TIMER_RANDOM_GENERATOR OR
CONFIG_XOSHIRO_RANDOM_GENERATOR)
zephyr_library()
zephyr_library_sources_ifdef(CONFIG_USERSPACE rand32_handlers.c)
endif()
if (CONFIG_TIMER_RANDOM_GENERATOR)
message(WARNING "
Warning: CONFIG_TIMER_RANDOM_GENERATOR is not a truly random generator.
This capability is not secure and it is provided for testing purposes only.
Use it carefully.")
endif()
# XOROSHIRO builds the XOSHIRO implementation because a Kconfig choice cannot
# select another choice as a means of deprecating the symbol. Swapping out the
# implementation lets out-of-tree users still build until the symbol is removed.
zephyr_library_sources_ifdef(CONFIG_TIMER_RANDOM_GENERATOR rand32_timer.c)
zephyr_library_sources_ifdef(CONFIG_XOROSHIRO_RANDOM_GENERATOR rand32_xoshiro128.c)
zephyr_library_sources_ifdef(CONFIG_XOSHIRO_RANDOM_GENERATOR rand32_xoshiro128.c)
zephyr_library_sources_ifdef(CONFIG_CTR_DRBG_CSPRNG_GENERATOR rand32_ctr_drbg.c)
if (CONFIG_ENTROPY_DEVICE_RANDOM_GENERATOR OR CONFIG_HARDWARE_DEVICE_CS_GENERATOR)
zephyr_library_sources(rand32_entropy_device.c)
endif()
if (CONFIG_CTR_DRBG_CSPRNG_GENERATOR)
zephyr_library_link_libraries_ifdef(CONFIG_MBEDTLS mbedTLS)
endif()