diff options
author | beck <> | 2016-09-03 11:33:43 +0000 |
---|---|---|
committer | beck <> | 2016-09-03 11:33:43 +0000 |
commit | 839327196dbc0dd6ca80811d25a0b2bf18060cb7 (patch) | |
tree | bda3f96ee18135da341fa9b72de3608609a4f2b7 /src/lib/libcrypto/crypto/arc4random_netbsd.h | |
parent | 68562b91f88d1a8511c997984c90fcdf0e29fc1f (diff) | |
download | openbsd-839327196dbc0dd6ca80811d25a0b2bf18060cb7.tar.gz openbsd-839327196dbc0dd6ca80811d25a0b2bf18060cb7.tar.bz2 openbsd-839327196dbc0dd6ca80811d25a0b2bf18060cb7.zip |
Remove the libcrypto/crypto directory
Diffstat (limited to 'src/lib/libcrypto/crypto/arc4random_netbsd.h')
-rw-r--r-- | src/lib/libcrypto/crypto/arc4random_netbsd.h | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/src/lib/libcrypto/crypto/arc4random_netbsd.h b/src/lib/libcrypto/crypto/arc4random_netbsd.h deleted file mode 100644 index 611997d54d..0000000000 --- a/src/lib/libcrypto/crypto/arc4random_netbsd.h +++ /dev/null | |||
@@ -1,87 +0,0 @@ | |||
1 | /* $OpenBSD: arc4random_netbsd.h,v 1.3 2016/06/30 12:19:51 bcook Exp $ */ | ||
2 | |||
3 | /* | ||
4 | * Copyright (c) 1996, David Mazieres <dm@uun.org> | ||
5 | * Copyright (c) 2008, Damien Miller <djm@openbsd.org> | ||
6 | * Copyright (c) 2013, Markus Friedl <markus@openbsd.org> | ||
7 | * Copyright (c) 2014, Theo de Raadt <deraadt@openbsd.org> | ||
8 | * | ||
9 | * Permission to use, copy, modify, and distribute this software for any | ||
10 | * purpose with or without fee is hereby granted, provided that the above | ||
11 | * copyright notice and this permission notice appear in all copies. | ||
12 | * | ||
13 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
14 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
15 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
16 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
17 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
18 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
19 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
20 | */ | ||
21 | |||
22 | /* | ||
23 | * Stub functions for portability. | ||
24 | */ | ||
25 | |||
26 | #include <sys/mman.h> | ||
27 | |||
28 | #include <pthread.h> | ||
29 | #include <signal.h> | ||
30 | |||
31 | static pthread_mutex_t arc4random_mtx = PTHREAD_MUTEX_INITIALIZER; | ||
32 | #define _ARC4_LOCK() pthread_mutex_lock(&arc4random_mtx) | ||
33 | #define _ARC4_UNLOCK() pthread_mutex_unlock(&arc4random_mtx) | ||
34 | |||
35 | /* | ||
36 | * Unfortunately, pthread_atfork() is broken on FreeBSD (at least 9 and 10) if | ||
37 | * a program does not link to -lthr. Callbacks registered with pthread_atfork() | ||
38 | * appear to fail silently. So, it is not always possible to detect a PID | ||
39 | * wraparound. | ||
40 | */ | ||
41 | #define _ARC4_ATFORK(f) pthread_atfork(NULL, NULL, (f)) | ||
42 | |||
43 | static inline void | ||
44 | _getentropy_fail(void) | ||
45 | { | ||
46 | raise(SIGKILL); | ||
47 | } | ||
48 | |||
49 | static volatile sig_atomic_t _rs_forked; | ||
50 | |||
51 | static inline void | ||
52 | _rs_forkhandler(void) | ||
53 | { | ||
54 | _rs_forked = 1; | ||
55 | } | ||
56 | |||
57 | static inline void | ||
58 | _rs_forkdetect(void) | ||
59 | { | ||
60 | static pid_t _rs_pid = 0; | ||
61 | pid_t pid = getpid(); | ||
62 | |||
63 | if (_rs_pid == 0 || _rs_pid != pid || _rs_forked) { | ||
64 | _rs_pid = pid; | ||
65 | _rs_forked = 0; | ||
66 | if (rs) | ||
67 | memset(rs, 0, sizeof(*rs)); | ||
68 | } | ||
69 | } | ||
70 | |||
71 | static inline int | ||
72 | _rs_allocate(struct _rs **rsp, struct _rsx **rsxp) | ||
73 | { | ||
74 | if ((*rsp = mmap(NULL, sizeof(**rsp), PROT_READ|PROT_WRITE, | ||
75 | MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) | ||
76 | return (-1); | ||
77 | |||
78 | if ((*rsxp = mmap(NULL, sizeof(**rsxp), PROT_READ|PROT_WRITE, | ||
79 | MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) { | ||
80 | munmap(*rsp, sizeof(**rsp)); | ||
81 | *rsp = NULL; | ||
82 | return (-1); | ||
83 | } | ||
84 | |||
85 | _ARC4_ATFORK(_rs_forkhandler); | ||
86 | return (0); | ||
87 | } | ||