aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2019-02-17 21:53:57 +0100
committerGravatar Christian Hesse <mail@eworm.de>2019-02-17 21:53:57 +0100
commitc33a043cb6a9ff5431d050a095f7900d9303a6e1 (patch)
treed5abf27bd5f6a58920971ae4d44753b8f702337b /bin
parent46c8a3e214ee092b99a30fab8ed91b6f033287a9 (diff)
downloadmkinitcpio-ykfde-c33a043cb6a9ff5431d050a095f7900d9303a6e1.tar.gz
mkinitcpio-ykfde-c33a043cb6a9ff5431d050a095f7900d9303a6e1.tar.zst
Seed with real random number
Diffstat (limited to 'bin')
-rw-r--r--bin/ykfde.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/bin/ykfde.c b/bin/ykfde.c
index 34674cc..2dfd5d7 100644
--- a/bin/ykfde.c
+++ b/bin/ykfde.c
@@ -13,7 +13,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/time.h>
+#include <sys/random.h>
#include <sys/stat.h>
#include <termios.h>
#include <unistd.h>
@@ -112,7 +112,7 @@ int main(int argc, char **argv) {
char challengefilename[sizeof(CHALLENGEDIR) + 11 /* "/challenge-" */ + 10 /* unsigned int in char */ + 1],
challengefiletmpname[sizeof(CHALLENGEDIR) + 11 /* "/challenge-" */ + 10 /* unsigned int in char */ + 7 /* -XXXXXX */ + 1];
int challengefile = 0, challengefiletmp = 0;
- struct timeval tv;
+ unsigned int seed;
int i;
size_t len;
int8_t rc = EXIT_FAILURE;
@@ -196,10 +196,12 @@ int main(int argc, char **argv) {
if (version > 0 || help > 0)
return EXIT_SUCCESS;
-
/* initialize random seed */
- gettimeofday(&tv, NULL);
- srand(tv.tv_usec * tv.tv_sec);
+ if (getrandom(&seed, 4, GRND_RANDOM) != 4) {
+ fprintf(stderr, "Initializing random seed failed.\n");
+ goto out10;
+ }
+ srand(seed);
/* initialize static buffers */
memset(challenge_old, 0, CHALLENGELEN + 1);