summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lib/libcrypto/arc4random/arc4random_linux.h66
-rw-r--r--src/lib/libcrypto/arc4random/arc4random_osx.h66
-rw-r--r--src/lib/libcrypto/arc4random/arc4random_solaris.h66
-rw-r--r--src/lib/libcrypto/arc4random/arc4random_win.h45
-rw-r--r--src/lib/libcrypto/crypto/arc4random_linux.h66
-rw-r--r--src/lib/libcrypto/crypto/arc4random_osx.h66
-rw-r--r--src/lib/libcrypto/crypto/arc4random_solaris.h66
-rw-r--r--src/lib/libcrypto/crypto/arc4random_win.h45
8 files changed, 486 insertions, 0 deletions
diff --git a/src/lib/libcrypto/arc4random/arc4random_linux.h b/src/lib/libcrypto/arc4random/arc4random_linux.h
new file mode 100644
index 0000000000..2319ccbf42
--- /dev/null
+++ b/src/lib/libcrypto/arc4random/arc4random_linux.h
@@ -0,0 +1,66 @@
1/* $OpenBSD: arc4random_linux.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_forkhandler(void)
38{
39 /*
40 * Race-free because we're running single-threaded in a new
41 * address space, and once allocated rs is never deallocated.
42 */
43 if (rs)
44 rs->rs_count = 0;
45}
46
47static inline void
48_rs_forkdetect(void)
49{
50 static pid_t _rs_pid = 0;
51 pid_t pid = getpid();
52
53 /* If a system lacks MAP_INHERIT_ZERO, resort to getpid() */
54 if (_rs_pid == 0 || _rs_pid != pid) {
55 _rs_pid = pid;
56 if (rs)
57 rs->rs_count = 0;
58 }
59}
60
61static inline void
62_rs_forkdetectsetup(struct _rs *rs, size_t len)
63{
64 _ARC4_ATFORK(_rs_forkhandler);
65}
66
diff --git a/src/lib/libcrypto/arc4random/arc4random_osx.h b/src/lib/libcrypto/arc4random/arc4random_osx.h
new file mode 100644
index 0000000000..88433e17dd
--- /dev/null
+++ b/src/lib/libcrypto/arc4random/arc4random_osx.h
@@ -0,0 +1,66 @@
1/* $OpenBSD: arc4random_osx.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_forkhandler(void)
38{
39 /*
40 * Race-free because we're running single-threaded in a new
41 * address space, and once allocated rs is never deallocated.
42 */
43 if (rs)
44 rs->rs_count = 0;
45}
46
47static inline void
48_rs_forkdetect(void)
49{
50 static pid_t _rs_pid = 0;
51 pid_t pid = getpid();
52
53 /* If a system lacks MAP_INHERIT_ZERO, resort to getpid() */
54 if (_rs_pid == 0 || _rs_pid != pid) {
55 _rs_pid = pid;
56 if (rs)
57 rs->rs_count = 0;
58 }
59}
60
61static inline void
62_rs_forkdetectsetup(struct _rs *rs, size_t len)
63{
64 _ARC4_ATFORK(_rs_forkhandler);
65}
66
diff --git a/src/lib/libcrypto/arc4random/arc4random_solaris.h b/src/lib/libcrypto/arc4random/arc4random_solaris.h
new file mode 100644
index 0000000000..ca8e107e40
--- /dev/null
+++ b/src/lib/libcrypto/arc4random/arc4random_solaris.h
@@ -0,0 +1,66 @@
1/* $OpenBSD: arc4random_solaris.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_forkhandler(void)
38{
39 /*
40 * Race-free because we're running single-threaded in a new
41 * address space, and once allocated rs is never deallocated.
42 */
43 if (rs)
44 rs->rs_count = 0;
45}
46
47static inline void
48_rs_forkdetect(void)
49{
50 static pid_t _rs_pid = 0;
51 pid_t pid = getpid();
52
53 /* If a system lacks MAP_INHERIT_ZERO, resort to getpid() */
54 if (_rs_pid == 0 || _rs_pid != pid) {
55 _rs_pid = pid;
56 if (rs)
57 rs->rs_count = 0;
58 }
59}
60
61static inline void
62_rs_forkdetectsetup(struct _rs *rs, size_t len)
63{
64 _ARC4_ATFORK(_rs_forkhandler);
65}
66
diff --git a/src/lib/libcrypto/arc4random/arc4random_win.h b/src/lib/libcrypto/arc4random/arc4random_win.h
new file mode 100644
index 0000000000..7d01d42be5
--- /dev/null
+++ b/src/lib/libcrypto/arc4random/arc4random_win.h
@@ -0,0 +1,45 @@
1/* $OpenBSD: arc4random_win.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 return calloc(1, sizeof(*rs));
29}
30
31static inline void
32_rs_forkhandler(void)
33{
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}
45
diff --git a/src/lib/libcrypto/crypto/arc4random_linux.h b/src/lib/libcrypto/crypto/arc4random_linux.h
new file mode 100644
index 0000000000..2319ccbf42
--- /dev/null
+++ b/src/lib/libcrypto/crypto/arc4random_linux.h
@@ -0,0 +1,66 @@
1/* $OpenBSD: arc4random_linux.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_forkhandler(void)
38{
39 /*
40 * Race-free because we're running single-threaded in a new
41 * address space, and once allocated rs is never deallocated.
42 */
43 if (rs)
44 rs->rs_count = 0;
45}
46
47static inline void
48_rs_forkdetect(void)
49{
50 static pid_t _rs_pid = 0;
51 pid_t pid = getpid();
52
53 /* If a system lacks MAP_INHERIT_ZERO, resort to getpid() */
54 if (_rs_pid == 0 || _rs_pid != pid) {
55 _rs_pid = pid;
56 if (rs)
57 rs->rs_count = 0;
58 }
59}
60
61static inline void
62_rs_forkdetectsetup(struct _rs *rs, size_t len)
63{
64 _ARC4_ATFORK(_rs_forkhandler);
65}
66
diff --git a/src/lib/libcrypto/crypto/arc4random_osx.h b/src/lib/libcrypto/crypto/arc4random_osx.h
new file mode 100644
index 0000000000..88433e17dd
--- /dev/null
+++ b/src/lib/libcrypto/crypto/arc4random_osx.h
@@ -0,0 +1,66 @@
1/* $OpenBSD: arc4random_osx.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_forkhandler(void)
38{
39 /*
40 * Race-free because we're running single-threaded in a new
41 * address space, and once allocated rs is never deallocated.
42 */
43 if (rs)
44 rs->rs_count = 0;
45}
46
47static inline void
48_rs_forkdetect(void)
49{
50 static pid_t _rs_pid = 0;
51 pid_t pid = getpid();
52
53 /* If a system lacks MAP_INHERIT_ZERO, resort to getpid() */
54 if (_rs_pid == 0 || _rs_pid != pid) {
55 _rs_pid = pid;
56 if (rs)
57 rs->rs_count = 0;
58 }
59}
60
61static inline void
62_rs_forkdetectsetup(struct _rs *rs, size_t len)
63{
64 _ARC4_ATFORK(_rs_forkhandler);
65}
66
diff --git a/src/lib/libcrypto/crypto/arc4random_solaris.h b/src/lib/libcrypto/crypto/arc4random_solaris.h
new file mode 100644
index 0000000000..ca8e107e40
--- /dev/null
+++ b/src/lib/libcrypto/crypto/arc4random_solaris.h
@@ -0,0 +1,66 @@
1/* $OpenBSD: arc4random_solaris.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_forkhandler(void)
38{
39 /*
40 * Race-free because we're running single-threaded in a new
41 * address space, and once allocated rs is never deallocated.
42 */
43 if (rs)
44 rs->rs_count = 0;
45}
46
47static inline void
48_rs_forkdetect(void)
49{
50 static pid_t _rs_pid = 0;
51 pid_t pid = getpid();
52
53 /* If a system lacks MAP_INHERIT_ZERO, resort to getpid() */
54 if (_rs_pid == 0 || _rs_pid != pid) {
55 _rs_pid = pid;
56 if (rs)
57 rs->rs_count = 0;
58 }
59}
60
61static inline void
62_rs_forkdetectsetup(struct _rs *rs, size_t len)
63{
64 _ARC4_ATFORK(_rs_forkhandler);
65}
66
diff --git a/src/lib/libcrypto/crypto/arc4random_win.h b/src/lib/libcrypto/crypto/arc4random_win.h
new file mode 100644
index 0000000000..7d01d42be5
--- /dev/null
+++ b/src/lib/libcrypto/crypto/arc4random_win.h
@@ -0,0 +1,45 @@
1/* $OpenBSD: arc4random_win.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 return calloc(1, sizeof(*rs));
29}
30
31static inline void
32_rs_forkhandler(void)
33{
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}
45