git.iko.soy/typeable/entropy
on main help sign in
Merge pull request #66 from TomMD/feature/do-not-get-entropy
2ea9ac8Thomas M. DuBuisson
cbits/random_initialized.c+4
@@ -6,12 +6,14 @@
6#include <unistd.h>
6#include <unistd.h>
7
7
8#ifdef HAVE_GETENTROPY
8#ifdef HAVE_GETENTROPY
9+#ifndef !DO_NOT_USE_GET_ENTROPY
9static int ensure_pool_initialized_getentropy()
10static int ensure_pool_initialized_getentropy()
10{
11{
11 char tmp;
12 char tmp;
12 return getentropy(&tmp, sizeof(tmp));
13 return getentropy(&tmp, sizeof(tmp));
13}
14}
14#endif
15#endif
16+#endif
15
17
16// Poll /dev/random to wait for randomness. This is a proxy for the /dev/urandom
18// Poll /dev/random to wait for randomness. This is a proxy for the /dev/urandom
17// pool being initialized.
19// pool being initialized.
@@ -46,8 +48,10 @@ static int ensure_pool_initialized_poll()
46int ensure_pool_initialized()
48int ensure_pool_initialized()
47{
49{
48#ifdef HAVE_GETENTROPY
50#ifdef HAVE_GETENTROPY
51+#ifndef !DO_NOT_USE_GET_ENTROPY
49 if (ensure_pool_initialized_getentropy() == 0)
52 if (ensure_pool_initialized_getentropy() == 0)
50 return 0;
53 return 0;
54+#endif
51#endif
55#endif
52
56
53 return ensure_pool_initialized_poll();
57 return ensure_pool_initialized_poll();
entropy.cabal+10−1
@@ -1,6 +1,6 @@
1name: entropy
1name: entropy
2
2
3−version: 0.4.1.7
3+version: 0.4.1.8
4description: A mostly platform independent method to obtain cryptographically strong entropy
4description: A mostly platform independent method to obtain cryptographically strong entropy
5 (RDRAND, urandom, CryptAPI, and patches welcome)
5 (RDRAND, urandom, CryptAPI, and patches welcome)
6 Users looking for cryptographically strong (number-theoretically
6 Users looking for cryptographically strong (number-theoretically
@@ -24,6 +24,12 @@ tested-with: GHC == 8.2.2
24-- data-files:
24-- data-files:
25extra-source-files: ./cbits/getrandom.c ./cbits/random_initialized.c ./cbits/rdrand.c, ./cbits/rdrand.h, README.md
25extra-source-files: ./cbits/getrandom.c ./cbits/random_initialized.c ./cbits/rdrand.c, ./cbits/rdrand.h, README.md
26
26
27+Flag DoNotGetEntropy
28+ Description: Avoid use of the getentropy() *nix function. By default getentropy will be used
29+ if detected during compilation (this plays poorly with cross compilation).
30+ Default: False
31+ Manual: True
32+
27custom-setup
33custom-setup
28 setup-depends: Cabal >= 1.10 && < 3.7
34 setup-depends: Cabal >= 1.10 && < 3.7
29 , base < 5
35 , base < 5
@@ -72,6 +78,9 @@ library
72 Build-Depends: unix
78 Build-Depends: unix
73 c-sources: cbits/getrandom.c cbits/random_initialized.c
79 c-sources: cbits/getrandom.c cbits/random_initialized.c
74 }
80 }
81+ if flag(DoNotGetEntropy) {
82+ cc-options: -DDO_NOT_USE_GET_ENTROPY
83+ }
75
84
76
85
77source-repository head
86source-repository head