summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorderaadt <>2014-06-13 15:36:37 +0000
committerderaadt <>2014-06-13 15:36:37 +0000
commit378abe0ca2a1224356342d63a962108de549162f (patch)
treeb066f017e8813e87254bdccdb82f1284b87a1c4d
parentc2d937dced6c0707f6b56cdd86aa9084f9aa18f0 (diff)
downloadopenbsd-378abe0ca2a1224356342d63a962108de549162f.tar.gz
openbsd-378abe0ca2a1224356342d63a962108de549162f.tar.bz2
openbsd-378abe0ca2a1224356342d63a962108de549162f.zip
use getgentropy() call. If it fails, things are pretty bad --
call abort(). this direction discussed at length with miod beck tedu matthew etc
-rw-r--r--src/lib/libc/crypt/arc4random.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/src/lib/libc/crypt/arc4random.c b/src/lib/libc/crypt/arc4random.c
index e08b729a04..4b6cde63fb 100644
--- a/src/lib/libc/crypt/arc4random.c
+++ b/src/lib/libc/crypt/arc4random.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: arc4random.c,v 1.31 2014/05/31 10:32:12 jca Exp $ */ 1/* $OpenBSD: arc4random.c,v 1.32 2014/06/13 15:36:37 deraadt Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1996, David Mazieres <dm@uun.org> 4 * Copyright (c) 1996, David Mazieres <dm@uun.org>
@@ -77,15 +77,10 @@ _rs_init(u_char *buf, size_t n)
77static void 77static void
78_rs_stir(void) 78_rs_stir(void)
79{ 79{
80 int mib[2];
81 size_t len;
82 u_char rnd[KEYSZ + IVSZ]; 80 u_char rnd[KEYSZ + IVSZ];
83 81
84 mib[0] = CTL_KERN; 82 if (getentropy(rnd, sizeof rnd) == -1)
85 mib[1] = KERN_ARND; 83 abort();
86
87 len = sizeof(rnd);
88 sysctl(mib, 2, rnd, &len, NULL, 0);
89 84
90 if (!rs_initialized) { 85 if (!rs_initialized) {
91 rs_initialized = 1; 86 rs_initialized = 1;