random.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * include/linux/random.h
  3. *
  4. * Include file for the random number generator.
  5. */
  6. #ifndef _LINUX_RANDOM_H
  7. #define _LINUX_RANDOM_H
  8. #include <linux/ioctl.h>
  9. /* ioctl()'s for the random number generator */
  10. /* Get the entropy count. */
  11. #define RNDGETENTCNT _IOR( 'R', 0x00, int )
  12. /* Add to (or subtract from) the entropy count. (Superuser only.) */
  13. #define RNDADDTOENTCNT _IOW( 'R', 0x01, int )
  14. /* Get the contents of the entropy pool. (Superuser only.) */
  15. #define RNDGETPOOL _IOR( 'R', 0x02, int [2] )
  16. /*
  17. * Write bytes into the entropy pool and add to the entropy count.
  18. * (Superuser only.)
  19. */
  20. #define RNDADDENTROPY _IOW( 'R', 0x03, int [2] )
  21. /* Clear entropy count to 0. (Superuser only.) */
  22. #define RNDZAPENTCNT _IO( 'R', 0x04 )
  23. /* Clear the entropy pool and associated counters. (Superuser only.) */
  24. #define RNDCLEARPOOL _IO( 'R', 0x06 )
  25. struct rand_pool_info {
  26. int entropy_count;
  27. int buf_size;
  28. __u32 buf[0];
  29. };
  30. /* Exported functions */
  31. #ifdef __KERNEL__
  32. extern void rand_initialize_irq(int irq);
  33. extern void add_input_randomness(unsigned int type, unsigned int code,
  34. unsigned int value);
  35. extern void add_interrupt_randomness(int irq);
  36. extern void get_random_bytes(void *buf, int nbytes);
  37. void generate_random_uuid(unsigned char uuid_out[16]);
  38. extern __u32 secure_ip_id(__u32 daddr);
  39. extern u32 secure_tcp_port_ephemeral(__u32 saddr, __u32 daddr, __u16 dport);
  40. extern u32 secure_tcpv6_port_ephemeral(const __u32 *saddr, const __u32 *daddr,
  41. __u16 dport);
  42. extern __u32 secure_tcp_sequence_number(__u32 saddr, __u32 daddr,
  43. __u16 sport, __u16 dport);
  44. extern __u32 secure_tcpv6_sequence_number(__u32 *saddr, __u32 *daddr,
  45. __u16 sport, __u16 dport);
  46. #ifndef MODULE
  47. extern struct file_operations random_fops, urandom_fops;
  48. #endif
  49. unsigned int get_random_int(void);
  50. unsigned long randomize_range(unsigned long start, unsigned long end, unsigned long len);
  51. #endif /* __KERNEL___ */
  52. #endif /* _LINUX_RANDOM_H */