forked from nuttx/nuttx-update
/dev/urandom: Add option to replace software PRNG with hardware TRNG.
This commit is contained in:
parent
bf25eef79f
commit
e0aaa168aa
3 changed files with 22 additions and 3 deletions
|
@ -34,8 +34,8 @@ config DEV_URANDOM
|
|||
bool "Enable /dev/urandom"
|
||||
default n
|
||||
---help---
|
||||
Enable support for /dev/urandom provided by a software PRNG
|
||||
implementation.
|
||||
Enable support for /dev/urandom provided by either a hardware TRNG or
|
||||
by a software PRNG implementation.
|
||||
|
||||
NOTE: This option may not be cryptographially secure and should not
|
||||
be enabled if you are concerned about cyptographically secure
|
||||
|
@ -46,7 +46,8 @@ if DEV_URANDOM
|
|||
|
||||
choice
|
||||
prompt "/dev/urandom algorithm"
|
||||
default DEV_URANDOM_XORSHIFT128
|
||||
default DEV_URANDOM_ARCH if ARCH_HAVE_RNG
|
||||
default DEV_URANDOM_XORSHIFT128 if !ARCH_HAVE_RNG
|
||||
|
||||
config DEV_URANDOM_XORSHIFT128
|
||||
bool "xorshift128"
|
||||
|
@ -66,6 +67,18 @@ config DEV_URANDOM_CONGRUENTIAL
|
|||
|
||||
NOTE: Not cyptographically secure
|
||||
|
||||
config DEV_URANDOM_ARCH
|
||||
bool "Architecture-specific"
|
||||
depends on ARCH_HAVE_RNG
|
||||
---help---
|
||||
The implementation of /dev/urandom is provided in archtecture-
|
||||
specific logic using hardware TRNG logic. architecture-specific
|
||||
logic must provide the whole implementation in this case, including
|
||||
the function devurandom_register().
|
||||
|
||||
May or may not be cyptographically secure, depending upon the
|
||||
implementation.
|
||||
|
||||
endchoice # /dev/urandom algorithm
|
||||
endif # DEV_URANDOM
|
||||
|
||||
|
|
|
@ -100,9 +100,11 @@ ifeq ($(CONFIG_PWM),y)
|
|||
endif
|
||||
|
||||
ifeq ($(CONFIG_DEV_URANDOM),y)
|
||||
ifneq ($(CONFIG_DEV_URANDOM_ARCH),y)
|
||||
CSRCS += dev_urandom.c
|
||||
endif
|
||||
endif
|
||||
endif # CONFIG_NFILE_DESCRIPTORS != 0
|
||||
|
||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||
|
|
|
@ -53,6 +53,8 @@
|
|||
#include <nuttx/lib.h>
|
||||
#include <nuttx/fs/fs.h>
|
||||
|
||||
#if defined(CONFIG_DEV_URANDOM) && !defined(CONFIG_DEV_URANDOM_ARCH)
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
@ -297,3 +299,5 @@ void devurandom_register(void)
|
|||
|
||||
(void)register_driver("/dev/urandom", &devurand_fops, 0666, NULL);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_DEV_URANDOM && CONFIG_DEV_URANDOM_ARCH */
|
||||
|
|
Loading…
Reference in a new issue