Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
0002 /*
0003  * include/linux/random.h
0004  *
0005  * Include file for the random number generator.
0006  */
0007 
0008 #ifndef _UAPI_LINUX_RANDOM_H
0009 #define _UAPI_LINUX_RANDOM_H
0010 
0011 #include <linux/types.h>
0012 #include <linux/ioctl.h>
0013 #include <linux/irqnr.h>
0014 
0015 /* ioctl()'s for the random number generator */
0016 
0017 /* Get the entropy count. */
0018 #define RNDGETENTCNT    _IOR( 'R', 0x00, int )
0019 
0020 /* Add to (or subtract from) the entropy count.  (Superuser only.) */
0021 #define RNDADDTOENTCNT  _IOW( 'R', 0x01, int )
0022 
0023 /* Get the contents of the entropy pool.  (Superuser only.) */
0024 #define RNDGETPOOL  _IOR( 'R', 0x02, int [2] )
0025 
0026 /* 
0027  * Write bytes into the entropy pool and add to the entropy count.
0028  * (Superuser only.)
0029  */
0030 #define RNDADDENTROPY   _IOW( 'R', 0x03, int [2] )
0031 
0032 /* Clear entropy count to 0.  (Superuser only.) */
0033 #define RNDZAPENTCNT    _IO( 'R', 0x04 )
0034 
0035 /* Clear the entropy pool and associated counters.  (Superuser only.) */
0036 #define RNDCLEARPOOL    _IO( 'R', 0x06 )
0037 
0038 /* Reseed CRNG.  (Superuser only.) */
0039 #define RNDRESEEDCRNG   _IO( 'R', 0x07 )
0040 
0041 struct rand_pool_info {
0042     int entropy_count;
0043     int buf_size;
0044     __u32   buf[];
0045 };
0046 
0047 /*
0048  * Flags for getrandom(2)
0049  *
0050  * GRND_NONBLOCK    Don't block and return EAGAIN instead
0051  * GRND_RANDOM      No effect
0052  * GRND_INSECURE    Return non-cryptographic random bytes
0053  */
0054 #define GRND_NONBLOCK   0x0001
0055 #define GRND_RANDOM 0x0002
0056 #define GRND_INSECURE   0x0004
0057 
0058 #endif /* _UAPI_LINUX_RANDOM_H */