summaryrefslogtreecommitdiff
path: root/src/lib/libc/crypt/arc4random.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libc/crypt/arc4random.h')
-rw-r--r--src/lib/libc/crypt/arc4random.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/lib/libc/crypt/arc4random.h b/src/lib/libc/crypt/arc4random.h
new file mode 100644
index 0000000000..e0309a3184
--- /dev/null
+++ b/src/lib/libc/crypt/arc4random.h
@@ -0,0 +1,46 @@
1/* $OpenBSD: arc4random.h,v 1.1 2014/07/18 02:05:55 deraadt 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 *
8 * Permission to use, copy, modify, and distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above
10 * copyright notice and this permission notice appear in all copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 */
20
21/*
22 * Stub functions for portability.
23 */
24
25static inline void *
26_rs_allocate(size_t len)
27{
28 void *p;
29
30 if ((p = mmap(NULL, sizeof(*rs), PROT_READ|PROT_WRITE,
31 MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED)
32 return (NULL);
33 return (p);
34}
35
36static inline void
37_rs_forkdetect(void)
38{
39}
40
41static inline void
42_rs_forkdetectsetup(struct _rs *rs, size_t len)
43{
44 if (minherit(rs, len, MAP_INHERIT_ZERO) == -1)
45 abort();
46}