]> Git Repo - secp256k1.git/blobdiff - src/tests.c
Merge #516: improvements to random seed in src/tests.c
[secp256k1.git] / src / tests.c
index a7f841de1a35c03c449070d67c3569c8317fc6dc..7189ef594d313ca9448a0e9581ff2be009bede70 100644 (file)
@@ -4994,8 +4994,9 @@ int main(int argc, char **argv) {
         }
     } else {
         FILE *frand = fopen("/dev/urandom", "r");
-        if ((frand == NULL) || fread(&seed16, sizeof(seed16), 1, frand) != sizeof(seed16)) {
+        if ((frand == NULL) || fread(&seed16, 1, sizeof(seed16), frand) != sizeof(seed16)) {
             uint64_t t = time(NULL) * (uint64_t)1337;
+            fprintf(stderr, "WARNING: could not read 16 bytes from /dev/urandom; falling back to insecure PRNG\n");
             seed16[0] ^= t;
             seed16[1] ^= t >> 8;
             seed16[2] ^= t >> 16;
This page took 0.028527 seconds and 4 git commands to generate.