diff options
author | bcook <bcook@cvs.openbsd.org> | 2014-07-20 20:51:14 +0000 |
---|---|---|
committer | bcook <bcook@cvs.openbsd.org> | 2014-07-20 20:51:14 +0000 |
commit | 43b96940ee4a95bd9ca411e91c2911ce14cfd74e (patch) | |
tree | 8cbd3de145056d9ff1a61e2827a5d01ba98f51cf /lib/libc | |
parent | 404854e696fa6480e40e79141dbe0f631f9e2c11 (diff) |
Move more OS-specific functionality to arc4random.h headers.
Move <sys/mman.h> and raise(SIGKILL) calls to OS-specific headers.
On OpenBSD, move thread_private.h as well to arc4random.h.
On Windows, use TerminateProcess on getentropy failure.
ok deraadt@
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/crypt/arc4random.c | 7 | ||||
-rw-r--r-- | lib/libc/crypt/arc4random.h | 13 |
2 files changed, 14 insertions, 6 deletions
diff --git a/lib/libc/crypt/arc4random.c b/lib/libc/crypt/arc4random.c index 3c80beb3b96..e4b6369bf1e 100644 --- a/lib/libc/crypt/arc4random.c +++ b/lib/libc/crypt/arc4random.c @@ -1,4 +1,4 @@ -/* $OpenBSD: arc4random.c,v 1.48 2014/07/19 00:08:41 deraadt Exp $ */ +/* $OpenBSD: arc4random.c,v 1.49 2014/07/20 20:51:13 bcook Exp $ */ /* * Copyright (c) 1996, David Mazieres <dm@uun.org> @@ -32,9 +32,6 @@ #include <sys/types.h> #include <sys/param.h> #include <sys/time.h> -#include <sys/mman.h> - -#include "thread_private.h" #define KEYSTREAM_ONLY #include "chacha_private.h" @@ -90,7 +87,7 @@ _rs_stir(void) u_char rnd[KEYSZ + IVSZ]; if (getentropy(rnd, sizeof rnd) == -1) - raise(SIGKILL); + _getentropy_fail(); if (!rs) _rs_init(rnd, sizeof(rnd)); diff --git a/lib/libc/crypt/arc4random.h b/lib/libc/crypt/arc4random.h index d867687226f..d29873cca4c 100644 --- a/lib/libc/crypt/arc4random.h +++ b/lib/libc/crypt/arc4random.h @@ -1,4 +1,4 @@ -/* $OpenBSD: arc4random.h,v 1.2 2014/07/19 00:08:41 deraadt Exp $ */ +/* $OpenBSD: arc4random.h,v 1.3 2014/07/20 20:51:13 bcook Exp $ */ /* * Copyright (c) 1996, David Mazieres <dm@uun.org> @@ -21,6 +21,17 @@ /* * Stub functions for portability. */ +#include <sys/mman.h> + +#include <signal.h> + +#include "thread_private.h" + +static inline void +_getentropy_fail(void) +{ + raise(SIGKILL); +} static inline int _rs_allocate(struct _rs **rsp, struct _rsx **rsxp) |