random.h 2.1 KB

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