xref: /linux/include/uapi/linux/random.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
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 
23607ca46eSDavid Howells /* Get the contents of the entropy pool.  (Superuser only.) */
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;
44*94dfc73eSGustavo 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 
58607ca46eSDavid Howells #endif /* _UAPI_LINUX_RANDOM_H */
59