diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2016-10-14 14:16:51 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2016-11-04 02:54:06 +0100 |
commit | e4c739fe0b9e568333bf43358fbc3db6b96fe1a1 (patch) | |
tree | 5846882d8a2ac908e9587a484274e1c4154e3811 /lib/random.h | |
parent | fea6c3ca8f869752f4f79f724fbb8736e961fd88 (diff) | |
download | gnutls-e4c739fe0b9e568333bf43358fbc3db6b96fe1a1.tar.gz |
rng: split initialization in preinit and init
This makes gnutls to initialize its random generator on the
first call to gnutls_rnd(). That prevents blocking due to
getrandom() on a constructor; that change allows to use gnutls-linked
applications even in early boot in systems where getrandom() blocks
waiting for entropy.
Diffstat (limited to 'lib/random.h')
-rw-r--r-- | lib/random.h | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/lib/random.h b/lib/random.h index 1538ec8da6..2ef7bc4684 100644 --- a/lib/random.h +++ b/lib/random.h @@ -31,31 +31,15 @@ extern int crypto_rnd_prio; extern void *gnutls_rnd_ctx; extern gnutls_crypto_rnd_st _gnutls_rnd_ops; -inline static int -_gnutls_rnd(gnutls_rnd_level_t level, void *data, size_t len) -{ - if (len > 0) { - return _gnutls_rnd_ops.rnd(gnutls_rnd_ctx, level, data, - len); - } - return 0; -} - -inline static void _gnutls_rnd_refresh(void) -{ - _gnutls_rnd_ops.rnd_refresh(gnutls_rnd_ctx); -} +#define _gnutls_rnd gnutls_rnd +#define _gnutls_rnd_refresh gnutls_rnd_refresh void _gnutls_rnd_deinit(void); -int _gnutls_rnd_init(void); +int _gnutls_rnd_preinit(void); inline static int _gnutls_rnd_check(void) { return _rnd_system_entropy_check(); } -#ifndef _WIN32 -extern int _gnutls_urandom_fd; -#endif - #endif |