diff --git a/drivers/Kconfig b/drivers/Kconfig index 87724553f5..5ee36f8a20 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -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 diff --git a/drivers/Makefile b/drivers/Makefile index cf97712926..fefb6a718b 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -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)) diff --git a/drivers/dev_urandom.c b/drivers/dev_urandom.c index b1ea369665..0e0cf97031 100644 --- a/drivers/dev_urandom.c +++ b/drivers/dev_urandom.c @@ -53,6 +53,8 @@ #include #include +#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 */