random.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. /*
  3. * include/linux/random.h
  4. *
  5. * Include file for the random number generator.
  6. */
  7. #ifndef _UAPI_LINUX_RANDOM_H
  8. #define _UAPI_LINUX_RANDOM_H
  9. #include <linux/types.h>
  10. #include <linux/ioctl.h>
  11. #include <linux/irqnr.h>
  12. /* ioctl()'s for the random number generator */
  13. /* Get the entropy count. */
  14. #define RNDGETENTCNT _IOR( 'R', 0x00, int )
  15. /* Add to (or subtract from) the entropy count. (Superuser only.) */
  16. #define RNDADDTOENTCNT _IOW( 'R', 0x01, int )
  17. /* Get the contents of the entropy pool. (Superuser only.) */
  18. #define RNDGETPOOL _IOR( 'R', 0x02, int [2] )
  19. /*
  20. * Write bytes into the entropy pool and add to the entropy count.
  21. * (Superuser only.)
  22. */
  23. #define RNDADDENTROPY _IOW( 'R', 0x03, int [2] )
  24. /* Clear entropy count to 0. (Superuser only.) */
  25. #define RNDZAPENTCNT _IO( 'R', 0x04 )
  26. /* Clear the entropy pool and associated counters. (Superuser only.) */
  27. #define RNDCLEARPOOL _IO( 'R', 0x06 )
  28. /* Reseed CRNG. (Superuser only.) */
  29. #define RNDRESEEDCRNG _IO( 'R', 0x07 )
  30. struct rand_pool_info {
  31. int entropy_count;
  32. int buf_size;
  33. __u32 buf[0];
  34. };
  35. /*
  36. * Flags for getrandom(2)
  37. *
  38. * GRND_NONBLOCK Don't block and return EAGAIN instead
  39. * GRND_RANDOM Use the /dev/random pool instead of /dev/urandom
  40. */
  41. #define GRND_NONBLOCK 0x0001
  42. #define GRND_RANDOM 0x0002
  43. #endif /* _UAPI_LINUX_RANDOM_H */