summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/crypto
diff options
context:
space:
mode:
authorderaadt <>2014-07-19 00:08:43 +0000
committerderaadt <>2014-07-19 00:08:43 +0000
commit63559a378edd18f00978f68eeb77fbd0f088a804 (patch)
treed1d1ea706aec9066edcbf60e8dd1c10257101a1d /src/lib/libcrypto/crypto
parentc08eb4d65e7656f34e0b7949bf7f3102cb5faaeb (diff)
downloadopenbsd-63559a378edd18f00978f68eeb77fbd0f088a804.tar.gz
openbsd-63559a378edd18f00978f68eeb77fbd0f088a804.tar.bz2
openbsd-63559a378edd18f00978f68eeb77fbd0f088a804.zip
Change _rs_allocate so it can combine the two regions (rs and rsx)
into one if a system has an awesome getentropy(). In that case it is valid to totally throw away the rsx state in the child. If the getentropy() is not very good and has a lazy reseed operation, this combining is a bad idea, and the reseed should probably continue to use the "something old, something new" mix. _rs_allocate() can accomodate either method, but not on the fly. ok matthew
Diffstat (limited to 'src/lib/libcrypto/crypto')
-rw-r--r--src/lib/libcrypto/crypto/arc4random_linux.h29
-rw-r--r--src/lib/libcrypto/crypto/arc4random_osx.h29
-rw-r--r--src/lib/libcrypto/crypto/arc4random_solaris.h29
-rw-r--r--src/lib/libcrypto/crypto/arc4random_win.h23
4 files changed, 55 insertions, 55 deletions
diff --git a/src/lib/libcrypto/crypto/arc4random_linux.h b/src/lib/libcrypto/crypto/arc4random_linux.h
index f02ae388d5..a713d15e06 100644
--- a/src/lib/libcrypto/crypto/arc4random_linux.h
+++ b/src/lib/libcrypto/crypto/arc4random_linux.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: arc4random_linux.h,v 1.2 2014/07/18 21:40:54 matthew Exp $ */ 1/* $OpenBSD: arc4random_linux.h,v 1.3 2014/07/19 00:08:43 deraadt Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1996, David Mazieres <dm@uun.org> 4 * Copyright (c) 1996, David Mazieres <dm@uun.org>
@@ -22,15 +22,21 @@
22 * Stub functions for portability. 22 * Stub functions for portability.
23 */ 23 */
24 24
25static inline void * 25static inline int
26_rs_allocate(size_t len) 26_rs_allocate(struct _rs **rsp, struct _rsx **rsxp)
27{ 27{
28 void *p; 28 if ((*rsp = mmap(NULL, sizeof(**rsp), PROT_READ|PROT_WRITE,
29
30 if ((p = mmap(NULL, len, PROT_READ|PROT_WRITE,
31 MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) 29 MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED)
32 return (NULL); 30 return (-1);
33 return (p); 31
32 if ((*rsxp = mmap(NULL, sizeof(**rsxp) PROT_READ|PROT_WRITE,
33 MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) {
34 munmap(*rsxp, sizeof(**rsxp);
35 return (-1);
36 }
37
38 _ARC4_ATFORK(_rs_forkhandler);
39 return (0);
34} 40}
35 41
36static volatile sig_atomic_t _rs_forked; 42static volatile sig_atomic_t _rs_forked;
@@ -54,10 +60,3 @@ _rs_forkdetect(void)
54 memset(rs, 0, sizeof(*rs)); 60 memset(rs, 0, sizeof(*rs));
55 } 61 }
56} 62}
57
58static inline void
59_rs_forkdetectsetup(struct _rs *rs, size_t len)
60{
61 _ARC4_ATFORK(_rs_forkhandler);
62}
63
diff --git a/src/lib/libcrypto/crypto/arc4random_osx.h b/src/lib/libcrypto/crypto/arc4random_osx.h
index 46053a45b9..ea4bd70fcd 100644
--- a/src/lib/libcrypto/crypto/arc4random_osx.h
+++ b/src/lib/libcrypto/crypto/arc4random_osx.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: arc4random_osx.h,v 1.2 2014/07/18 21:40:54 matthew Exp $ */ 1/* $OpenBSD: arc4random_osx.h,v 1.3 2014/07/19 00:08:43 deraadt Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1996, David Mazieres <dm@uun.org> 4 * Copyright (c) 1996, David Mazieres <dm@uun.org>
@@ -22,15 +22,21 @@
22 * Stub functions for portability. 22 * Stub functions for portability.
23 */ 23 */
24 24
25static inline void * 25static inline int
26_rs_allocate(size_t len) 26_rs_allocate(struct _rs **rsp, struct _rsx **rsxp)
27{ 27{
28 void *p; 28 if ((*rsp = mmap(NULL, sizeof(**rsp), PROT_READ|PROT_WRITE,
29
30 if ((p = mmap(NULL, len, PROT_READ|PROT_WRITE,
31 MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) 29 MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED)
32 return (NULL); 30 return (-1);
33 return (p); 31
32 if ((*rsxp = mmap(NULL, sizeof(**rsxp) PROT_READ|PROT_WRITE,
33 MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) {
34 munmap(*rsxp, sizeof(**rsxp);
35 return (-1);
36 }
37
38 _ARC4_ATFORK(_rs_forkhandler);
39 return (0);
34} 40}
35 41
36static volatile sig_atomic_t _rs_forked; 42static volatile sig_atomic_t _rs_forked;
@@ -54,10 +60,3 @@ _rs_forkdetect(void)
54 memset(rs, 0, sizeof(*rs)); 60 memset(rs, 0, sizeof(*rs));
55 } 61 }
56} 62}
57
58static inline void
59_rs_forkdetectsetup(struct _rs *rs, size_t len)
60{
61 _ARC4_ATFORK(_rs_forkhandler);
62}
63
diff --git a/src/lib/libcrypto/crypto/arc4random_solaris.h b/src/lib/libcrypto/crypto/arc4random_solaris.h
index 2386dbe885..ec9353f1b7 100644
--- a/src/lib/libcrypto/crypto/arc4random_solaris.h
+++ b/src/lib/libcrypto/crypto/arc4random_solaris.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: arc4random_solaris.h,v 1.2 2014/07/18 21:40:54 matthew Exp $ */ 1/* $OpenBSD: arc4random_solaris.h,v 1.3 2014/07/19 00:08:43 deraadt Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1996, David Mazieres <dm@uun.org> 4 * Copyright (c) 1996, David Mazieres <dm@uun.org>
@@ -22,15 +22,21 @@
22 * Stub functions for portability. 22 * Stub functions for portability.
23 */ 23 */
24 24
25static inline void * 25static inline int
26_rs_allocate(size_t len) 26_rs_allocate(struct _rs **rsp, struct _rsx **rsxp)
27{ 27{
28 void *p; 28 if ((*rsp = mmap(NULL, sizeof(**rsp), PROT_READ|PROT_WRITE,
29
30 if ((p = mmap(NULL, len, PROT_READ|PROT_WRITE,
31 MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) 29 MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED)
32 return (NULL); 30 return (-1);
33 return (p); 31
32 if ((*rsxp = mmap(NULL, sizeof(**rsxp) PROT_READ|PROT_WRITE,
33 MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) {
34 munmap(*rsxp, sizeof(**rsxp);
35 return (-1);
36 }
37
38 _ARC4_ATFORK(_rs_forkhandler);
39 return (0);
34} 40}
35 41
36static volatile sig_atomic_t _rs_forked; 42static volatile sig_atomic_t _rs_forked;
@@ -54,10 +60,3 @@ _rs_forkdetect(void)
54 memset(rs, 0, sizeof(*rs)); 60 memset(rs, 0, sizeof(*rs));
55 } 61 }
56} 62}
57
58static inline void
59_rs_forkdetectsetup(struct _rs *rs, size_t len)
60{
61 _ARC4_ATFORK(_rs_forkhandler);
62}
63
diff --git a/src/lib/libcrypto/crypto/arc4random_win.h b/src/lib/libcrypto/crypto/arc4random_win.h
index 7d01d42be5..1fc228d109 100644
--- a/src/lib/libcrypto/crypto/arc4random_win.h
+++ b/src/lib/libcrypto/crypto/arc4random_win.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: arc4random_win.h,v 1.1 2014/07/18 02:05:55 deraadt Exp $ */ 1/* $OpenBSD: arc4random_win.h,v 1.2 2014/07/19 00:08:43 deraadt Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1996, David Mazieres <dm@uun.org> 4 * Copyright (c) 1996, David Mazieres <dm@uun.org>
@@ -22,10 +22,19 @@
22 * Stub functions for portability. 22 * Stub functions for portability.
23 */ 23 */
24 24
25static inline void * 25static inline int
26_rs_allocate(size_t len) 26_rs_allocate(struct _rs **rsp, struct _rsx **rsxp)
27{ 27{
28 return calloc(1, sizeof(*rs)); 28 *rsp = calloc(1, sizeof(**rsp));
29 if (*rsp == NULL)
30 return (-1);
31
32 *rsxp = calloc(1, sizeof(**rsxp));
33 if (*rsxp == NULL) {
34 free(*rsp);
35 return (-1);
36 }
37 return (0);
29} 38}
30 39
31static inline void 40static inline void
@@ -37,9 +46,3 @@ static inline void
37_rs_forkdetect(void) 46_rs_forkdetect(void)
38{ 47{
39} 48}
40
41static inline void
42_rs_forkdetectsetup(struct _rs *rs, size_t len)
43{
44}
45