Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * include/linux/random.h |
| 3 | * |
| 4 | * Include file for the random number generator. |
| 5 | */ |
| 6 | |
| 7 | #ifndef _LINUX_RANDOM_H |
| 8 | #define _LINUX_RANDOM_H |
| 9 | |
Jaswinder Singh Rajput | 68622c6 | 2009-01-30 22:11:32 +0530 | [diff] [blame] | 10 | #include <linux/types.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | #include <linux/ioctl.h> |
Ingo Molnar | 0ebb26e | 2008-12-12 11:26:39 +0100 | [diff] [blame] | 12 | #include <linux/irqnr.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | |
| 14 | /* ioctl()'s for the random number generator */ |
| 15 | |
| 16 | /* Get the entropy count. */ |
| 17 | #define RNDGETENTCNT _IOR( 'R', 0x00, int ) |
| 18 | |
| 19 | /* Add to (or subtract from) the entropy count. (Superuser only.) */ |
| 20 | #define RNDADDTOENTCNT _IOW( 'R', 0x01, int ) |
| 21 | |
| 22 | /* Get the contents of the entropy pool. (Superuser only.) */ |
| 23 | #define RNDGETPOOL _IOR( 'R', 0x02, int [2] ) |
| 24 | |
| 25 | /* |
| 26 | * Write bytes into the entropy pool and add to the entropy count. |
| 27 | * (Superuser only.) |
| 28 | */ |
| 29 | #define RNDADDENTROPY _IOW( 'R', 0x03, int [2] ) |
| 30 | |
| 31 | /* Clear entropy count to 0. (Superuser only.) */ |
| 32 | #define RNDZAPENTCNT _IO( 'R', 0x04 ) |
| 33 | |
| 34 | /* Clear the entropy pool and associated counters. (Superuser only.) */ |
| 35 | #define RNDCLEARPOOL _IO( 'R', 0x06 ) |
| 36 | |
| 37 | struct rand_pool_info { |
| 38 | int entropy_count; |
| 39 | int buf_size; |
| 40 | __u32 buf[0]; |
| 41 | }; |
| 42 | |
| 43 | /* Exported functions */ |
| 44 | |
| 45 | #ifdef __KERNEL__ |
| 46 | |
| 47 | extern void rand_initialize_irq(int irq); |
| 48 | |
| 49 | extern void add_input_randomness(unsigned int type, unsigned int code, |
| 50 | unsigned int value); |
| 51 | extern void add_interrupt_randomness(int irq); |
| 52 | |
| 53 | extern void get_random_bytes(void *buf, int nbytes); |
| 54 | void generate_random_uuid(unsigned char uuid_out[16]); |
| 55 | |
Al Viro | b09b845c | 2006-11-14 20:52:19 -0800 | [diff] [blame] | 56 | extern __u32 secure_ip_id(__be32 daddr); |
| 57 | extern u32 secure_ipv4_port_ephemeral(__be32 saddr, __be32 daddr, __be16 dport); |
| 58 | extern u32 secure_ipv6_port_ephemeral(const __be32 *saddr, const __be32 *daddr, |
| 59 | __be16 dport); |
| 60 | extern __u32 secure_tcp_sequence_number(__be32 saddr, __be32 daddr, |
| 61 | __be16 sport, __be16 dport); |
| 62 | extern __u32 secure_tcpv6_sequence_number(__be32 *saddr, __be32 *daddr, |
| 63 | __be16 sport, __be16 dport); |
| 64 | extern u64 secure_dccp_sequence_number(__be32 saddr, __be32 daddr, |
| 65 | __be16 sport, __be16 dport); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | |
| 67 | #ifndef MODULE |
Arjan van de Ven | 5404732 | 2007-02-12 00:55:28 -0800 | [diff] [blame] | 68 | extern const struct file_operations random_fops, urandom_fops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | #endif |
| 70 | |
| 71 | unsigned int get_random_int(void); |
| 72 | unsigned long randomize_range(unsigned long start, unsigned long end, unsigned long len); |
| 73 | |
Stephen Hemminger | aaa248f | 2006-10-17 00:09:42 -0700 | [diff] [blame] | 74 | u32 random32(void); |
| 75 | void srandom32(u32 seed); |
| 76 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | #endif /* __KERNEL___ */ |
| 78 | |
| 79 | #endif /* _LINUX_RANDOM_H */ |