diff options
Diffstat (limited to 'lib/libc/gen/arc4random.c')
-rw-r--r-- | lib/libc/gen/arc4random.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/libc/gen/arc4random.c b/lib/libc/gen/arc4random.c index 6aa2323..7c11da2 100644 --- a/lib/libc/gen/arc4random.c +++ b/lib/libc/gen/arc4random.c @@ -164,7 +164,7 @@ arc4_check_init(void) } } -static void +static inline void arc4_check_stir(void) { if (!rs_stired || arc4_count <= 0) { @@ -208,6 +208,21 @@ arc4random(void) return (rnd); } +void +arc4random_buf(void *_buf, size_t n) +{ + u_char *buf = (u_char *)_buf; + + THREAD_LOCK(); + arc4_check_init(); + while (n--) { + arc4_check_stir(); + buf[n] = arc4_getbyte(&rs); + arc4_count--; + } + THREAD_UNLOCK(); +} + #if 0 /*-------- Test code for i386 --------*/ #include <stdio.h> |