diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2003-11-03 18:24:29 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2003-11-03 18:24:29 +0000 |
commit | 660262a24f8daae1e5417ca94b02bce0585f726a (patch) | |
tree | fcc4422c67a7bd2334244172293bd117832d1d04 /sys/dev | |
parent | e9a344f9ce8e4163c4a4ca745b27915030cbbbf1 (diff) |
add arc4random_bytes. input ok mickey@
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/rnd.c | 13 | ||||
-rw-r--r-- | sys/dev/rndvar.h | 3 |
2 files changed, 14 insertions, 2 deletions
diff --git a/sys/dev/rnd.c b/sys/dev/rnd.c index a99dfb30c8a..a830b5fcef9 100644 --- a/sys/dev/rnd.c +++ b/sys/dev/rnd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rnd.c,v 1.65 2003/10/21 05:24:40 jmc Exp $ */ +/* $OpenBSD: rnd.c,v 1.66 2003/11/03 18:24:28 tedu Exp $ */ /* * rnd.c -- A strong random number generator @@ -596,6 +596,17 @@ arc4random(void) } void +arc4random_bytes(void *buf, size_t n) +{ + u_int8_t *cp = buf; + u_int8_t *end = cp + n; + + arc4maybeinit(); + while (cp < end) + *cp++ = arc4_getbyte(); +} + +void randomattach(void) { int i; diff --git a/sys/dev/rndvar.h b/sys/dev/rndvar.h index a5677ccb43d..60305d48fa6 100644 --- a/sys/dev/rndvar.h +++ b/sys/dev/rndvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rndvar.h,v 1.18 2003/06/02 19:24:22 mickey Exp $ */ +/* $OpenBSD: rndvar.h,v 1.19 2003/11/03 18:24:28 tedu Exp $ */ /* * Copyright (c) 1996,2000 Michael Shalayeff. @@ -85,6 +85,7 @@ extern struct rndstats rndstats; void enqueue_randomness(int, int); void get_random_bytes(void *, size_t); +void arc4random_bytes(void *, size_t); u_int32_t arc4random(void); #endif /* _KERNEL */ |