summaryrefslogtreecommitdiff
path: root/src/basic/random-util.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-11-07 19:31:39 +0100
committerLennart Poettering <lennart@poettering.net>2018-11-08 09:44:27 +0100
commit6fb6f13896b13e8a5afee30ebec110dd1c8f1b29 (patch)
tree0147b83664179fb1a25babd6d42d2f7a5bebb703 /src/basic/random-util.h
parent776cf7461fa54445a40df17c40cfd024b6f09578 (diff)
downloadsystemd-6fb6f13896b13e8a5afee30ebec110dd1c8f1b29.tar.gz
random-util: introduce RANDOM_DONT_DRAIN
Originally, the high_quality_required boolean argument controlled two things: whether to extend any random data we successfully read with pseudo-random data, and whether to return -ENODATA if we couldn't read any data at all. The boolean got replaced by RANDOM_EXTEND_WITH_PSEUDO, but this name doesn't really cover the second part nicely. Moreover hiding both changes of behaviour under a single flag is confusing. Hence, let's split this part off under a new flag, and use it from random_bytes().
Diffstat (limited to 'src/basic/random-util.h')
-rw-r--r--src/basic/random-util.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/basic/random-util.h b/src/basic/random-util.h
index 0813314a05..487f20e0ab 100644
--- a/src/basic/random-util.h
+++ b/src/basic/random-util.h
@@ -8,6 +8,7 @@
typedef enum RandomFlags {
RANDOM_EXTEND_WITH_PSEUDO = 1 << 0, /* If we can't get enough genuine randomness, but some, fill up the rest with pseudo-randomness */
RANDOM_BLOCK = 1 << 1, /* Rather block than return crap randomness (only if the kernel supports that) */
+ RANDOM_DONT_DRAIN = 1 << 2, /* If we can't get any randomness at all, return early with -EAGAIN */
} RandomFlags;
int genuine_random_bytes(void *p, size_t n, RandomFlags flags); /* returns "genuine" randomness, optionally filled upwith pseudo random, if not enough is available */