mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 14:27:37 +08:00
/dev/urandom: Add option to replace software PRNG with hardware TRNG.
This commit is contained in:
+16
-3
@@ -34,8 +34,8 @@ config DEV_URANDOM
|
|||||||
bool "Enable /dev/urandom"
|
bool "Enable /dev/urandom"
|
||||||
default n
|
default n
|
||||||
---help---
|
---help---
|
||||||
Enable support for /dev/urandom provided by a software PRNG
|
Enable support for /dev/urandom provided by either a hardware TRNG or
|
||||||
implementation.
|
by a software PRNG implementation.
|
||||||
|
|
||||||
NOTE: This option may not be cryptographially secure and should not
|
NOTE: This option may not be cryptographially secure and should not
|
||||||
be enabled if you are concerned about cyptographically secure
|
be enabled if you are concerned about cyptographically secure
|
||||||
@@ -46,7 +46,8 @@ if DEV_URANDOM
|
|||||||
|
|
||||||
choice
|
choice
|
||||||
prompt "/dev/urandom algorithm"
|
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
|
config DEV_URANDOM_XORSHIFT128
|
||||||
bool "xorshift128"
|
bool "xorshift128"
|
||||||
@@ -66,6 +67,18 @@ config DEV_URANDOM_CONGRUENTIAL
|
|||||||
|
|
||||||
NOTE: Not cyptographically secure
|
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
|
endchoice # /dev/urandom algorithm
|
||||||
endif # DEV_URANDOM
|
endif # DEV_URANDOM
|
||||||
|
|
||||||
|
|||||||
@@ -100,9 +100,11 @@ ifeq ($(CONFIG_PWM),y)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_DEV_URANDOM),y)
|
ifeq ($(CONFIG_DEV_URANDOM),y)
|
||||||
|
ifneq ($(CONFIG_DEV_URANDOM_ARCH),y)
|
||||||
CSRCS += dev_urandom.c
|
CSRCS += dev_urandom.c
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
endif # CONFIG_NFILE_DESCRIPTORS != 0
|
||||||
|
|
||||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||||
|
|||||||
@@ -53,6 +53,8 @@
|
|||||||
#include <nuttx/lib.h>
|
#include <nuttx/lib.h>
|
||||||
#include <nuttx/fs/fs.h>
|
#include <nuttx/fs/fs.h>
|
||||||
|
|
||||||
|
#if defined(CONFIG_DEV_URANDOM) && !defined(CONFIG_DEV_URANDOM_ARCH)
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -297,3 +299,5 @@ void devurandom_register(void)
|
|||||||
|
|
||||||
(void)register_driver("/dev/urandom", &devurand_fops, 0666, NULL);
|
(void)register_driver("/dev/urandom", &devurand_fops, 0666, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* CONFIG_DEV_URANDOM && CONFIG_DEV_URANDOM_ARCH */
|
||||||
|
|||||||
Reference in New Issue
Block a user