diff options
author | Nicholas Tay <nick@windblume.net> | 2021-12-02 18:10:16 +1100 |
---|---|---|
committer | Nicholas Tay <nick@windblume.net> | 2021-12-02 18:10:16 +1100 |
commit | 6570d30f963be94189cf8ed0bf0b751f28bd0051 (patch) | |
tree | 08058771195d6868a5b88060659a6afb3d60ede6 | |
parent | f3e1a6389ca1df7caf66072d676b9e53843deb3b (diff) | |
download | passgen-6570d30f963be94189cf8ed0bf0b751f28bd0051.tar.gz passgen-6570d30f963be94189cf8ed0bf0b751f28bd0051.tar.bz2 passgen-6570d30f963be94189cf8ed0bf0b751f28bd0051.zip |
Less syscalls the better? Call getrandom() every generation
Seems to hang every few executions if we getrandom one big chunk.
Probably not enough entropy?
-rw-r--r-- | passgen.c | 9 |
1 files changed, 3 insertions, 6 deletions
@@ -56,11 +56,7 @@ int main(int argc, char *argv[]) char password[grammar_size+1];
password[grammar_size] = 0;
-#ifdef __linux__
- // Reduce syscalls by generating a bunch and then doing it
- unsigned int entropy[grammar_size];
- getrandom(&entropy, sizeof(entropy), 0);
-#else
+#ifndef __linux__
// seed RNG; this isn't very good, but it's enough(?)
srand(time(NULL) + getpid() % 420 - 69);
#endif
@@ -87,7 +83,8 @@ int main(int argc, char *argv[]) do {
#ifdef __linux__
- unsigned int r = entropy[i];
+ unsigned int r;
+ getrandom(&r, sizeof(r), 0);
#else
long r = rand();
#endif
|