summaryrefslogtreecommitdiffstats
path: root/sys/dev/rndvar.h
diff options
context:
space:
mode:
authordjm <djm@openbsd.org>2008-03-02 21:29:06 +0000
committerdjm <djm@openbsd.org>2008-03-02 21:29:06 +0000
commit75eb879db294a00ed42d2baec9891df994afd113 (patch)
tree5cf89d9e0b1f5d34b41ce012d1d88991f6b83886 /sys/dev/rndvar.h
parentKeep resolv.conf.shadow around when restarting an install. This (diff)
downloadwireguard-openbsd-75eb879db294a00ed42d2baec9891df994afd113.tar.xz
wireguard-openbsd-75eb879db294a00ed42d2baec9891df994afd113.zip
Add a arc4random_uniform() that returns a uniformly distributed number
in the range 0 <= x < upper_bound Please use this new API instead of "arc4random() % upper_bound", as it avoids the "modulo bias" that favours small results when upper_bound is not a power of two. feedback deraadt@ mcbride@; ok deraadt@
Diffstat (limited to 'sys/dev/rndvar.h')
-rw-r--r--sys/dev/rndvar.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/sys/dev/rndvar.h b/sys/dev/rndvar.h
index 60305d48fa6..c6831502c0b 100644
--- a/sys/dev/rndvar.h
+++ b/sys/dev/rndvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rndvar.h,v 1.19 2003/11/03 18:24:28 tedu Exp $ */
+/* $OpenBSD: rndvar.h,v 1.20 2008/03/02 21:29:07 djm Exp $ */
/*
* Copyright (c) 1996,2000 Michael Shalayeff.
@@ -87,6 +87,7 @@ void enqueue_randomness(int, int);
void get_random_bytes(void *, size_t);
void arc4random_bytes(void *, size_t);
u_int32_t arc4random(void);
+u_int32_t arc4random_uniform(u_int32_t);
#endif /* _KERNEL */