700-use_dev_urandom.patch 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. --- a/src/crypto/random.c
  2. +++ b/src/crypto/random.c
  3. @@ -202,16 +202,16 @@ int random_pool_ready(void)
  4. /*
  5. * Try to fetch some more data from the kernel high quality
  6. - * /dev/random. There may not be enough data available at this point,
  7. + * /dev/urandom. There may not be enough data available at this point,
  8. * so use non-blocking read to avoid blocking the application
  9. * completely.
  10. */
  11. - fd = open("/dev/random", O_RDONLY | O_NONBLOCK);
  12. + fd = open("/dev/urandom", O_RDONLY | O_NONBLOCK);
  13. if (fd < 0) {
  14. #ifndef CONFIG_NO_STDOUT_DEBUG
  15. int error = errno;
  16. - perror("open(/dev/random)");
  17. - wpa_printf(MSG_ERROR, "random: Cannot open /dev/random: %s",
  18. + perror("open(/dev/urandom)");
  19. + wpa_printf(MSG_ERROR, "random: Cannot open /dev/urandom: %s",
  20. strerror(error));
  21. #endif /* CONFIG_NO_STDOUT_DEBUG */
  22. return -1;
  23. @@ -220,12 +220,12 @@ int random_pool_ready(void)
  24. res = read(fd, dummy_key + dummy_key_avail,
  25. sizeof(dummy_key) - dummy_key_avail);
  26. if (res < 0) {
  27. - wpa_printf(MSG_ERROR, "random: Cannot read from /dev/random: "
  28. + wpa_printf(MSG_ERROR, "random: Cannot read from /dev/urandom: "
  29. "%s", strerror(errno));
  30. res = 0;
  31. }
  32. wpa_printf(MSG_DEBUG, "random: Got %u/%u bytes from "
  33. - "/dev/random", (unsigned) res,
  34. + "/dev/urandom", (unsigned) res,
  35. (unsigned) (sizeof(dummy_key) - dummy_key_avail));
  36. dummy_key_avail += res;
  37. close(fd);
  38. @@ -234,7 +234,7 @@ int random_pool_ready(void)
  39. return 1;
  40. wpa_printf(MSG_INFO, "random: Only %u/%u bytes of strong "
  41. - "random data available from /dev/random",
  42. + "random data available from /dev/urandom",
  43. (unsigned) dummy_key_avail, (unsigned) sizeof(dummy_key));
  44. if (own_pool_ready >= MIN_READY_MARK ||