blob: b01d118750ab29785c01c53ecc560bfe7f93f3b8 [file] [log] [blame]
David Howells607ca462012-10-13 10:46:48 +01001/*
2 * include/linux/random.h
3 *
4 * Include file for the random number generator.
5 */
6
7#ifndef _UAPI_LINUX_RANDOM_H
8#define _UAPI_LINUX_RANDOM_H
9
10#include <linux/types.h>
11#include <linux/ioctl.h>
12#include <linux/irqnr.h>
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
Theodore Ts'o1d49e2a2018-04-11 16:32:17 -040037/* Reseed CRNG. (Superuser only.) */
38#define RNDRESEEDCRNG _IO( 'R', 0x07 )
39
David Howells607ca462012-10-13 10:46:48 +010040struct rand_pool_info {
41 int entropy_count;
42 int buf_size;
43 __u32 buf[0];
44};
45
Theodore Ts'oc6e9d6f2014-07-17 04:13:05 -040046/*
47 * Flags for getrandom(2)
48 *
49 * GRND_NONBLOCK Don't block and return EAGAIN instead
Andy Lutomirskie962a3a2019-12-23 00:20:47 -080050 * GRND_RANDOM No effect
Andy Lutomirski82c1e112019-12-23 00:20:46 -080051 * GRND_INSECURE Return non-cryptographic random bytes
Theodore Ts'oc6e9d6f2014-07-17 04:13:05 -040052 */
53#define GRND_NONBLOCK 0x0001
54#define GRND_RANDOM 0x0002
Andy Lutomirski82c1e112019-12-23 00:20:46 -080055#define GRND_INSECURE 0x0004
Theodore Ts'oc6e9d6f2014-07-17 04:13:05 -040056
David Howells607ca462012-10-13 10:46:48 +010057#endif /* _UAPI_LINUX_RANDOM_H */