summaryrefslogtreecommitdiff
path: root/lib/libc/crypt/arc4random.c
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2005-11-30 07:51:03 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2005-11-30 07:51:03 +0000
commit1fcb44d8d6accf4b13417c63d21bd922f79d386a (patch)
treed5f0eb26e09410e4bf7f6d954c2e138b95ccd125 /lib/libc/crypt/arc4random.c
parent0f97be5213bc1c35042f4403759d8c954c4e631a (diff)
Use sysctl(KERN_ARND) to get n bytes, instead of just 4 at a time
and remove fallback code. If somebody is dumb enough to make the sysctl fail using systrace, he deserves what he gets. Saves 7 syscalls on process startup. looks good miod@ ok deraadt@ tedu@
Diffstat (limited to 'lib/libc/crypt/arc4random.c')
-rw-r--r--lib/libc/crypt/arc4random.c11
1 files changed, 2 insertions, 9 deletions
diff --git a/lib/libc/crypt/arc4random.c b/lib/libc/crypt/arc4random.c
index 843751d09e8..1e338f9968c 100644
--- a/lib/libc/crypt/arc4random.c
+++ b/lib/libc/crypt/arc4random.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: arc4random.c,v 1.14 2005/06/06 14:57:59 kjell Exp $ */
+/* $OpenBSD: arc4random.c,v 1.15 2005/11/30 07:51:02 otto Exp $ */
/*
* Copyright (c) 1996, David Mazieres <dm@uun.org>
@@ -99,14 +99,7 @@ arc4_stir(struct arc4_stream *as)
mib[1] = KERN_ARND;
len = sizeof(rnd);
- if (sysctl(mib, 2, rnd, &len, NULL, 0) == -1) {
- for (i = 0; i < sizeof(rnd) / sizeof(u_int); i ++) {
- len = sizeof(u_int);
- if (sysctl(mib, 2, &rnd[i * sizeof(u_int)], &len,
- NULL, 0) == -1)
- break;
- }
- }
+ sysctl(mib, 2, rnd, &len, NULL, 0);
arc4_stir_pid = getpid();
arc4_addrandom(as, rnd, sizeof(rnd));