aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2025-10-09 07:49:58 +0100
committerRon Yorston <rmy@pobox.com>2025-10-09 07:49:58 +0100
commit255e7ea4e2a0e3d28c0abf2750f42713eff711d7 (patch)
tree3319e84a7392f9787ed9f93d21d19fc496fd9240 /shell
parent88fd5391b0b7bffda946b586adb1fef4d2412e5f (diff)
downloadbusybox-w32-255e7ea4e2a0e3d28c0abf2750f42713eff711d7.tar.gz
busybox-w32-255e7ea4e2a0e3d28c0abf2750f42713eff711d7.tar.bz2
busybox-w32-255e7ea4e2a0e3d28c0abf2750f42713eff711d7.zip
win32: use RtlGenRandom for /dev/urandom
Use the (somewhat ancient) Microsoft RtlGenRandom() function to provide random data for /dev/urandom. Saves 176-240 bytes. (GitHub issue #519)
Diffstat (limited to 'shell')
-rw-r--r--shell/Kbuild.src1
-rw-r--r--shell/random.c11
-rw-r--r--shell/random.h3
3 files changed, 0 insertions, 15 deletions
diff --git a/shell/Kbuild.src b/shell/Kbuild.src
index a287fce4e..6bba4989f 100644
--- a/shell/Kbuild.src
+++ b/shell/Kbuild.src
@@ -9,4 +9,3 @@ lib-y:=
9INSERT 9INSERT
10 10
11lib-$(CONFIG_FEATURE_SH_MATH) += math.o 11lib-$(CONFIG_FEATURE_SH_MATH) += math.o
12lib-$(CONFIG_FEATURE_PRNG_SHELL) += random.o
diff --git a/shell/random.c b/shell/random.c
index ffe0cc937..56c7c5a3c 100644
--- a/shell/random.c
+++ b/shell/random.c
@@ -19,17 +19,6 @@
19# include "random.h" 19# include "random.h"
20# define RAND_BASH_MASK 0x7fff 20# define RAND_BASH_MASK 0x7fff
21 21
22# if ENABLE_FEATURE_PRNG_SHELL
23uint32_t FAST_FUNC
24next_random(random_t *rnd)
25{
26 return full_random(rnd) & RAND_BASH_MASK;
27}
28# undef RAND_BASH_MASK
29# define RAND_BASH_MASK 0xffffffff
30# define next_random full_random
31# endif
32
33#else 22#else
34# include <stdint.h> 23# include <stdint.h>
35# include <unistd.h> 24# include <unistd.h>
diff --git a/shell/random.h b/shell/random.h
index 75fe0f69f..c4eb44c13 100644
--- a/shell/random.h
+++ b/shell/random.h
@@ -35,9 +35,6 @@ typedef struct random_t {
35 ((rnd)->galois_LFSR = 0) 35 ((rnd)->galois_LFSR = 0)
36 36
37uint32_t next_random(random_t *rnd) FAST_FUNC; 37uint32_t next_random(random_t *rnd) FAST_FUNC;
38#if ENABLE_FEATURE_PRNG_SHELL
39uint32_t full_random(random_t *rnd) FAST_FUNC;
40#endif
41 38
42POP_SAVED_FUNCTION_VISIBILITY 39POP_SAVED_FUNCTION_VISIBILITY
43 40