void noise_get_heavy(void (*func) (void *, int)) { char buf[512]; if (read_dev_urandom(buf, 32)) func(buf, 32); #if defined(UNIX) FILE *fp; int ret; fp = popen("ps -axu 2>/dev/null", "r"); while ( (ret = fread(buf, 1, sizeof(buf), fp)) > 0) func(buf, ret); pclose(fp); fp = popen("ls -al /tmp 2>/dev/null", "r"); while ( (ret = fread(buf, 1, sizeof(buf), fp)) > 0) func(buf, ret); pclose(fp); #endif }
void noise_get_heavy(void (*func) (void *, int)) { char buf[512]; FILE *fp; int ret; bool got_dev_urandom = false; if (read_dev_urandom(buf, 32)) { got_dev_urandom = true; func(buf, 32); } fp = popen("ps -axu 2>/dev/null", "r"); if (fp) { while ( (ret = fread(buf, 1, sizeof(buf), fp)) > 0) func(buf, ret); pclose(fp); } else if (!got_dev_urandom) { fprintf(stderr, "popen: %s\n" "Unable to access fallback entropy source\n", strerror(errno)); exit(1); } fp = popen("ls -al /tmp 2>/dev/null", "r"); if (fp) { while ( (ret = fread(buf, 1, sizeof(buf), fp)) > 0) func(buf, ret); pclose(fp); } else if (!got_dev_urandom) { fprintf(stderr, "popen: %s\n" "Unable to access fallback entropy source\n", strerror(errno)); exit(1); } read_random_seed(func); }