0497c4c28a
kernel 5.6 added support for a new flag for getrandom(): GRND_INSECURE. If we set it we can get some random data out of the kernel random pool, even if it is not yet initializated. This is great for us to initialize hash table seeds and such, where it is OK if they are crap initially. We used RDRAND for these cases so far, but RDRAND is only available on newer CPUs and some archs. Let's now use GRND_INSECURE for these cases as well, which means we won't needlessly delay boot anymore even on archs/CPUs that do not have RDRAND. Of course we never set this flag when generating crypto keys or uuids. Which makes it different from RDRAND for us (and is the reason I think we should keep explicit RDRAND support in): RDRAND we don't trust enough for crypto keys. But we do trust it enough for UUIDs.
21 lines
316 B
C
21 lines
316 B
C
/* SPDX-License-Identifier: LGPL-2.1+ */
|
|
#pragma once
|
|
|
|
#if USE_SYS_RANDOM_H
|
|
# include <sys/random.h>
|
|
#else
|
|
# include <linux/random.h>
|
|
#endif
|
|
|
|
#ifndef GRND_NONBLOCK
|
|
#define GRND_NONBLOCK 0x0001
|
|
#endif
|
|
|
|
#ifndef GRND_RANDOM
|
|
#define GRND_RANDOM 0x0002
|
|
#endif
|
|
|
|
#ifndef GRND_INSECURE
|
|
#define GRND_INSECURE 0x0004
|
|
#endif
|