16f52b16cSGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2607ca46eSDavid Howells /* 3607ca46eSDavid Howells * include/linux/random.h 4607ca46eSDavid Howells * 5607ca46eSDavid Howells * Include file for the random number generator. 6607ca46eSDavid Howells */ 7607ca46eSDavid Howells 8607ca46eSDavid Howells #ifndef _UAPI_LINUX_RANDOM_H 9607ca46eSDavid Howells #define _UAPI_LINUX_RANDOM_H 10607ca46eSDavid Howells 11607ca46eSDavid Howells #include <linux/types.h> 12607ca46eSDavid Howells #include <linux/ioctl.h> 13607ca46eSDavid Howells #include <linux/irqnr.h> 14607ca46eSDavid Howells 15607ca46eSDavid Howells /* ioctl()'s for the random number generator */ 16607ca46eSDavid Howells 17607ca46eSDavid Howells /* Get the entropy count. */ 18607ca46eSDavid Howells #define RNDGETENTCNT _IOR( 'R', 0x00, int ) 19607ca46eSDavid Howells 20607ca46eSDavid Howells /* Add to (or subtract from) the entropy count. (Superuser only.) */ 21607ca46eSDavid Howells #define RNDADDTOENTCNT _IOW( 'R', 0x01, int ) 22607ca46eSDavid Howells 23*13f75d9eSJason A. Donenfeld /* Get the contents of the entropy pool. (Superuser only.) (Removed in 2.6.9-rc2.) */ 24607ca46eSDavid Howells #define RNDGETPOOL _IOR( 'R', 0x02, int [2] ) 25607ca46eSDavid Howells 26607ca46eSDavid Howells /* 27607ca46eSDavid Howells * Write bytes into the entropy pool and add to the entropy count. 28607ca46eSDavid Howells * (Superuser only.) 29607ca46eSDavid Howells */ 30607ca46eSDavid Howells #define RNDADDENTROPY _IOW( 'R', 0x03, int [2] ) 31607ca46eSDavid Howells 32607ca46eSDavid Howells /* Clear entropy count to 0. (Superuser only.) */ 33607ca46eSDavid Howells #define RNDZAPENTCNT _IO( 'R', 0x04 ) 34607ca46eSDavid Howells 35607ca46eSDavid Howells /* Clear the entropy pool and associated counters. (Superuser only.) */ 36607ca46eSDavid Howells #define RNDCLEARPOOL _IO( 'R', 0x06 ) 37607ca46eSDavid Howells 38d848e5f8STheodore Ts'o /* Reseed CRNG. (Superuser only.) */ 39d848e5f8STheodore Ts'o #define RNDRESEEDCRNG _IO( 'R', 0x07 ) 40d848e5f8STheodore Ts'o 41607ca46eSDavid Howells struct rand_pool_info { 42607ca46eSDavid Howells int entropy_count; 43607ca46eSDavid Howells int buf_size; 4494dfc73eSGustavo A. R. Silva __u32 buf[]; 45607ca46eSDavid Howells }; 46607ca46eSDavid Howells 47c6e9d6f3STheodore Ts'o /* 48c6e9d6f3STheodore Ts'o * Flags for getrandom(2) 49c6e9d6f3STheodore Ts'o * 50c6e9d6f3STheodore Ts'o * GRND_NONBLOCK Don't block and return EAGAIN instead 5148446f19SAndy Lutomirski * GRND_RANDOM No effect 5275551dbfSAndy Lutomirski * GRND_INSECURE Return non-cryptographic random bytes 53c6e9d6f3STheodore Ts'o */ 54c6e9d6f3STheodore Ts'o #define GRND_NONBLOCK 0x0001 55c6e9d6f3STheodore Ts'o #define GRND_RANDOM 0x0002 5675551dbfSAndy Lutomirski #define GRND_INSECURE 0x0004 57c6e9d6f3STheodore Ts'o 584ad10a5fSJason A. Donenfeld /** 594ad10a5fSJason A. Donenfeld * struct vgetrandom_opaque_params - arguments for allocating memory for vgetrandom 604ad10a5fSJason A. Donenfeld * 614ad10a5fSJason A. Donenfeld * @size_per_opaque_state: Size of each state that is to be passed to vgetrandom(). 624ad10a5fSJason A. Donenfeld * @mmap_prot: Value of the prot argument in mmap(2). 634ad10a5fSJason A. Donenfeld * @mmap_flags: Value of the flags argument in mmap(2). 644ad10a5fSJason A. Donenfeld * @reserved: Reserved for future use. 654ad10a5fSJason A. Donenfeld */ 664ad10a5fSJason A. Donenfeld struct vgetrandom_opaque_params { 674ad10a5fSJason A. Donenfeld __u32 size_of_opaque_state; 684ad10a5fSJason A. Donenfeld __u32 mmap_prot; 694ad10a5fSJason A. Donenfeld __u32 mmap_flags; 704ad10a5fSJason A. Donenfeld __u32 reserved[13]; 714ad10a5fSJason A. Donenfeld }; 724ad10a5fSJason A. Donenfeld 73607ca46eSDavid Howells #endif /* _UAPI_LINUX_RANDOM_H */ 74