summaryrefslogtreecommitdiff
path: root/src/lib/libc/crypt
diff options
context:
space:
mode:
authorbcook <>2014-07-20 20:51:13 +0000
committerbcook <>2014-07-20 20:51:13 +0000
commitf34324d947b29b5a35a325bbd3901294355b4f39 (patch)
tree3cffc18607d7ee2f36193cbc2c6420f39f8d8d9f /src/lib/libc/crypt
parent6f021fc4705d719c57993c7f3e916ed71f4480eb (diff)
downloadopenbsd-f34324d947b29b5a35a325bbd3901294355b4f39.tar.gz
openbsd-f34324d947b29b5a35a325bbd3901294355b4f39.tar.bz2
openbsd-f34324d947b29b5a35a325bbd3901294355b4f39.zip
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 'src/lib/libc/crypt')
-rw-r--r--src/lib/libc/crypt/arc4random.c7
-rw-r--r--src/lib/libc/crypt/arc4random.h13
2 files changed, 14 insertions, 6 deletions
diff --git a/src/lib/libc/crypt/arc4random.c b/src/lib/libc/crypt/arc4random.c
index 3c80beb3b9..e4b6369bf1 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.48 2014/07/19 00:08:41 deraadt Exp $ */ 1/* $OpenBSD: arc4random.c,v 1.49 2014/07/20 20:51:13 bcook Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1996, David Mazieres <dm@uun.org> 4 * Copyright (c) 1996, David Mazieres <dm@uun.org>
@@ -32,9 +32,6 @@
32#include <sys/types.h> 32#include <sys/types.h>
33#include <sys/param.h> 33#include <sys/param.h>
34#include <sys/time.h> 34#include <sys/time.h>
35#include <sys/mman.h>
36
37#include "thread_private.h"
38 35
39#define KEYSTREAM_ONLY 36#define KEYSTREAM_ONLY
40#include "chacha_private.h" 37#include "chacha_private.h"
@@ -90,7 +87,7 @@ _rs_stir(void)
90 u_char rnd[KEYSZ + IVSZ]; 87 u_char rnd[KEYSZ + IVSZ];
91 88
92 if (getentropy(rnd, sizeof rnd) == -1) 89 if (getentropy(rnd, sizeof rnd) == -1)
93 raise(SIGKILL); 90 _getentropy_fail();
94 91
95 if (!rs) 92 if (!rs)
96 _rs_init(rnd, sizeof(rnd)); 93 _rs_init(rnd, sizeof(rnd));
diff --git a/src/lib/libc/crypt/arc4random.h b/src/lib/libc/crypt/arc4random.h
index d867687226..d29873cca4 100644
--- a/src/lib/libc/crypt/arc4random.h
+++ b/src/lib/libc/crypt/arc4random.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: arc4random.h,v 1.2 2014/07/19 00:08:41 deraadt Exp $ */ 1/* $OpenBSD: arc4random.h,v 1.3 2014/07/20 20:51:13 bcook Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1996, David Mazieres <dm@uun.org> 4 * Copyright (c) 1996, David Mazieres <dm@uun.org>
@@ -21,6 +21,17 @@
21/* 21/*
22 * Stub functions for portability. 22 * Stub functions for portability.
23 */ 23 */
24#include <sys/mman.h>
25
26#include <signal.h>
27
28#include "thread_private.h"
29
30static inline void
31_getentropy_fail(void)
32{
33 raise(SIGKILL);
34}
24 35
25static inline int 36static inline int
26_rs_allocate(struct _rs **rsp, struct _rsx **rsxp) 37_rs_allocate(struct _rs **rsp, struct _rsx **rsxp)