random: Clarify the semantics of TEST_RANDOM_GENERATOR

The `TEST_RANDOM_GENERATOR` Kconfig symbol indicates that a non-random
number generator (i.e. a random number generator that is not truly
random) is _allowed_ to be used for testing purposes, and not
necessarily that a non-random number generator is _selected_ -- that is
indicated by the `RNG_GENERATOR_CHOICE` choices that depend on
`TEST_RANDOM_GENERATOR` (i.e. only `TIMER_RANDOM_GENERATOR` as of now).

This commit updates the `TEST_RANDOM_GENERATOR` Kconfig symbol
description to reflect and clarify that.

It also removes the `TEST_RANDOM_GENERATOR`'s dependency on
`ENTROPY_HAS_DRIVER` because the act of _allowing_ a non-random number
generator to be used does not depend on the availability of an entropy
driver -- when an entropy driver is available, by default, the
`ENTROPY_DEVICE_RANDOM_GENERATOR` will be selected; otherwise,
`TIMER_RANDOM_GENERATOR`, a non-random generator, will be selected.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
This commit is contained in:
Stephanos Ioannidis 2022-12-14 04:54:13 +09:00 committed by Carles Cufí
commit 6f91f97939
2 changed files with 22 additions and 8 deletions

View file

@ -6,18 +6,32 @@
menu "Random Number Generators"
config TEST_RANDOM_GENERATOR
bool "Non-random number generator"
depends on !ENTROPY_HAS_DRIVER
bool "Allow non-random number generator"
help
This option signifies that the kernel's random number APIs are
permitted to return values that are not truly random.
This capability is provided for testing purposes, when a truly random
This option signifies that a non-random number generator is allowed to
be used and the kernel's random number APIs are permitted to return
values that are not truly random.
This capability is provided for testing purposes when a truly random
number generator is not available. The non-random number generator
should not be used in a production environment.
This option is intended to be selected only by application-level
configurations (e.g. in tests and samples) to indicate that the
application is allowed to run with a random number generator that is not
truly random. Board-level configurations must not select this option
unless the sole purpose of the board is testing (e.g. QEMU emulation
boards).
Note that this option does not imply that a non-random number generator
is selected -- that is indicated by RNG_GENERATOR_CHOICE. An entropy
device-backed random number generator, if available, will be selected by
default even when CONFIG_TEST_RANDOM_GENERATOR=y.
choice RNG_GENERATOR_CHOICE
prompt "Random generator"
default ENTROPY_DEVICE_RANDOM_GENERATOR
default ENTROPY_DEVICE_RANDOM_GENERATOR if ENTROPY_HAS_DRIVER
default TIMER_RANDOM_GENERATOR if TEST_RANDOM_GENERATOR
depends on ENTROPY_HAS_DRIVER || TEST_RANDOM_GENERATOR
help
Platform dependent non-cryptographically secure random number support.