6cf9b8e
diff -up openssh-7.4p1/entropy.c.entropy openssh-7.4p1/entropy.c
6cf9b8e
--- openssh-7.4p1/entropy.c.entropy	2016-12-19 05:59:41.000000000 +0100
6cf9b8e
+++ openssh-7.4p1/entropy.c	2016-12-23 18:34:27.769753570 +0100
6cf9b8e
@@ -229,6 +229,9 @@ seed_rng(void)
Jan F. Chadima 69dd72f
 	memset(buf, '\0', sizeof(buf));
Jan F. Chadima 69dd72f
 
Jan F. Chadima 69dd72f
 #endif /* OPENSSL_PRNG_ONLY */
Jan F. Chadima 69dd72f
+#ifdef __linux__
Jan F. Chadima 69dd72f
+	linux_seed();
Jan F. Chadima 69dd72f
+#endif /* __linux__ */
Jan F. Chadima 69dd72f
 	if (RAND_status() != 1)
Jan F. Chadima 69dd72f
 		fatal("PRNG is not seeded");
Jan F. Chadima 69dd72f
 }
6cf9b8e
diff -up openssh-7.4p1/openbsd-compat/Makefile.in.entropy openssh-7.4p1/openbsd-compat/Makefile.in
6cf9b8e
--- openssh-7.4p1/openbsd-compat/Makefile.in.entropy	2016-12-23 18:34:53.715762155 +0100
6cf9b8e
+++ openssh-7.4p1/openbsd-compat/Makefile.in	2016-12-23 18:35:15.890769493 +0100
3cd4899
@@ -20,7 +20,8 @@ OPENBSD=base64.o basename.o bcrypt_pbkdf
3cd4899
 	port-solaris.o \
3cd4899
 	port-net.o \
3cd4899
 	port-uw.o \
3cd4899
-	port-linux-sshd.o
3cd4899
+	port-linux-sshd.o \
3cd4899
+	port-linux-prng.o
Jan F. Chadima 69dd72f
 
Jan F. Chadima 69dd72f
 .c.o:
Jan F. Chadima 69dd72f
 	$(CC) $(CFLAGS) $(CPPFLAGS) -c $<
6cf9b8e
diff -up openssh-7.4p1/openbsd-compat/port-linux.h.entropy openssh-7.4p1/openbsd-compat/port-linux.h
6cf9b8e
--- openssh-7.4p1/openbsd-compat/port-linux.h.entropy	2016-12-23 18:34:27.747753563 +0100
6cf9b8e
+++ openssh-7.4p1/openbsd-compat/port-linux.h	2016-12-23 18:34:27.769753570 +0100
6cf9b8e
@@ -34,4 +34,6 @@ void oom_adjust_restore(void);
6cf9b8e
 void oom_adjust_setup(void);
6cf9b8e
 #endif
6cf9b8e
 
6cf9b8e
+void linux_seed(void);
6cf9b8e
+
6cf9b8e
 #endif /* ! _PORT_LINUX_H */
6cf9b8e
diff -up openssh-7.4p1/openbsd-compat/port-linux-prng.c.entropy openssh-7.4p1/openbsd-compat/port-linux-prng.c
6cf9b8e
--- openssh-7.4p1/openbsd-compat/port-linux-prng.c.entropy	2016-12-23 18:34:27.769753570 +0100
6cf9b8e
+++ openssh-7.4p1/openbsd-compat/port-linux-prng.c	2016-12-23 18:34:27.769753570 +0100
Jan F. Chadima 69dd72f
@@ -0,0 +1,59 @@
Jan F. Chadima 69dd72f
+/* $Id: port-linux.c,v 1.11.4.2 2011/02/04 00:43:08 djm Exp $ */
Jan F. Chadima 69dd72f
+
Jan F. Chadima 69dd72f
+/*
Jan F. Chadima 69dd72f
+ * Copyright (c) 2011 Jan F. Chadima <jchadima@redhat.com>
Jan F. Chadima 69dd72f
+ *
Jan F. Chadima 69dd72f
+ * Permission to use, copy, modify, and distribute this software for any
Jan F. Chadima 69dd72f
+ * purpose with or without fee is hereby granted, provided that the above
Jan F. Chadima 69dd72f
+ * copyright notice and this permission notice appear in all copies.
Jan F. Chadima 69dd72f
+ *
Jan F. Chadima 69dd72f
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
Jan F. Chadima 69dd72f
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
Jan F. Chadima 69dd72f
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
Jan F. Chadima 69dd72f
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
Jan F. Chadima 69dd72f
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
Jan F. Chadima 69dd72f
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
Jan F. Chadima 69dd72f
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Jan F. Chadima 69dd72f
+ */
Jan F. Chadima 69dd72f
+
Jan F. Chadima 69dd72f
+/*
Jan F. Chadima 69dd72f
+ * Linux-specific portability code - prng support
Jan F. Chadima 69dd72f
+ */
Jan F. Chadima 69dd72f
+
Jan F. Chadima 69dd72f
+#include "includes.h"
Jan F. Chadima 69dd72f
+
Jan F. Chadima 69dd72f
+#include <errno.h>
Jan F. Chadima 69dd72f
+#include <stdarg.h>
Jan F. Chadima 69dd72f
+#include <string.h>
Jan F. Chadima 69dd72f
+#include <stdio.h>
Jan F. Chadima 69dd72f
+#include <openssl/rand.h>
Jan F. Chadima 69dd72f
+
Jan F. Chadima 69dd72f
+#include "log.h"
Jan F. Chadima 69dd72f
+#include "xmalloc.h"
1900351
+#include "misc.h"      /* servconf.h needs misc.h for struct ForwardOptions */
Jan F. Chadima 69dd72f
+#include "servconf.h"
Jan F. Chadima 69dd72f
+#include "port-linux.h"
Jan F. Chadima 69dd72f
+#include "key.h"
Jan F. Chadima 69dd72f
+#include "hostfile.h"
Jan F. Chadima 69dd72f
+#include "auth.h"
Jan F. Chadima 69dd72f
+
Jan F. Chadima 69dd72f
+void
Jan F. Chadima 69dd72f
+linux_seed(void)
Jan F. Chadima 69dd72f
+{
Jan F. Chadima 69dd72f
+	char *env = getenv("SSH_USE_STRONG_RNG");
Jan F. Chadima 69dd72f
+	char *random = "/dev/random";
1900351
+	size_t len, ienv, randlen = 14;
Jan F. Chadima 69dd72f
+
Jan F. Chadima 69dd72f
+	if (!env || !strcmp(env, "0"))
Jan F. Chadima 69dd72f
+		random = "/dev/urandom";
9acec07
+	else if ((ienv = atoi(env)) > randlen)
Jan F. Chadima 69dd72f
+		randlen = ienv;
Jan F. Chadima 69dd72f
+
Jan F. Chadima 69dd72f
+	errno = 0;
Jan F. Chadima 69dd72f
+	if ((len = RAND_load_file(random, randlen)) != randlen) {
Jan F. Chadima 69dd72f
+		if (errno)
Jan F. Chadima 69dd72f
+			fatal ("cannot read from %s, %s", random, strerror(errno));
Jan F. Chadima 69dd72f
+		else
Jan F. Chadima 69dd72f
+			fatal ("EOF reading %s", random);
Jan F. Chadima 69dd72f
+	}
Jan F. Chadima 69dd72f
+}
6cf9b8e
diff -up openssh-7.4p1/ssh.1.entropy openssh-7.4p1/ssh.1
6cf9b8e
--- openssh-7.4p1/ssh.1.entropy	2016-12-23 18:34:27.754753565 +0100
6cf9b8e
+++ openssh-7.4p1/ssh.1	2016-12-23 18:34:27.770753571 +0100
6cf9b8e
@@ -1441,6 +1441,23 @@ For more information, see the
6cf9b8e
 .Cm PermitUserEnvironment
6cf9b8e
 option in
6cf9b8e
 .Xr sshd_config 5 .
6cf9b8e
+.Sh ENVIRONMENT
6cf9b8e
+.Bl -tag -width Ds -compact
6cf9b8e
+.It Ev SSH_USE_STRONG_RNG
6cf9b8e
+The reseeding of the OpenSSL random generator is usually done from
6cf9b8e
+.Cm /dev/urandom .
6cf9b8e
+If the 
6cf9b8e
+.Cm SSH_USE_STRONG_RNG
6cf9b8e
+environment variable is set to value other than
6cf9b8e
+.Cm 0
6cf9b8e
+the OpenSSL random generator is reseeded from
6cf9b8e
+.Cm /dev/random .
6cf9b8e
+The number of bytes read is defined by the SSH_USE_STRONG_RNG value. 
6cf9b8e
+Minimum is 14 bytes.
6cf9b8e
+This setting is not recommended on the computers without the hardware
6cf9b8e
+random generator because insufficient entropy causes the connection to 
6cf9b8e
+be blocked until enough entropy is available.
6cf9b8e
+.El
6cf9b8e
 .Sh FILES
6cf9b8e
 .Bl -tag -width Ds -compact
6cf9b8e
 .It Pa ~/.rhosts
6cf9b8e
diff -up openssh-7.4p1/ssh-add.1.entropy openssh-7.4p1/ssh-add.1
6cf9b8e
--- openssh-7.4p1/ssh-add.1.entropy	2016-12-19 05:59:41.000000000 +0100
6cf9b8e
+++ openssh-7.4p1/ssh-add.1	2016-12-23 18:34:27.770753571 +0100
6cf9b8e
@@ -171,6 +171,20 @@ to make this work.)
251c8db
 Identifies the path of a
65ba94e
 .Ux Ns -domain
65ba94e
 socket used to communicate with the agent.
65ba94e
+.It Ev SSH_USE_STRONG_RNG
Jan F. Chadima 69dd72f
+The reseeding of the OpenSSL random generator is usually done from
Jan F. Chadima 69dd72f
+.Cm /dev/urandom .
Jan F. Chadima 69dd72f
+If the 
Jan F. Chadima 69dd72f
+.Cm SSH_USE_STRONG_RNG
Jan F. Chadima 69dd72f
+environment variable is set to value other than
Jan F. Chadima 69dd72f
+.Cm 0
Jan F. Chadima 69dd72f
+the OpenSSL random generator is reseeded from
Jan F. Chadima 69dd72f
+.Cm /dev/random .
Jan F. Chadima 69dd72f
+The number of bytes read is defined by the SSH_USE_STRONG_RNG value. 
9acec07
+Minimum is 14 bytes.
Jan F. Chadima 69dd72f
+This setting is not recommended on the computers without the hardware
Jan F. Chadima 69dd72f
+random generator because insufficient entropy causes the connection to 
Jan F. Chadima 69dd72f
+be blocked until enough entropy is available.
251c8db
 .El
65ba94e
 .Sh FILES
65ba94e
 .Bl -tag -width Ds
6cf9b8e
diff -up openssh-7.4p1/ssh-agent.1.entropy openssh-7.4p1/ssh-agent.1
6cf9b8e
--- openssh-7.4p1/ssh-agent.1.entropy	2016-12-19 05:59:41.000000000 +0100
6cf9b8e
+++ openssh-7.4p1/ssh-agent.1	2016-12-23 18:34:27.770753571 +0100
6cf9b8e
@@ -214,6 +214,24 @@ sockets used to contain the connection t
65ba94e
 These sockets should only be readable by the owner.
65ba94e
 The sockets should get automatically removed when the agent exits.
Jan F. Chadima 69dd72f
 .El
Jan F. Chadima 69dd72f
+.Sh ENVIRONMENT
Jan F. Chadima 69dd72f
+.Bl -tag -width Ds -compact
Jan F. Chadima 69dd72f
+.Pp
Jan F. Chadima 69dd72f
+.It Pa SSH_USE_STRONG_RNG
Jan F. Chadima 69dd72f
+The reseeding of the OpenSSL random generator is usually done from
Jan F. Chadima 69dd72f
+.Cm /dev/urandom .
Jan F. Chadima 69dd72f
+If the 
Jan F. Chadima 69dd72f
+.Cm SSH_USE_STRONG_RNG
Jan F. Chadima 69dd72f
+environment variable is set to value other than
Jan F. Chadima 69dd72f
+.Cm 0
Jan F. Chadima 69dd72f
+the OpenSSL random generator is reseeded from
Jan F. Chadima 69dd72f
+.Cm /dev/random .
Jan F. Chadima 69dd72f
+The number of bytes read is defined by the SSH_USE_STRONG_RNG value. 
9acec07
+Minimum is 14 bytes.
Jan F. Chadima 69dd72f
+This setting is not recommended on the computers without the hardware
Jan F. Chadima 69dd72f
+random generator because insufficient entropy causes the connection to 
Jan F. Chadima 69dd72f
+be blocked until enough entropy is available.
Jan F. Chadima 69dd72f
+.El
Jan F. Chadima 69dd72f
 .Sh SEE ALSO
Jan F. Chadima 69dd72f
 .Xr ssh 1 ,
Jan F. Chadima 69dd72f
 .Xr ssh-add 1 ,
6cf9b8e
diff -up openssh-7.4p1/sshd.8.entropy openssh-7.4p1/sshd.8
6cf9b8e
--- openssh-7.4p1/sshd.8.entropy	2016-12-23 18:34:27.755753566 +0100
6cf9b8e
+++ openssh-7.4p1/sshd.8	2016-12-23 18:34:27.770753571 +0100
6cf9b8e
@@ -920,6 +920,24 @@ concurrently for different ports, this c
6cf9b8e
 started last).
6cf9b8e
 The content of this file is not sensitive; it can be world-readable.
Jan F. Chadima 69dd72f
 .El
Jan F. Chadima 69dd72f
+.Sh ENVIRONMENT
Jan F. Chadima 69dd72f
+.Bl -tag -width Ds -compact
Jan F. Chadima 69dd72f
+.Pp
Jan F. Chadima 69dd72f
+.It Pa SSH_USE_STRONG_RNG
Jan F. Chadima 69dd72f
+The reseeding of the OpenSSL random generator is usually done from
Jan F. Chadima 69dd72f
+.Cm /dev/urandom .
Jan F. Chadima 69dd72f
+If the 
Jan F. Chadima 69dd72f
+.Cm SSH_USE_STRONG_RNG
Jan F. Chadima 69dd72f
+environment variable is set to value other than
Jan F. Chadima 69dd72f
+.Cm 0
Jan F. Chadima 69dd72f
+the OpenSSL random generator is reseeded from
Jan F. Chadima 69dd72f
+.Cm /dev/random .
Jan F. Chadima 69dd72f
+The number of bytes read is defined by the SSH_USE_STRONG_RNG value. 
9acec07
+Minimum is 14 bytes.
Jan F. Chadima 69dd72f
+This setting is not recommended on the computers without the hardware
Jan F. Chadima 69dd72f
+random generator because insufficient entropy causes the connection to 
Jan F. Chadima 69dd72f
+be blocked until enough entropy is available.
Jan F. Chadima 69dd72f
+.El
6cf9b8e
 .Sh IPV6
6cf9b8e
 IPv6 address can be used everywhere where IPv4 address. In all entries must be the IPv6 address enclosed in square brackets. Note: The square brackets are metacharacters for the shell and must be escaped in shell.
Jan F. Chadima 69dd72f
 .Sh SEE ALSO
6cf9b8e
diff -up openssh-7.4p1/ssh-keygen.1.entropy openssh-7.4p1/ssh-keygen.1
6cf9b8e
--- openssh-7.4p1/ssh-keygen.1.entropy	2016-12-19 05:59:41.000000000 +0100
6cf9b8e
+++ openssh-7.4p1/ssh-keygen.1	2016-12-23 18:34:27.770753571 +0100
6cf9b8e
@@ -848,6 +848,24 @@ Contains Diffie-Hellman groups used for
6cf9b8e
 The file format is described in
6cf9b8e
 .Xr moduli 5 .
65ba94e
 .El
Jan F. Chadima 69dd72f
+.Sh ENVIRONMENT
Jan F. Chadima 69dd72f
+.Bl -tag -width Ds -compact
65ba94e
+.Pp
65ba94e
+.It Pa SSH_USE_STRONG_RNG
Jan F. Chadima 69dd72f
+The reseeding of the OpenSSL random generator is usually done from
Jan F. Chadima 69dd72f
+.Cm /dev/urandom .
Jan F. Chadima 69dd72f
+If the 
Jan F. Chadima 69dd72f
+.Cm SSH_USE_STRONG_RNG
Jan F. Chadima 69dd72f
+environment variable is set to value other than
Jan F. Chadima 69dd72f
+.Cm 0
Jan F. Chadima 69dd72f
+the OpenSSL random generator is reseeded from
Jan F. Chadima 69dd72f
+.Cm /dev/random .
Jan F. Chadima 69dd72f
+The number of bytes read is defined by the SSH_USE_STRONG_RNG value. 
9acec07
+Minimum is 14 bytes.
Jan F. Chadima 69dd72f
+This setting is not recommended on the computers without the hardware
Jan F. Chadima 69dd72f
+random generator because insufficient entropy causes the connection to 
Jan F. Chadima 69dd72f
+be blocked until enough entropy is available.
Jan F. Chadima 69dd72f
+.El
65ba94e
 .Sh SEE ALSO
65ba94e
 .Xr ssh 1 ,
6cf9b8e
 .Xr ssh-add 1 ,
6cf9b8e
diff -up openssh-7.4p1/ssh-keysign.8.entropy openssh-7.4p1/ssh-keysign.8
6cf9b8e
--- openssh-7.4p1/ssh-keysign.8.entropy	2016-12-19 05:59:41.000000000 +0100
6cf9b8e
+++ openssh-7.4p1/ssh-keysign.8	2016-12-23 18:34:27.770753571 +0100
6cf9b8e
@@ -80,6 +80,24 @@ must be set-uid root if host-based authe
6cf9b8e
 If these files exist they are assumed to contain public certificate
6cf9b8e
 information corresponding with the private keys above.
94c6f8d
 .El
8a29ded
+.Sh ENVIRONMENT
8a29ded
+.Bl -tag -width Ds -compact
94c6f8d
+.Pp
94c6f8d
+.It Pa SSH_USE_STRONG_RNG
8a29ded
+The reseeding of the OpenSSL random generator is usually done from
8a29ded
+.Cm /dev/urandom .
8a29ded
+If the 
8a29ded
+.Cm SSH_USE_STRONG_RNG
8a29ded
+environment variable is set to value other than
8a29ded
+.Cm 0
8a29ded
+the OpenSSL random generator is reseeded from
8a29ded
+.Cm /dev/random .
8a29ded
+The number of bytes read is defined by the SSH_USE_STRONG_RNG value. 
9acec07
+Minimum is 14 bytes.
8a29ded
+This setting is not recommended on the computers without the hardware
8a29ded
+random generator because insufficient entropy causes the connection to 
8a29ded
+be blocked until enough entropy is available.
8a29ded
+.El
94c6f8d
 .Sh SEE ALSO
6cf9b8e
 .Xr ssh 1 ,
6cf9b8e
 .Xr ssh-keygen 1 ,