Use gnutls' random functions to avoid depending on getentropy entirely (#1409291)
parent
ba23261be5
commit
cab355a61c
@ -0,0 +1,29 @@
|
||||
diff --git a/lib/sendserver.c b/lib/sendserver.c
|
||||
index ac5a35f..dce17f4 100644
|
||||
--- a/lib/sendserver.c
|
||||
+++ b/lib/sendserver.c
|
||||
@@ -20,6 +20,11 @@
|
||||
#include "rc-md5.h"
|
||||
#include "rc-hmac.h"
|
||||
|
||||
+#if defined(HAVE_GNUTLS)
|
||||
+# include <gnutls/gnutls.h>
|
||||
+# include <gnutls/crypto.h>
|
||||
+#endif
|
||||
+
|
||||
#define SCLOSE(fd) if (sfuncs->close_fd) sfuncs->close_fd(fd)
|
||||
|
||||
static void rc_random_vector(unsigned char *);
|
||||
@@ -338,7 +343,11 @@ static void rc_random_vector(unsigned char *vector)
|
||||
{
|
||||
int randno;
|
||||
int i;
|
||||
-#if defined(HAVE_GETENTROPY)
|
||||
+#if defined(HAVE_GNUTLS)
|
||||
+ if (gnutls_rnd(GNUTLS_RND_NONCE, vector, AUTH_VECTOR_LEN) >= 0) {
|
||||
+ return;
|
||||
+ }
|
||||
+#elif defined(HAVE_GETENTROPY)
|
||||
if (getentropy(vector, AUTH_VECTOR_LEN) >= 0) {
|
||||
return;
|
||||
} /* else fall through */
|
Loading…
Reference in new issue