random.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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(__be32 daddr);
  39. extern u32 secure_ipv4_port_ephemeral(__be32 saddr, __be32 daddr, __be16 dport);
  40. extern u32 secure_ipv6_port_ephemeral(const __be32 *saddr, const __be32 *daddr,
  41. __be16 dport);
  42. extern __u32 secure_tcp_sequence_number(__be32 saddr, __be32 daddr,
  43. __be16 sport, __be16 dport);
  44. extern __u32 secure_tcpv6_sequence_number(__be32 *saddr, __be32 *daddr,
  45. __be16 sport, __be16 dport);
  46. extern u64 secure_dccp_sequence_number(__be32 saddr, __be32 daddr,
  47. __be16 sport, __be16 dport);
  48. #ifndef MODULE
  49. extern const struct file_operations random_fops, urandom_fops;
  50. #endif
  51. unsigned int get_random_int(void);
  52. unsigned long randomize_range(unsigned long start, unsigned long end, unsigned long len);
  53. u32 random32(void);
  54. void srandom32(u32 seed);
  55. #endif /* __KERNEL___ */
  56. #endif /* _LINUX_RANDOM_H */