From f8452f05564b5820c3745b9348d85a2b3a745467 Mon Sep 17 00:00:00 2001 From: otto <> Date: Wed, 30 Nov 2005 07:51:02 +0000 Subject: 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@ --- src/lib/libc/crypt/arc4random.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'src/lib/libc/crypt/arc4random.c') diff --git a/src/lib/libc/crypt/arc4random.c b/src/lib/libc/crypt/arc4random.c index 843751d09e..1e338f9968 100644 --- a/src/lib/libc/crypt/arc4random.c +++ b/src/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 @@ -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)); -- cgit v1.2.3-55-g6feb