kentpeacock / rpms / openssh

Forked from rpms/openssh 2 years ago
Clone
8f2528
diff --git a/entropy.c b/entropy.c
8f2528
index 2d483b3..b361a04 100644
8f2528
--- a/entropy.c
8f2528
+++ b/entropy.c
8f2528
@@ -234,6 +234,9 @@ seed_rng(void)
8f2528
 	memset(buf, '\0', sizeof(buf));
8f2528
 
8f2528
 #endif /* OPENSSL_PRNG_ONLY */
8f2528
+#ifdef __linux__
8f2528
+	linux_seed();
8f2528
+#endif /* __linux__ */
8f2528
 	if (RAND_status() != 1)
8f2528
 		fatal("PRNG is not seeded");
8f2528
 }
8f2528
diff --git a/openbsd-compat/Makefile.in b/openbsd-compat/Makefile.in
8f2528
index b912dbe..9206337 100644
8f2528
--- a/openbsd-compat/Makefile.in
8f2528
+++ b/openbsd-compat/Makefile.in
8f2528
@@ -20,7 +20,7 @@ OPENBSD=base64.o basename.o bcrypt_pbkdf.o bindresvport.o blowfish.o daemon.o di
8f2528
 
8f2528
 COMPAT=arc4random.o bsd-asprintf.o bsd-closefrom.o bsd-cray.o bsd-cygwin_util.o bsd-getpeereid.o getrrsetbyname-ldns.o bsd-err.o bsd-misc.o bsd-nextstep.o bsd-openpty.o bsd-poll.o bsd-setres_id.o bsd-snprintf.o bsd-statvfs.o bsd-waitpid.o fake-rfc2553.o openssl-compat.o xcrypt.o kludge-fd_set.o
8f2528
 
8f2528
-PORTS=port-aix.o port-irix.o port-linux.o port-linux-sshd.o port-solaris.o port-tun.o port-uw.o
8f2528
+PORTS=port-aix.o port-irix.o port-linux.o port-linux-sshd.o port-linux-prng.o port-solaris.o port-tun.o port-uw.o
8f2528
 
8f2528
 .c.o:
8f2528
 	$(CC) $(CFLAGS) $(CPPFLAGS) -c $<
8f2528
diff -up openssh-7.4p1/openbsd-compat/port-linux.h.entropy openssh-7.4p1/openbsd-compat/port-linux.h
8f2528
--- openssh-7.4p1/openbsd-compat/port-linux.h.entropy	2016-12-23 18:34:27.747753563 +0100
8f2528
+++ openssh-7.4p1/openbsd-compat/port-linux.h	2016-12-23 18:34:27.769753570 +0100
8f2528
@@ -34,4 +34,6 @@ void oom_adjust_restore(void);
8f2528
 void oom_adjust_setup(void);
8f2528
 #endif
8f2528
 
8f2528
+void linux_seed(void);
8f2528
+
8f2528
 #endif /* ! _PORT_LINUX_H */
8f2528
diff --git a/openbsd-compat/port-linux-prng.c b/openbsd-compat/port-linux-prng.c
8f2528
new file mode 100644
8f2528
index 0000000..92a617c
8f2528
--- /dev/null
8f2528
+++ b/openbsd-compat/port-linux-prng.c
8f2528
@@ -0,0 +1,59 @@
8f2528
+/* $Id: port-linux.c,v 1.11.4.2 2011/02/04 00:43:08 djm Exp $ */
8f2528
+
8f2528
+/*
8f2528
+ * Copyright (c) 2011 Jan F. Chadima <jchadima@redhat.com>
8f2528
+ *
8f2528
+ * Permission to use, copy, modify, and distribute this software for any
8f2528
+ * purpose with or without fee is hereby granted, provided that the above
8f2528
+ * copyright notice and this permission notice appear in all copies.
8f2528
+ *
8f2528
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8f2528
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
8f2528
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
8f2528
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
8f2528
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
8f2528
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
8f2528
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
8f2528
+ */
8f2528
+
8f2528
+/*
8f2528
+ * Linux-specific portability code - prng support
8f2528
+ */
8f2528
+
8f2528
+#include "includes.h"
8f2528
+
8f2528
+#include <errno.h>
8f2528
+#include <stdarg.h>
8f2528
+#include <string.h>
8f2528
+#include <stdio.h>
8f2528
+#include <openssl/rand.h>
8f2528
+
8f2528
+#include "log.h"
8f2528
+#include "xmalloc.h"
8f2528
+#include "misc.h"      /* servconf.h needs misc.h for struct ForwardOptions */
8f2528
+#include "servconf.h"
8f2528
+#include "port-linux.h"
8f2528
+#include "key.h"
8f2528
+#include "hostfile.h"
8f2528
+#include "auth.h"
8f2528
+
8f2528
+void
8f2528
+linux_seed(void)
8f2528
+{
8f2528
+	char *env = getenv("SSH_USE_STRONG_RNG");
8f2528
+	char *random = "/dev/random";
8f2528
+	size_t len, ienv, randlen = 14;
8f2528
+
8f2528
+	if (!env || !strcmp(env, "0"))
8f2528
+		random = "/dev/urandom";
8f2528
+	else if ((ienv = atoi(env)) > randlen)
8f2528
+		randlen = ienv;
8f2528
+
8f2528
+	errno = 0;
8f2528
+	if ((len = RAND_load_file(random, randlen)) != randlen) {
8f2528
+		if (errno)
8f2528
+			fatal ("cannot read from %s, %s", random, strerror(errno));
8f2528
+		else
8f2528
+			fatal ("EOF reading %s", random);
8f2528
+	}
8f2528
+}
8f2528
diff --git a/ssh-add.0 b/ssh-add.0
8f2528
index ba43fee..0b2629a 100644
8f2528
--- a/ssh-add.0
8f2528
+++ b/ssh-add.0
8f2528
@@ -82,6 +82,16 @@ ENVIRONMENT
8f2528
              Identifies the path of a UNIX-domain socket used to communicate
8f2528
              with the agent.
8f2528
 
8f2528
+     SSH_USE_STRONG_RNG
8f2528
+             The reseeding of the OpenSSL random generator is usually done
8f2528
+             from /dev/urandom.  If the SSH_USE_STRONG_RNG environment vari-
8f2528
+             able is set to value other than 0 the OpenSSL random generator is
8f2528
+             reseeded from /dev/random.  The number of bytes read is defined
8f2528
+             by the SSH_USE_STRONG_RNG value.  Minimum is 14 bytes.  This set-
8f2528
+             ting is not recommended on the computers without the hardware
8f2528
+             random generator because insufficient entropy causes the connec-
8f2528
+             tion to be blocked until enough entropy is available.
8f2528
+
8f2528
 FILES
8f2528
      ~/.ssh/identity
8f2528
              Contains the protocol version 1 RSA authentication identity of
8f2528
diff --git a/ssh-add.1 b/ssh-add.1
8f2528
index 4812448..16305bf 100644
8f2528
--- a/ssh-add.1
8f2528
+++ b/ssh-add.1
8f2528
@@ -161,6 +161,20 @@ to make this work.)
8f2528
 Identifies the path of a
8f2528
 .Ux Ns -domain
8f2528
 socket used to communicate with the agent.
8f2528
+.It Ev SSH_USE_STRONG_RNG
8f2528
+The reseeding of the OpenSSL random generator is usually done from
8f2528
+.Cm /dev/urandom .
8f2528
+If the 
8f2528
+.Cm SSH_USE_STRONG_RNG
8f2528
+environment variable is set to value other than
8f2528
+.Cm 0
8f2528
+the OpenSSL random generator is reseeded from
8f2528
+.Cm /dev/random .
8f2528
+The number of bytes read is defined by the SSH_USE_STRONG_RNG value. 
8f2528
+Minimum is 14 bytes.
8f2528
+This setting is not recommended on the computers without the hardware
8f2528
+random generator because insufficient entropy causes the connection to 
8f2528
+be blocked until enough entropy is available.
8f2528
 .El
8f2528
 .Sh FILES
8f2528
 .Bl -tag -width Ds
8f2528
diff --git a/ssh-agent.1 b/ssh-agent.1
8f2528
index 281ecbd..1a9a635 100644
8f2528
--- a/ssh-agent.1
8f2528
+++ b/ssh-agent.1
8f2528
@@ -201,6 +201,24 @@ sockets used to contain the connection to the authentication agent.
8f2528
 These sockets should only be readable by the owner.
8f2528
 The sockets should get automatically removed when the agent exits.
8f2528
 .El
8f2528
+.Sh ENVIRONMENT
8f2528
+.Bl -tag -width Ds -compact
8f2528
+.Pp
8f2528
+.It Pa SSH_USE_STRONG_RNG
8f2528
+The reseeding of the OpenSSL random generator is usually done from
8f2528
+.Cm /dev/urandom .
8f2528
+If the 
8f2528
+.Cm SSH_USE_STRONG_RNG
8f2528
+environment variable is set to value other than
8f2528
+.Cm 0
8f2528
+the OpenSSL random generator is reseeded from
8f2528
+.Cm /dev/random .
8f2528
+The number of bytes read is defined by the SSH_USE_STRONG_RNG value. 
8f2528
+Minimum is 14 bytes.
8f2528
+This setting is not recommended on the computers without the hardware
8f2528
+random generator because insufficient entropy causes the connection to 
8f2528
+be blocked until enough entropy is available.
8f2528
+.El
8f2528
 .Sh SEE ALSO
8f2528
 .Xr ssh 1 ,
8f2528
 .Xr ssh-add 1 ,
8f2528
diff --git a/ssh-keygen.1 b/ssh-keygen.1
8f2528
index 12e00d4..1b51a4a 100644
8f2528
--- a/ssh-keygen.1
8f2528
+++ b/ssh-keygen.1
8f2528
@@ -832,6 +832,24 @@ Contains Diffie-Hellman groups used for DH-GEX.
8f2528
 The file format is described in
8f2528
 .Xr moduli 5 .
8f2528
 .El
8f2528
+.Sh ENVIRONMENT
8f2528
+.Bl -tag -width Ds -compact
8f2528
+.Pp
8f2528
+.It Pa SSH_USE_STRONG_RNG
8f2528
+The reseeding of the OpenSSL random generator is usually done from
8f2528
+.Cm /dev/urandom .
8f2528
+If the 
8f2528
+.Cm SSH_USE_STRONG_RNG
8f2528
+environment variable is set to value other than
8f2528
+.Cm 0
8f2528
+the OpenSSL random generator is reseeded from
8f2528
+.Cm /dev/random .
8f2528
+The number of bytes read is defined by the SSH_USE_STRONG_RNG value. 
8f2528
+Minimum is 14 bytes.
8f2528
+This setting is not recommended on the computers without the hardware
8f2528
+random generator because insufficient entropy causes the connection to 
8f2528
+be blocked until enough entropy is available.
8f2528
+.El
8f2528
 .Sh SEE ALSO
8f2528
 .Xr ssh 1 ,
8f2528
 .Xr ssh-add 1 ,
8f2528
diff --git a/ssh-keysign.8 b/ssh-keysign.8
8f2528
index 69d0829..02d79f8 100644
8f2528
--- a/ssh-keysign.8
8f2528
+++ b/ssh-keysign.8
8f2528
@@ -80,6 +80,24 @@ must be set-uid root if host-based authentication is used.
8f2528
 If these files exist they are assumed to contain public certificate
8f2528
 information corresponding with the private keys above.
8f2528
 .El
8f2528
+.Sh ENVIRONMENT
8f2528
+.Bl -tag -width Ds -compact
8f2528
+.Pp
8f2528
+.It Pa SSH_USE_STRONG_RNG
8f2528
+The reseeding of the OpenSSL random generator is usually done from
8f2528
+.Cm /dev/urandom .
8f2528
+If the 
8f2528
+.Cm SSH_USE_STRONG_RNG
8f2528
+environment variable is set to value other than
8f2528
+.Cm 0
8f2528
+the OpenSSL random generator is reseeded from
8f2528
+.Cm /dev/random .
8f2528
+The number of bytes read is defined by the SSH_USE_STRONG_RNG value. 
8f2528
+Minimum is 14 bytes.
8f2528
+This setting is not recommended on the computers without the hardware
8f2528
+random generator because insufficient entropy causes the connection to 
8f2528
+be blocked until enough entropy is available.
8f2528
+.El
8f2528
 .Sh SEE ALSO
8f2528
 .Xr ssh 1 ,
8f2528
 .Xr ssh-keygen 1 ,
8f2528
diff --git a/ssh.1 b/ssh.1
8f2528
index 929904b..f65e42f 100644
8f2528
--- a/ssh.1
8f2528
+++ b/ssh.1
8f2528
@@ -1309,6 +1309,23 @@ For more information, see the
8f2528
 .Cm PermitUserEnvironment
8f2528
 option in
8f2528
 .Xr sshd_config 5 .
8f2528
+.Sh ENVIRONMENT
8f2528
+.Bl -tag -width Ds -compact
8f2528
+.It Ev SSH_USE_STRONG_RNG
8f2528
+The reseeding of the OpenSSL random generator is usually done from
8f2528
+.Cm /dev/urandom .
8f2528
+If the 
8f2528
+.Cm SSH_USE_STRONG_RNG
8f2528
+environment variable is set to value other than
8f2528
+.Cm 0
8f2528
+the OpenSSL random generator is reseeded from
8f2528
+.Cm /dev/random .
8f2528
+The number of bytes read is defined by the SSH_USE_STRONG_RNG value. 
8f2528
+Minimum is 14 bytes.
8f2528
+This setting is not recommended on the computers without the hardware
8f2528
+random generator because insufficient entropy causes the connection to 
8f2528
+be blocked until enough entropy is available.
8f2528
+.El
8f2528
 .Sh FILES
8f2528
 .Bl -tag -width Ds -compact
8f2528
 .It Pa ~/.rhosts
8f2528
diff --git a/sshd.8 b/sshd.8
8f2528
index c2c237f..058d37a 100644
8f2528
--- a/sshd.8
8f2528
+++ b/sshd.8
8f2528
@@ -951,6 +951,24 @@ concurrently for different ports, this contains the process ID of the one
8f2528
 started last).
8f2528
 The content of this file is not sensitive; it can be world-readable.
8f2528
 .El
8f2528
+.Sh ENVIRONMENT
8f2528
+.Bl -tag -width Ds -compact
8f2528
+.Pp
8f2528
+.It Pa SSH_USE_STRONG_RNG
8f2528
+The reseeding of the OpenSSL random generator is usually done from
8f2528
+.Cm /dev/urandom .
8f2528
+If the 
8f2528
+.Cm SSH_USE_STRONG_RNG
8f2528
+environment variable is set to value other than
8f2528
+.Cm 0
8f2528
+the OpenSSL random generator is reseeded from
8f2528
+.Cm /dev/random .
8f2528
+The number of bytes read is defined by the SSH_USE_STRONG_RNG value. 
8f2528
+Minimum is 14 bytes.
8f2528
+This setting is not recommended on the computers without the hardware
8f2528
+random generator because insufficient entropy causes the connection to 
8f2528
+be blocked until enough entropy is available.
8f2528
+.El
8f2528
 .Sh IPV6
8f2528
 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.
8f2528
 .Sh SEE ALSO