xref: /OK3568_Linux_fs/kernel/include/uapi/linux/random.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * include/linux/random.h
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * Include file for the random number generator.
6*4882a593Smuzhiyun  */
7*4882a593Smuzhiyun 
8*4882a593Smuzhiyun #ifndef _UAPI_LINUX_RANDOM_H
9*4882a593Smuzhiyun #define _UAPI_LINUX_RANDOM_H
10*4882a593Smuzhiyun 
11*4882a593Smuzhiyun #include <linux/types.h>
12*4882a593Smuzhiyun #include <linux/ioctl.h>
13*4882a593Smuzhiyun #include <linux/irqnr.h>
14*4882a593Smuzhiyun 
15*4882a593Smuzhiyun /* ioctl()'s for the random number generator */
16*4882a593Smuzhiyun 
17*4882a593Smuzhiyun /* Get the entropy count. */
18*4882a593Smuzhiyun #define RNDGETENTCNT	_IOR( 'R', 0x00, int )
19*4882a593Smuzhiyun 
20*4882a593Smuzhiyun /* Add to (or subtract from) the entropy count.  (Superuser only.) */
21*4882a593Smuzhiyun #define RNDADDTOENTCNT	_IOW( 'R', 0x01, int )
22*4882a593Smuzhiyun 
23*4882a593Smuzhiyun /* Get the contents of the entropy pool.  (Superuser only.) */
24*4882a593Smuzhiyun #define RNDGETPOOL	_IOR( 'R', 0x02, int [2] )
25*4882a593Smuzhiyun 
26*4882a593Smuzhiyun /*
27*4882a593Smuzhiyun  * Write bytes into the entropy pool and add to the entropy count.
28*4882a593Smuzhiyun  * (Superuser only.)
29*4882a593Smuzhiyun  */
30*4882a593Smuzhiyun #define RNDADDENTROPY	_IOW( 'R', 0x03, int [2] )
31*4882a593Smuzhiyun 
32*4882a593Smuzhiyun /* Clear entropy count to 0.  (Superuser only.) */
33*4882a593Smuzhiyun #define RNDZAPENTCNT	_IO( 'R', 0x04 )
34*4882a593Smuzhiyun 
35*4882a593Smuzhiyun /* Clear the entropy pool and associated counters.  (Superuser only.) */
36*4882a593Smuzhiyun #define RNDCLEARPOOL	_IO( 'R', 0x06 )
37*4882a593Smuzhiyun 
38*4882a593Smuzhiyun /* Reseed CRNG.  (Superuser only.) */
39*4882a593Smuzhiyun #define RNDRESEEDCRNG	_IO( 'R', 0x07 )
40*4882a593Smuzhiyun 
41*4882a593Smuzhiyun struct rand_pool_info {
42*4882a593Smuzhiyun 	int	entropy_count;
43*4882a593Smuzhiyun 	int	buf_size;
44*4882a593Smuzhiyun 	__u32	buf[0];
45*4882a593Smuzhiyun };
46*4882a593Smuzhiyun 
47*4882a593Smuzhiyun /*
48*4882a593Smuzhiyun  * Flags for getrandom(2)
49*4882a593Smuzhiyun  *
50*4882a593Smuzhiyun  * GRND_NONBLOCK	Don't block and return EAGAIN instead
51*4882a593Smuzhiyun  * GRND_RANDOM		No effect
52*4882a593Smuzhiyun  * GRND_INSECURE	Return non-cryptographic random bytes
53*4882a593Smuzhiyun  */
54*4882a593Smuzhiyun #define GRND_NONBLOCK	0x0001
55*4882a593Smuzhiyun #define GRND_RANDOM	0x0002
56*4882a593Smuzhiyun #define GRND_INSECURE	0x0004
57*4882a593Smuzhiyun 
58*4882a593Smuzhiyun #endif /* _UAPI_LINUX_RANDOM_H */
59