diff options
author | Ron Yorston <rmy@pobox.com> | 2018-03-22 14:58:29 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2018-03-22 15:11:41 +0000 |
commit | 6cff8357023adb4d5c9daa027522f883f3905f4c (patch) | |
tree | 50964ae864ec3325c2413facaa8efc3a3104f3a6 /shell | |
parent | be9b9ed64e658889229e18e3d089df27d8b724c3 (diff) | |
download | busybox-w32-6cff8357023adb4d5c9daa027522f883f3905f4c.tar.gz busybox-w32-6cff8357023adb4d5c9daa027522f883f3905f4c.tar.bz2 busybox-w32-6cff8357023adb4d5c9daa027522f883f3905f4c.zip |
win32: allow use of shell's PRNG for /dev/urandom
Allow either ISAAC or the shell's built-in pseudo-random number
generator to be used for /dev/urandom. The latter is smaller so
it's the default.
Diffstat (limited to 'shell')
-rw-r--r-- | shell/Kbuild.src | 1 | ||||
-rw-r--r-- | shell/random.c | 11 | ||||
-rw-r--r-- | shell/random.h | 3 |
3 files changed, 15 insertions, 0 deletions
diff --git a/shell/Kbuild.src b/shell/Kbuild.src index 6bba4989f..a287fce4e 100644 --- a/shell/Kbuild.src +++ b/shell/Kbuild.src | |||
@@ -9,3 +9,4 @@ lib-y:= | |||
9 | INSERT | 9 | INSERT |
10 | 10 | ||
11 | lib-$(CONFIG_FEATURE_SH_MATH) += math.o | 11 | lib-$(CONFIG_FEATURE_SH_MATH) += math.o |
12 | lib-$(CONFIG_FEATURE_PRNG_SHELL) += random.o | ||
diff --git a/shell/random.c b/shell/random.c index 5d3620516..614172279 100644 --- a/shell/random.c +++ b/shell/random.c | |||
@@ -19,6 +19,17 @@ | |||
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 | ||
23 | uint32_t FAST_FUNC | ||
24 | next_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 | |||
22 | #else | 33 | #else |
23 | # include <stdint.h> | 34 | # include <stdint.h> |
24 | # include <unistd.h> | 35 | # include <unistd.h> |
diff --git a/shell/random.h b/shell/random.h index c4eb44c13..75fe0f69f 100644 --- a/shell/random.h +++ b/shell/random.h | |||
@@ -35,6 +35,9 @@ typedef struct random_t { | |||
35 | ((rnd)->galois_LFSR = 0) | 35 | ((rnd)->galois_LFSR = 0) |
36 | 36 | ||
37 | uint32_t next_random(random_t *rnd) FAST_FUNC; | 37 | uint32_t next_random(random_t *rnd) FAST_FUNC; |
38 | #if ENABLE_FEATURE_PRNG_SHELL | ||
39 | uint32_t full_random(random_t *rnd) FAST_FUNC; | ||
40 | #endif | ||
38 | 41 | ||
39 | POP_SAVED_FUNCTION_VISIBILITY | 42 | POP_SAVED_FUNCTION_VISIBILITY |
40 | 43 | ||