318211936a
Version update to 8.1p1: * ssh-keygen(1): when acting as a CA and signing certificates with an RSA key, default to using the rsa-sha2-512 signature algorithm. Certificates signed by RSA keys will therefore be incompatible with OpenSSH versions prior to 7.2 unless the default is overridden (using "ssh-keygen -t ssh-rsa -s ..."). * ssh(1): Allow %n to be expanded in ProxyCommand strings * ssh(1), sshd(8): Allow prepending a list of algorithms to the default set by starting the list with the '^' character, E.g. "HostKeyAlgorithms ^ssh-ed25519" * ssh-keygen(1): add an experimental lightweight signature and verification ability. Signatures may be made using regular ssh keys held on disk or stored in a ssh-agent and verified against an authorized_keys-like list of allowed keys. Signatures embed a namespace that prevents confusion and attacks between different usage domains (e.g. files vs email). * ssh-keygen(1): print key comment when extracting public key from a private key. * ssh-keygen(1): accept the verbose flag when searching for host keys in known hosts (i.e. "ssh-keygen -vF host") to print the matching host's random-art signature too. * All: support PKCS8 as an optional format for storage of private keys to disk. The OpenSSH native key format remains the default, but PKCS8 is a superior format to PEM if interoperability with non-OpenSSH software is required, as it may use a less insecure key derivation function than PEM's. - Additional changes from 8.0p1 release: * scp(1): Add "-T" flag to disable client-side filtering of server file list. * sshd(8): Remove support for obsolete "host/port" syntax. OBS-URL: https://build.opensuse.org/request/show/737034 OBS-URL: https://build.opensuse.org/package/show/network/openssh?expand=0&rev=197
380 lines
12 KiB
Diff
380 lines
12 KiB
Diff
# HG changeset patch
|
|
# Parent e655fcb8e89d19ce9e954d6fc330e5e3e093a848
|
|
# extended support for (re-)seeding the OpenSSL PRNG from /dev/random
|
|
# bnc#703221, FATE#312172
|
|
|
|
diff --git a/Makefile.in b/Makefile.in
|
|
index 85818f4..750aada 100644
|
|
--- a/Makefile.in
|
|
+++ b/Makefile.in
|
|
@@ -182,13 +182,13 @@ libssh.a: $(LIBSSH_OBJS)
|
|
$(RANLIB) $@
|
|
|
|
ssh$(EXEEXT): $(LIBCOMPAT) libssh.a $(SSHOBJS)
|
|
- $(LD) -o $@ $(SSHOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(SSHLIBS) $(LIBS) $(GSSLIBS)
|
|
+ $(LD) -o $@ $(SSHOBJS) $(LDFLAGS) -lssh -lopenbsd-compat -lssh $(SSHLIBS) $(LIBS) $(GSSLIBS)
|
|
|
|
sshd$(EXEEXT): libssh.a $(LIBCOMPAT) $(SSHDOBJS)
|
|
- $(LD) -o $@ $(SSHDOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(SSHDLIBS) $(LIBS) $(GSSLIBS) $(K5LIBS)
|
|
+ $(LD) -o $@ $(SSHDOBJS) $(LDFLAGS) -lssh -lopenbsd-compat -lssh $(SSHDLIBS) $(LIBS) $(GSSLIBS) $(K5LIBS)
|
|
|
|
scp$(EXEEXT): $(LIBCOMPAT) libssh.a scp.o progressmeter.o
|
|
- $(LD) -o $@ scp.o progressmeter.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
|
|
+ $(LD) -o $@ scp.o progressmeter.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
|
|
|
|
ssh-add$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-add.o
|
|
$(LD) -o $@ ssh-add.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
|
|
@@ -197,10 +197,10 @@ ssh-agent$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-agent.o ssh-pkcs11-client.o
|
|
$(LD) -o $@ ssh-agent.o ssh-pkcs11-client.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
|
|
|
|
ssh-keygen$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keygen.o sshsig.o
|
|
- $(LD) -o $@ ssh-keygen.o sshsig.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
|
|
+ $(LD) -o $@ ssh-keygen.o sshsig.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
|
|
|
|
ssh-keysign$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keysign.o readconf.o uidswap.o compat.o
|
|
- $(LD) -o $@ ssh-keysign.o readconf.o uidswap.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
|
|
+ $(LD) -o $@ ssh-keysign.o readconf.o uidswap.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh $(LIBS)
|
|
|
|
ssh-pkcs11-helper$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-pkcs11-helper.o ssh-pkcs11.o
|
|
$(LD) -o $@ ssh-pkcs11-helper.o ssh-pkcs11.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
|
|
@@ -209,10 +209,10 @@ ssh-keyscan$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keyscan.o
|
|
$(LD) -o $@ ssh-keyscan.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh $(LIBS)
|
|
|
|
sftp-server$(EXEEXT): $(LIBCOMPAT) libssh.a sftp.o sftp-common.o sftp-server.o sftp-realpath.o sftp-server-main.o
|
|
- $(LD) -o $@ sftp-server.o sftp-common.o sftp-realpath.o sftp-server-main.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
|
|
+ $(LD) -o $@ sftp-server.o sftp-common.o sftp-realpath.o sftp-server-main.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
|
|
|
|
sftp$(EXEEXT): $(LIBCOMPAT) libssh.a sftp.o sftp-client.o sftp-common.o sftp-glob.o progressmeter.o
|
|
- $(LD) -o $@ progressmeter.o sftp.o sftp-client.o sftp-common.o sftp-glob.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) $(LIBEDIT)
|
|
+ $(LD) -o $@ progressmeter.o sftp.o sftp-client.o sftp-common.o sftp-glob.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS) $(LIBEDIT)
|
|
|
|
# FIPS tests
|
|
cavstest-ctr$(EXEEXT): $(LIBCOMPAT) libssh.a cavstest-ctr.o
|
|
diff --git a/entropy.c b/entropy.c
|
|
index 5de6801..f8b9f42 100644
|
|
--- a/entropy.c
|
|
+++ b/entropy.c
|
|
@@ -239,6 +239,8 @@ seed_rng(void)
|
|
}
|
|
#endif /* OPENSSL_PRNG_ONLY */
|
|
|
|
+ linux_seed();
|
|
+
|
|
if (RAND_status() != 1)
|
|
fatal("PRNG is not seeded");
|
|
|
|
diff --git a/openbsd-compat/Makefile.in b/openbsd-compat/Makefile.in
|
|
index 1162dc5..80fd688 100644
|
|
--- a/openbsd-compat/Makefile.in
|
|
+++ b/openbsd-compat/Makefile.in
|
|
@@ -91,6 +91,7 @@ COMPAT= arc4random.o \
|
|
PORTS= port-aix.o \
|
|
port-irix.o \
|
|
port-linux.o \
|
|
+ port-linux-prng.o \
|
|
port-solaris.o \
|
|
port-net.o \
|
|
port-uw.o
|
|
diff --git a/openbsd-compat/port-linux-prng.c b/openbsd-compat/port-linux-prng.c
|
|
new file mode 100644
|
|
index 0000000..dfc4bdb
|
|
--- /dev/null
|
|
+++ b/openbsd-compat/port-linux-prng.c
|
|
@@ -0,0 +1,81 @@
|
|
+/*
|
|
+ * Copyright (c) 2011 Jan F. Chadima <jchadima@redhat.com>
|
|
+ * (c) 2011 Petr Cerny <pcerny@suse.cz>
|
|
+ *
|
|
+ * Permission to use, copy, modify, and distribute this software for any
|
|
+ * purpose with or without fee is hereby granted, provided that the above
|
|
+ * copyright notice and this permission notice appear in all copies.
|
|
+ *
|
|
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
+ */
|
|
+
|
|
+/*
|
|
+ * Linux-specific portability code - prng support
|
|
+ */
|
|
+
|
|
+#include "includes.h"
|
|
+#include "defines.h"
|
|
+
|
|
+#include <errno.h>
|
|
+#include <stdarg.h>
|
|
+#include <string.h>
|
|
+#include <stdio.h>
|
|
+#include <openssl/rand.h>
|
|
+
|
|
+#include "log.h"
|
|
+#include "port-linux.h"
|
|
+#include "fips.h"
|
|
+
|
|
+#define RNG_BYTES_DEFAULT 6L
|
|
+#define RNG_ENV_VAR "SSH_USE_STRONG_RNG"
|
|
+
|
|
+long rand_bytes = 0;
|
|
+char *rand_file = NULL;
|
|
+
|
|
+static void
|
|
+linux_seed_init(void)
|
|
+{
|
|
+ long elen = 0;
|
|
+ char *env = getenv(RNG_ENV_VAR);
|
|
+
|
|
+ if (env) {
|
|
+ errno = 0;
|
|
+ elen = strtol(env, NULL, 10);
|
|
+ if (errno) {
|
|
+ elen = RNG_BYTES_DEFAULT;
|
|
+ debug("bogus value in the %s environment variable, "
|
|
+ "using %li bytes from /dev/random\n",
|
|
+ RNG_ENV_VAR, RNG_BYTES_DEFAULT);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ if (elen || fips_mode())
|
|
+ rand_file = "/dev/random";
|
|
+ else
|
|
+ rand_file = "/dev/urandom";
|
|
+
|
|
+ rand_bytes = MAX(elen, RNG_BYTES_DEFAULT);
|
|
+}
|
|
+
|
|
+void
|
|
+linux_seed(void)
|
|
+{
|
|
+ long len;
|
|
+ if (!rand_file)
|
|
+ linux_seed_init();
|
|
+
|
|
+ errno = 0;
|
|
+ len = RAND_load_file(rand_file, rand_bytes);
|
|
+ if (len != rand_bytes) {
|
|
+ if (errno)
|
|
+ fatal ("cannot read from %s, %s", rand_file, strerror(errno));
|
|
+ else
|
|
+ fatal ("EOF reading %s", rand_file);
|
|
+ }
|
|
+}
|
|
diff --git a/openbsd-compat/port-linux.h b/openbsd-compat/port-linux.h
|
|
index 3c22a85..2dc1fd0 100644
|
|
--- a/openbsd-compat/port-linux.h
|
|
+++ b/openbsd-compat/port-linux.h
|
|
@@ -17,6 +17,10 @@
|
|
#ifndef _PORT_LINUX_H
|
|
#define _PORT_LINUX_H
|
|
|
|
+extern long rand_bytes;
|
|
+extern char *rand_file;
|
|
+void linux_seed(void);
|
|
+
|
|
#ifdef WITH_SELINUX
|
|
int ssh_selinux_enabled(void);
|
|
void ssh_selinux_setup_pty(char *, const char *);
|
|
diff --git a/ssh-add.1 b/ssh-add.1
|
|
index d4e1c60..6f76900 100644
|
|
--- a/ssh-add.1
|
|
+++ b/ssh-add.1
|
|
@@ -189,6 +189,20 @@ to make this work.)
|
|
Identifies the path of a
|
|
.Ux Ns -domain
|
|
socket used to communicate with the agent.
|
|
+.It Ev SSH_USE_STRONG_RNG
|
|
+The reseeding of the OpenSSL random generator is usually done from
|
|
+.Cm /dev/urandom .
|
|
+If the
|
|
+.Cm SSH_USE_STRONG_RNG
|
|
+environment variable is set to value other than
|
|
+.Cm 0
|
|
+the OpenSSL random generator is reseeded from
|
|
+.Cm /dev/random .
|
|
+The number of bytes read is defined by the SSH_USE_STRONG_RNG value.
|
|
+Minimum is 6 bytes.
|
|
+This setting is not recommended on the computers without the hardware
|
|
+random generator because insufficient entropy causes the connection to
|
|
+be blocked until enough entropy is available.
|
|
.El
|
|
.Sh FILES
|
|
.Bl -tag -width Ds
|
|
diff --git a/ssh-agent.1 b/ssh-agent.1
|
|
index 83b2b41..9e187f2 100644
|
|
--- a/ssh-agent.1
|
|
+++ b/ssh-agent.1
|
|
@@ -214,6 +214,23 @@ sockets used to contain the connection to the authentication agent.
|
|
These sockets should only be readable by the owner.
|
|
The sockets should get automatically removed when the agent exits.
|
|
.El
|
|
+.Sh ENVIRONMENT
|
|
+.Bl -tag -width Ds -compact
|
|
+.Pp
|
|
+.It Pa SSH_USE_STRONG_RNG
|
|
+The reseeding of the OpenSSL random generator is usually done from
|
|
+.Cm /dev/urandom .
|
|
+If the
|
|
+.Cm SSH_USE_STRONG_RNG
|
|
+environment variable is set to value other than
|
|
+.Cm 0
|
|
+the OpenSSL random generator is reseeded from
|
|
+.Cm /dev/random .
|
|
+The number of bytes read is defined by the SSH_USE_STRONG_RNG value.
|
|
+Minimum is 6 bytes.
|
|
+This setting is not recommended on the computers without the hardware
|
|
+random generator because insufficient entropy causes the connection to
|
|
+be blocked until enough entropy is available.
|
|
.Sh SEE ALSO
|
|
.Xr ssh 1 ,
|
|
.Xr ssh-add 1 ,
|
|
diff --git a/ssh-keygen.1 b/ssh-keygen.1
|
|
index 957d2f0..70c4a28 100644
|
|
--- a/ssh-keygen.1
|
|
+++ b/ssh-keygen.1
|
|
@@ -1054,6 +1054,23 @@ Contains Diffie-Hellman groups used for DH-GEX.
|
|
The file format is described in
|
|
.Xr moduli 5 .
|
|
.El
|
|
+.Sh ENVIRONMENT
|
|
+.Bl -tag -width Ds -compact
|
|
+.Pp
|
|
+.It Pa SSH_USE_STRONG_RNG
|
|
+The reseeding of the OpenSSL random generator is usually done from
|
|
+.Cm /dev/urandom .
|
|
+If the
|
|
+.Cm SSH_USE_STRONG_RNG
|
|
+environment variable is set to value other than
|
|
+.Cm 0
|
|
+the OpenSSL random generator is reseeded from
|
|
+.Cm /dev/random .
|
|
+The number of bytes read is defined by the SSH_USE_STRONG_RNG value.
|
|
+Minimum is 6 bytes.
|
|
+This setting is not recommended on the computers without the hardware
|
|
+random generator because insufficient entropy causes the connection to
|
|
+be blocked until enough entropy is available.
|
|
.Sh SEE ALSO
|
|
.Xr ssh 1 ,
|
|
.Xr ssh-add 1 ,
|
|
diff --git a/ssh-keysign.8 b/ssh-keysign.8
|
|
index 19b0dbc..639b56e 100644
|
|
--- a/ssh-keysign.8
|
|
+++ b/ssh-keysign.8
|
|
@@ -80,6 +80,23 @@ must be set-uid root if host-based authentication is used.
|
|
If these files exist they are assumed to contain public certificate
|
|
information corresponding with the private keys above.
|
|
.El
|
|
+.Sh ENVIRONMENT
|
|
+.Bl -tag -width Ds -compact
|
|
+.Pp
|
|
+.It Pa SSH_USE_STRONG_RNG
|
|
+The reseeding of the OpenSSL random generator is usually done from
|
|
+.Cm /dev/urandom .
|
|
+If the
|
|
+.Cm SSH_USE_STRONG_RNG
|
|
+environment variable is set to value other than
|
|
+.Cm 0
|
|
+the OpenSSL random generator is reseeded from
|
|
+.Cm /dev/random .
|
|
+The number of bytes read is defined by the SSH_USE_STRONG_RNG value.
|
|
+Minimum is 6 bytes.
|
|
+This setting is not recommended on the computers without the hardware
|
|
+random generator because insufficient entropy causes the connection to
|
|
+be blocked until enough entropy is available.
|
|
.Sh SEE ALSO
|
|
.Xr ssh 1 ,
|
|
.Xr ssh-keygen 1 ,
|
|
diff --git a/ssh.1 b/ssh.1
|
|
index 424d6c3..899a339 100644
|
|
--- a/ssh.1
|
|
+++ b/ssh.1
|
|
@@ -1433,6 +1433,20 @@ For more information, see the
|
|
.Cm PermitUserEnvironment
|
|
option in
|
|
.Xr sshd_config 5 .
|
|
+.It Ev SSH_USE_STRONG_RNG
|
|
+The reseeding of the OpenSSL random generator is usually done from
|
|
+.Cm /dev/urandom .
|
|
+If the
|
|
+.Cm SSH_USE_STRONG_RNG
|
|
+environment variable is set to value other than
|
|
+.Cm 0
|
|
+the OpenSSL random generator is reseeded from
|
|
+.Cm /dev/random .
|
|
+The number of bytes read is defined by the SSH_USE_STRONG_RNG value.
|
|
+Minimum is 6 bytes.
|
|
+This setting is not recommended on the computers without the hardware
|
|
+random generator because insufficient entropy causes the connection to
|
|
+be blocked until enough entropy is available.
|
|
.Sh FILES
|
|
.Bl -tag -width Ds -compact
|
|
.It Pa ~/.rhosts
|
|
diff --git a/sshd.8 b/sshd.8
|
|
index fb133c1..2f1d3ab 100644
|
|
--- a/sshd.8
|
|
+++ b/sshd.8
|
|
@@ -966,6 +966,23 @@ concurrently for different ports, this contains the process ID of the one
|
|
started last).
|
|
The content of this file is not sensitive; it can be world-readable.
|
|
.El
|
|
+.Sh ENVIRONMENT
|
|
+.Bl -tag -width Ds -compact
|
|
+.Pp
|
|
+.It Pa SSH_USE_STRONG_RNG
|
|
+The reseeding of the OpenSSL random generator is usually done from
|
|
+.Cm /dev/urandom .
|
|
+If the
|
|
+.Cm SSH_USE_STRONG_RNG
|
|
+environment variable is set to value other than
|
|
+.Cm 0
|
|
+the OpenSSL random generator is reseeded from
|
|
+.Cm /dev/random .
|
|
+The number of bytes read is defined by the SSH_USE_STRONG_RNG value.
|
|
+Minimum is 6 bytes.
|
|
+This setting is not recommended on the computers without the hardware
|
|
+random generator because insufficient entropy causes the connection to
|
|
+be blocked until enough entropy is available.
|
|
.Sh SEE ALSO
|
|
.Xr scp 1 ,
|
|
.Xr sftp 1 ,
|
|
diff --git a/sshd.c b/sshd.c
|
|
index bb20eec..c562094 100644
|
|
--- a/sshd.c
|
|
+++ b/sshd.c
|
|
@@ -55,6 +55,8 @@
|
|
#endif
|
|
#include "openbsd-compat/sys-tree.h"
|
|
#include "openbsd-compat/sys-queue.h"
|
|
+#include "openbsd-compat/port-linux.h"
|
|
+
|
|
#include <sys/wait.h>
|
|
|
|
#include <errno.h>
|
|
@@ -205,6 +207,13 @@ struct {
|
|
int have_ssh2_key;
|
|
} sensitive_data;
|
|
|
|
+/*
|
|
+ * Every RESEED_AFTERth connection triggers call to linux_seed() to re-seed the
|
|
+ * random pool.
|
|
+ */
|
|
+#define RESEED_AFTER 100
|
|
+static int re_seeding_counter = RESEED_AFTER;
|
|
+
|
|
/* This is set to true when a signal is received. */
|
|
static volatile sig_atomic_t received_sighup = 0;
|
|
static volatile sig_atomic_t received_sigterm = 0;
|
|
@@ -1201,6 +1210,10 @@ server_accept_loop(int *sock_in, int *sock_out, int *newsock, int *config_s)
|
|
startup_flags[j] = 1;
|
|
break;
|
|
}
|
|
+ if(!(--re_seeding_counter)) {
|
|
+ re_seeding_counter = RESEED_AFTER;
|
|
+ linux_seed();
|
|
+ }
|
|
|
|
/*
|
|
* Got connection. Fork a child to handle it, unless
|