forked from pool/openssh
Marcus Meissner
3fed02069e
- Version upgrade to 8.8p1 * No changes for askpass, see main package changelog for details - Version update to 8.8p1: = Security * sshd(8) from OpenSSH 6.2 through 8.7 failed to correctly initialise supplemental groups when executing an AuthorizedKeysCommand or AuthorizedPrincipalsCommand, where a AuthorizedKeysCommandUser or AuthorizedPrincipalsCommandUser directive has been set to run the command as a different user. Instead these commands would inherit the groups that sshd(8) was started with. Depending on system configuration, inherited groups may allow AuthorizedKeysCommand/AuthorizedPrincipalsCommand helper programs to gain unintended privilege. Neither AuthorizedKeysCommand nor AuthorizedPrincipalsCommand are enabled by default in sshd_config(5). = Potentially-incompatible changes * This release disables RSA signatures using the SHA-1 hash algorithm by default. This change has been made as the SHA-1 hash algorithm is cryptographically broken, and it is possible to create chosen-prefix hash collisions for <USD$50K. For most users, this change should be invisible and there is no need to replace ssh-rsa keys. OpenSSH has supported RFC8332 RSA/SHA-256/512 signatures since release 7.2 and existing ssh-rsa keys will automatically use the stronger algorithm where possible. Incompatibility is more likely when connecting to older SSH implementations that have not been upgraded or have not closely tracked improvements in the SSH protocol. For these cases, it may be necessary to selectively re-enable RSA/SHA1 to allow connection and/or user authentication via the HostkeyAlgorithms and PubkeyAcceptedAlgorithms options. = New features * ssh(1): allow the ssh_config(5) CanonicalizePermittedCNAMEs directive to accept a "none" argument to specify the default behaviour. = Bugfixes * scp(1): when using the SFTP protocol, continue transferring files after a transfer error occurs, better matching original scp/rcp behaviour. * ssh(1): fixed a number of memory leaks in multiplexing, * ssh-keygen(1): avoid crash when using the -Y find-principals command. * A number of documentation and manual improvements, including bz#3340, PR139, PR215, PR241, PR257 - Additional changes from 8.7p1 release: = Potentially-incompatible changes * scp(1): this release changes the behaviour of remote to remote copies (e.g. "scp host-a:/path host-b:") to transfer through the local host by default. This was previously available via the -3 flag. This mode avoids the need to expose credentials on the origin hop, avoids triplicate interpretation of filenames by the shell (by the local system, the copy origin and the destination) and, in conjunction with the SFTP support for scp(1) mentioned below, allows use of all authentication methods to the remote hosts (previously, only non-interactive methods could be used). A -R flag has been added to select the old behaviour. * ssh(1)/sshd(8): both the client and server are now using a stricter configuration file parser. The new parser uses more shell-like rules for quotes, space and escape characters. It is also more strict in rejecting configurations that include options lacking arguments. Previously some options (e.g. DenyUsers) could appear on a line with no subsequent arguments. This release will reject such configurations. The new parser will also reject configurations with unterminated quotes and multiple '=' characters after the option name. * ssh(1): when using SSHFP DNS records for host key verification, ssh(1) will verify all matching records instead of just those with the specific signature type requested. This may cause host key verification problems if stale SSHFP records of a different or legacy signature type exist alongside other records for a particular host. bz#3322 * ssh-keygen(1): when generating a FIDO key and specifying an explicit attestation challenge (using -Ochallenge), the challenge will now be hashed by the builtin security key middleware. This removes the (undocumented) requirement that challenges be exactly 32 bytes in length and matches the expectations of libfido2. * sshd(8): environment="..." directives in authorized_keys files are now first-match-wins and limited to 1024 discrete environment variable names. = New features * scp(1): experimental support for transfers using the SFTP protocol as a replacement for the venerable SCP/RCP protocol that it has traditionally used. SFTP offers more predictable filename handling and does not require expansion of glob(3) patterns via the shell on the remote side. * sftp-server(8): add a protocol extension to support expansion of ~/ and ~user/ prefixed paths. This was added to support these paths when used by scp(1) while in SFTP mode. * ssh(1): add a ForkAfterAuthentication ssh_config(5) counterpart to the ssh(1) -f flag. GHPR231 * ssh(1): add a StdinNull directive to ssh_config(5) that allows the config file to do the same thing as -n does on the ssh(1) command- line. GHPR231 * ssh(1): add a SessionType directive to ssh_config, allowing the configuration file to offer equivalent control to the -N (no session) and -s (subsystem) command-line flags. GHPR231 * ssh-keygen(1): allowed signers files used by ssh-keygen(1) signatures now support listing key validity intervals alongside they key, and ssh-keygen(1) can optionally check during signature verification whether a specified time falls inside this interval. This feature is intended for use by git to support signing and verifying objects using ssh keys. * ssh-keygen(8): support printing of the full public key in a sshsig signature via a -Oprint-pubkey flag. = Bugfixes * ssh(1)/sshd(8): start time-based re-keying exactly on schedule in the client and server mainloops. Previously the re-key timeout could expire but re-keying would not start until a packet was sent or received, causing a spin in select() if the connection was quiescent. * ssh-keygen(1): avoid Y2038 problem in printing certificate validity lifetimes. Dates past 2^31-1 seconds since epoch were displayed incorrectly on some platforms. bz#3329 * scp(1): allow spaces to appear in usernames for local to remote and scp -3 remote to remote copies. bz#1164 * ssh(1)/sshd(8): remove references to ChallengeResponseAuthentication in favour of KbdInteractiveAuthentication. The former is what was in SSHv1, the latter is what is in SSHv2 (RFC4256) and they were treated as somewhat but not entirely equivalent. We retain the old name as a deprecated alias so configuration files continue to work as well as a reference in the man page for people looking for it. bz#3303 * ssh(1)/ssh-add(1)/ssh-keygen(1): fix decoding of X.509 subject name when extracting a key from a PKCS#11 certificate. bz#3327 * ssh(1): restore blocking status on stdio fds before close. ssh(1) needs file descriptors in non-blocking mode to operate but it was not restoring the original state on exit. This could cause problems with fds shared with other programs via the shell, bz#3280 and GHPR246 * ssh(1)/sshd(8): switch both client and server mainloops from select(3) to pselect(3). Avoids race conditions where a signal may arrive immediately before select(3) and not be processed until an event fires. bz#2158 * ssh(1): sessions started with ControlPersist were incorrectly executing a shell when the -N (no shell) option was specified. bz#3290 * ssh(1): check if IPQoS or TunnelDevice are already set before overriding. Prevents values in config files from overriding values supplied on the command line. bz#3319 * ssh(1): fix debug message when finding a private key to match a certificate being attempted for user authentication. Previously it would print the certificate's path, whereas it was supposed to be showing the private key's path. GHPR247 * sshd(8): match host certificates against host public keys, not private keys. Allows use of certificates with private keys held in a ssh-agent. bz#3524 * ssh(1): add a workaround for a bug in OpenSSH 7.4 sshd(8), which allows RSA/SHA2 signatures for public key authentication but fails to advertise this correctly via SSH2_MSG_EXT_INFO. This causes clients of these server to incorrectly match PubkeyAcceptedAlgorithmse and potentially refuse to offer valid keys. bz#3213 * sftp(1)/scp(1): degrade gracefully if a sftp-server offers the limits@openssh.com extension but fails when the client tries to invoke it. bz#3318 * ssh(1): allow ssh_config SetEnv to override $TERM, which is otherwise handled specially by the protocol. Useful in ~/.ssh/config to set TERM to something generic (e.g. "xterm" instead of "xterm-256color") for destinations that lack terminfo entries. * sftp-server(8): the limits@openssh.com extension was incorrectly marked as an operation that writes to the filesystem, which made it unavailable in sftp-server read-only mode. bz#3318 * ssh(1): fix SEGV in UpdateHostkeys debug() message, triggered when the update removed more host keys than remain present. * Many manual page fixes. - Additional changes from 8.6p1 release: = Security * sshd(8): OpenSSH 8.5 introduced the LogVerbose keyword. When this option was enabled with a set of patterns that activated logging in code that runs in the low-privilege sandboxed sshd process, the log messages were constructed in such a way that printf(3) format strings could effectively be specified the low-privilege code. = New features * sftp-server(8): add a new limits@openssh.com protocol extension that allows a client to discover various server limits, including maximum packet size and maximum read/write length. * sftp(1): use the new limits@openssh.com extension (when available) to select better transfer lengths in the client. * sshd(8): Add ModuliFile keyword to sshd_config to specify the location of the "moduli" file containing the groups for DH-GEX. * unit tests: Add a TEST_SSH_ELAPSED_TIMES environment variable to enable printing of the elapsed time in seconds of each test. = Bugfixes * ssh_config(5), sshd_config(5): sync CASignatureAlgorithms lists in manual pages with the current default. GHPR174 * ssh(1): ensure that pkcs11_del_provider() is called before exit. GHPR234 * ssh(1), sshd(8): fix problems in string->argv conversion. Multiple backslashes were not being dequoted correctly and quoted space in the middle of a string was being incorrectly split. GHPR223 * ssh(1): return non-zero exit status when killed by signal; bz#3281 * sftp-server(8): increase maximum SSH2_FXP_READ to match the maximum packet size. Also handle zero-length reads that are not explicitly banned by the spec. - Additional changes from 8.5p1 release: = Security * ssh-agent(1): fixed a double-free memory corruption that was introduced in OpenSSH 8.2 . We treat all such memory faults as potentially exploitable. This bug could be reached by an attacker with access to the agent socket. = Potentially-incompatible changes * ssh(1), sshd(8): this release changes the first-preference signature algorithm from ECDSA to ED25519. * ssh(1), sshd(8): set the TOS/DSCP specified in the configuration for interactive use prior to TCP connect. The connection phase of the SSH session is time-sensitive and often explicitly interactive. The ultimate interactive/bulk TOS/DSCP will be set after authentication completes. * ssh(1), sshd(8): remove the pre-standardization cipher rijndael-cbc@lysator.liu.se. It is an alias for aes256-cbc before it was standardized in RFC4253 (2006), has been deprecated and disabled by default since OpenSSH 7.2 (2016) and was only briefly documented in ssh.1 in 2001. * ssh(1), sshd(8): update/replace the experimental post-quantum hybrid key exchange method based on Streamlined NTRU Prime coupled with X25519. The previous sntrup4591761x25519-sha512@tinyssh.org method is replaced with sntrup761x25519-sha512@openssh.com. * ssh(1): disable CheckHostIP by default. It provides insignificant benefits while making key rotation significantly more difficult, especially for hosts behind IP-based load-balancers. = New features * ssh(1): this release enables UpdateHostkeys by default subject to some conservative preconditions: - The key was matched in the UserKnownHostsFile (and not in the GlobalKnownHostsFile). - The same key does not exist under another name. - A certificate host key is not in use. - known_hosts contains no matching wildcard hostname pattern. - VerifyHostKeyDNS is not enabled. - The default UserKnownHostsFile is in use. * ssh(1), sshd(8): add a new LogVerbose configuration directive for that allows forcing maximum debug logging by file/function/line pattern-lists. * ssh(1): when prompting the user to accept a new hostkey, display any other host names/addresses already associated with the key. * ssh(1): allow UserKnownHostsFile=none to indicate that no known_hosts file should be used to identify host keys. * ssh(1): add a ssh_config KnownHostsCommand option that allows the client to obtain known_hosts data from a command in addition to the usual files. * ssh(1): add a ssh_config PermitRemoteOpen option that allows the client to restrict the destination when RemoteForward is used with SOCKS. * ssh(1): for FIDO keys, if a signature operation fails with a "incorrect PIN" reason and no PIN was initially requested from the user, then request a PIN and retry the operation. This supports some biometric devices that fall back to requiring PIN when reading of the biometric failed, and devices that require PINs for all hosted credentials. * sshd(8): implement client address-based rate-limiting via new sshd_config(5) PerSourceMaxStartups and PerSourceNetBlockSize directives that provide more fine-grained control on a per-origin address basis than the global MaxStartups limit. = Bugfixes * ssh(1): Prefix keyboard interactive prompts with "(user@host)" to make it easier to determine which connection they are associated with in cases like scp -3, ProxyJump, etc. bz#3224 * sshd(8): fix sshd_config SetEnv directives located inside Match blocks. GHPR201 * ssh(1): when requesting a FIDO token touch on stderr, inform the user once the touch has been recorded. * ssh(1): prevent integer overflow when ridiculously large ConnectTimeout values are specified, capping the effective value (for most platforms) at 24 days. bz#3229 * ssh(1): consider the ECDSA key subtype when ordering host key algorithms in the client. * ssh(1), sshd(8): rename the PubkeyAcceptedKeyTypes keyword to PubkeyAcceptedAlgorithms. The previous name incorrectly suggested that it control allowed key algorithms, when this option actually specifies the signature algorithms that are accepted. The previous name remains available as an alias. bz#3253 * ssh(1), sshd(8): similarly, rename HostbasedKeyTypes (ssh) and HostbasedAcceptedKeyTypes (sshd) to HostbasedAcceptedAlgorithms. * sftp-server(8): add missing lsetstat@openssh.com documentation and advertisement in the server's SSH2_FXP_VERSION hello packet. * ssh(1), sshd(8): more strictly enforce KEX state-machine by banning packet types once they are received. Fixes memleak caused by duplicate SSH2_MSG_KEX_DH_GEX_REQUEST (oss-fuzz #30078). * sftp(1): allow the full range of UIDs/GIDs for chown/chgrp on 32bit platforms instead of being limited by LONG_MAX. bz#3206 * Minor man page fixes (capitalization, commas, etc.) bz#3223 * sftp(1): when doing an sftp recursive upload or download of a read-only directory, ensure that the directory is created with write and execute permissions in the interim so that the transfer can actually complete, then set the directory permission as the final step. bz#3222 * ssh-keygen(1): document the -Z, check the validity of its argument earlier and provide a better error message if it's not correct. bz#2879 * ssh(1): ignore comments at the end of config lines in ssh_config, similar to what we already do for sshd_config. bz#2320 * sshd_config(5): mention that DisableForwarding is valid in a sshd_config Match block. bz3239 * sftp(1): fix incorrect sorting of "ls -ltr" under some circumstances. bz3248. * ssh(1), sshd(8): fix potential integer truncation of (unlikely) timeout values. bz#3250 * ssh(1): make hostbased authentication send the signature algorithm in its SSH2_MSG_USERAUTH_REQUEST packets instead of the key type. This make HostbasedAcceptedAlgorithms do what it is supposed to - filter on signature algorithm and not key type. - Rebased patches: * openssh-7.7p1-IPv6_X_forwarding.patch * openssh-7.7p1-X11_trusted_forwarding.patch * openssh-7.7p1-X_forward_with_disabled_ipv6.patch * openssh-7.7p1-cavstest-ctr.patch * openssh-7.7p1-cavstest-kdf.patch * openssh-7.7p1-disable_openssl_abi_check.patch * openssh-7.7p1-eal3.patch * openssh-7.7p1-enable_PAM_by_default.patch * openssh-7.7p1-fips.patch * openssh-7.7p1-fips_checks.patch * openssh-7.7p1-host_ident.patch * openssh-7.7p1-hostname_changes_when_forwarding_X.patch * openssh-7.7p1-ldap.patch * openssh-7.7p1-no_fork-no_pid_file.patch * openssh-7.7p1-pam_check_locks.patch * openssh-7.7p1-pts_names_formatting.patch * openssh-7.7p1-remove_xauth_cookies_on_exit.patch * openssh-7.7p1-seccomp_ipc_flock.patch * openssh-7.7p1-seccomp_stat.patch * openssh-7.7p1-send_locale.patch * openssh-7.7p1-sftp_force_permissions.patch * openssh-7.7p1-sftp_print_diagnostic_messages.patch * openssh-7.7p1-systemd-notify.patch * openssh-7.9p1-keygen-preserve-perms.patch * openssh-7.9p1-revert-new-qos-defaults.patch * openssh-8.0p1-gssapi-keyex.patch * openssh-8.1p1-audit.patch * openssh-8.1p1-seccomp-clock_gettime64.patch * openssh-8.1p1-seccomp-clock_nanosleep.patch * openssh-8.1p1-seccomp-clock_nanosleep_time64.patch * openssh-8.1p1-use-openssl-kdf.patch * openssh-8.4p1-vendordir.patch * openssh-fips-ensure-approved-moduli.patch * openssh-link-with-sk.patch * openssh-reenable-dh-group14-sha1-default.patch * openssh-whitelist-syscalls.patch - Removed openssh-fix-ssh-copy-id.patch (fixed upstream). OBS-URL: https://build.opensuse.org/request/show/922068 OBS-URL: https://build.opensuse.org/package/show/network/openssh?expand=0&rev=235
833 lines
24 KiB
Diff
833 lines
24 KiB
Diff
# HG changeset patch
|
|
# Parent 92d953171b34f6fba18d24085eeeaa24b1d2d5b5
|
|
FIPS 140-2 compliance. Perform selftests on start and use only FIPS approved
|
|
algorithms.
|
|
|
|
Index: openssh-8.8p1/Makefile.in
|
|
===================================================================
|
|
--- openssh-8.8p1.orig/Makefile.in
|
|
+++ openssh-8.8p1/Makefile.in
|
|
@@ -113,6 +113,8 @@ LIBSSH_OBJS=${LIBOPENSSH_OBJS} \
|
|
|
|
SKOBJS= ssh-sk-client.o
|
|
|
|
+LIBSSH_OBJS += fips.o
|
|
+
|
|
SSHOBJS= ssh.o readconf.o clientloop.o sshtty.o \
|
|
sshconnect.o sshconnect2.o mux.o $(SKOBJS)
|
|
|
|
Index: openssh-8.8p1/cipher-ctr.c
|
|
===================================================================
|
|
--- openssh-8.8p1.orig/cipher-ctr.c
|
|
+++ openssh-8.8p1/cipher-ctr.c
|
|
@@ -27,6 +27,8 @@
|
|
#include "xmalloc.h"
|
|
#include "log.h"
|
|
|
|
+#include "fips.h"
|
|
+
|
|
/* compatibility with old or broken OpenSSL versions */
|
|
#include "openbsd-compat/openssl-compat.h"
|
|
|
|
@@ -139,6 +141,8 @@ evp_aes_128_ctr(void)
|
|
#ifndef SSH_OLD_EVP
|
|
aes_ctr.flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH |
|
|
EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CUSTOM_IV;
|
|
+ if (fips_mode())
|
|
+ aes_ctr.flags |= EVP_CIPH_FLAG_FIPS;
|
|
#endif
|
|
return (&aes_ctr);
|
|
}
|
|
Index: openssh-8.8p1/cipher.c
|
|
===================================================================
|
|
--- openssh-8.8p1.orig/cipher.c
|
|
+++ openssh-8.8p1/cipher.c
|
|
@@ -51,6 +51,9 @@
|
|
|
|
#include "openbsd-compat/openssl-compat.h"
|
|
|
|
+#include "fips.h"
|
|
+#include "log.h"
|
|
+
|
|
#ifndef WITH_OPENSSL
|
|
#define EVP_CIPHER_CTX void
|
|
#endif
|
|
@@ -83,7 +86,7 @@ struct sshcipher {
|
|
#endif
|
|
};
|
|
|
|
-static const struct sshcipher ciphers[] = {
|
|
+static const struct sshcipher ciphers_all[] = {
|
|
#ifdef WITH_OPENSSL
|
|
#ifndef OPENSSL_NO_DES
|
|
{ "3des-cbc", 8, 24, 0, 0, CFLAG_CBC, EVP_des_ede3_cbc },
|
|
@@ -112,8 +115,52 @@ static const struct sshcipher ciphers[]
|
|
{ NULL, 0, 0, 0, 0, 0, NULL }
|
|
};
|
|
|
|
+static const struct sshcipher ciphers_fips140_2[] = {
|
|
+#ifdef WITH_OPENSSL
|
|
+ { "aes128-cbc", 16, 16, 0, 0, CFLAG_CBC, EVP_aes_128_cbc },
|
|
+ { "aes192-cbc", 16, 24, 0, 0, CFLAG_CBC, EVP_aes_192_cbc },
|
|
+ { "aes256-cbc", 16, 32, 0, 0, CFLAG_CBC, EVP_aes_256_cbc },
|
|
+ { "rijndael-cbc@lysator.liu.se",
|
|
+ 16, 32, 0, 0, CFLAG_CBC, EVP_aes_256_cbc },
|
|
+ { "aes128-ctr", 16, 16, 0, 0, 0, EVP_aes_128_ctr },
|
|
+ { "aes192-ctr", 16, 24, 0, 0, 0, EVP_aes_192_ctr },
|
|
+ { "aes256-ctr", 16, 32, 0, 0, 0, EVP_aes_256_ctr },
|
|
+# ifdef OPENSSL_HAVE_EVPGCM
|
|
+ { "aes128-gcm@openssh.com",
|
|
+ 16, 16, 12, 16, 0, EVP_aes_128_gcm },
|
|
+ { "aes256-gcm@openssh.com",
|
|
+ 16, 32, 12, 16, 0, EVP_aes_256_gcm },
|
|
+# endif /* OPENSSL_HAVE_EVPGCM */
|
|
+#else
|
|
+ { "aes128-ctr", 16, 16, 0, 0, CFLAG_AESCTR, NULL },
|
|
+ { "aes192-ctr", 16, 24, 0, 0, CFLAG_AESCTR, NULL },
|
|
+ { "aes256-ctr", 16, 32, 0, 0, CFLAG_AESCTR, NULL },
|
|
+#endif
|
|
+ { "none", 8, 0, 0, 0, CFLAG_NONE, NULL },
|
|
+
|
|
+ { NULL, 0, 0, 0, 0, 0, NULL }
|
|
+};
|
|
+
|
|
/*--*/
|
|
|
|
+/* Returns array of ciphers available depending on selected FIPS mode */
|
|
+static const struct sshcipher *
|
|
+fips_select_ciphers(void)
|
|
+{
|
|
+ int fips = fips_mode();
|
|
+ switch (fips) {
|
|
+ case 0:
|
|
+ return ciphers_all;
|
|
+ case 1:
|
|
+ return ciphers_fips140_2;
|
|
+ default:
|
|
+ /* should not be reached */
|
|
+ fatal("Fatal error: incorrect FIPS mode '%i' at %s:%u",
|
|
+ fips, __FILE__, __LINE__);
|
|
+ return NULL;
|
|
+ }
|
|
+}
|
|
+
|
|
/* Returns a comma-separated list of supported ciphers. */
|
|
char *
|
|
cipher_alg_list(char sep, int auth_only)
|
|
@@ -122,7 +169,7 @@ cipher_alg_list(char sep, int auth_only)
|
|
size_t nlen, rlen = 0;
|
|
const struct sshcipher *c;
|
|
|
|
- for (c = ciphers; c->name != NULL; c++) {
|
|
+ for (c = fips_select_ciphers(); c->name != NULL; c++) {
|
|
if ((c->flags & CFLAG_INTERNAL) != 0)
|
|
continue;
|
|
if (auth_only && c->auth_len == 0)
|
|
@@ -205,7 +252,7 @@ const struct sshcipher *
|
|
cipher_by_name(const char *name)
|
|
{
|
|
const struct sshcipher *c;
|
|
- for (c = ciphers; c->name != NULL; c++)
|
|
+ for (c = fips_select_ciphers(); c->name != NULL; c++)
|
|
if (strcmp(c->name, name) == 0)
|
|
return c;
|
|
return NULL;
|
|
Index: openssh-8.8p1/fips.c
|
|
===================================================================
|
|
--- /dev/null
|
|
+++ openssh-8.8p1/fips.c
|
|
@@ -0,0 +1,212 @@
|
|
+/*
|
|
+ * Copyright (c) 2012 Petr Cerny. All rights reserved.
|
|
+ *
|
|
+ * Redistribution and use in source and binary forms, with or without
|
|
+ * modification, are permitted provided that the following conditions
|
|
+ * are met:
|
|
+ * 1. Redistributions of source code must retain the above copyright
|
|
+ * notice, this list of conditions and the following disclaimer.
|
|
+ * 2. Redistributions in binary form must reproduce the above copyright
|
|
+ * notice, this list of conditions and the following disclaimer in the
|
|
+ * documentation and/or other materials provided with the distribution.
|
|
+ *
|
|
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
+ */
|
|
+
|
|
+#include "includes.h"
|
|
+
|
|
+#include "fips.h"
|
|
+
|
|
+#include "cipher.h"
|
|
+#include "dh.h"
|
|
+#include "digest.h"
|
|
+#include "kex.h"
|
|
+#include "sshkey.h"
|
|
+#include "mac.h"
|
|
+#include "log.h"
|
|
+#include "xmalloc.h"
|
|
+
|
|
+#include <string.h>
|
|
+#include <openssl/crypto.h>
|
|
+
|
|
+static int fips_state = -1;
|
|
+
|
|
+static int
|
|
+fips_check_required_env(void)
|
|
+{
|
|
+ int fips_required = 0;
|
|
+ char *env = getenv(SSH_FORCE_FIPS_ENV);
|
|
+
|
|
+ if (env) {
|
|
+ errno = 0;
|
|
+ fips_required = strtol(env, NULL, 10);
|
|
+ if (errno) {
|
|
+ debug("bogus value in the %s environment variable, ignoring\n"
|
|
+ , SSH_FORCE_FIPS_ENV);
|
|
+ fips_required = 0;
|
|
+ } else
|
|
+ fips_required = 1;
|
|
+ }
|
|
+ return fips_required;
|
|
+}
|
|
+
|
|
+int
|
|
+fips_mode(void)
|
|
+{
|
|
+ if (-1 == fips_state) {
|
|
+ fips_state = FIPS_mode();
|
|
+ if (fips_state)
|
|
+ debug("FIPS mode initialized");
|
|
+ else {
|
|
+ if (fips_check_required_env()) {
|
|
+ debug("FIPS mode requested through the environment variable '%s'"
|
|
+ , SSH_FORCE_FIPS_ENV);
|
|
+ if (!FIPS_mode_set(1))
|
|
+ fatal("Unable to enter FIPS mode as requested through the environment variable '%s'"
|
|
+ , SSH_FORCE_FIPS_ENV);
|
|
+ fips_state = 1;
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ return fips_state;
|
|
+}
|
|
+
|
|
+int
|
|
+fips_correct_dgst(int digest)
|
|
+{
|
|
+ int fips;
|
|
+ int rv = -1;
|
|
+
|
|
+ fips = fips_mode();
|
|
+ switch (fips) {
|
|
+ case 0:
|
|
+ rv = digest;
|
|
+ break;
|
|
+ case 1:
|
|
+ switch (digest) {
|
|
+ case SSH_DIGEST_MD5:
|
|
+ case SSH_DIGEST_SHA1:
|
|
+ debug("MD5/RIPEMD160 digests not allowed in FIPS 140-2 mode"
|
|
+ "using SHA-256 instead.");
|
|
+ rv = SSH_DIGEST_SHA256;
|
|
+ break;
|
|
+ default:
|
|
+ rv = digest;
|
|
+ break;
|
|
+ }
|
|
+ break;
|
|
+ default:
|
|
+ /* should not be reached */
|
|
+ fatal("Fatal error: incorrect FIPS mode '%i' at %s:%u",
|
|
+ fips, __FILE__, __LINE__);
|
|
+ }
|
|
+
|
|
+ return rv;
|
|
+}
|
|
+
|
|
+/*
|
|
+ * filter out FIPS disallowed algorithms
|
|
+ * *crypto MUST be free()-able - it is assigned newly allocated memory and
|
|
+ * the previous one is freed
|
|
+ *
|
|
+ * returns zero if all algorithms were rejected, non-zero otherwise
|
|
+ */
|
|
+int
|
|
+fips_filter_crypto(char **crypto, fips_filters filter)
|
|
+{
|
|
+ char *token, *tmp, *tmp_sav, *new;
|
|
+ int plus = 0;
|
|
+ int valid;
|
|
+ int comma = 0;
|
|
+ int empty = 1;
|
|
+ size_t len;
|
|
+
|
|
+ tmp = tmp_sav = xstrdup(*crypto);
|
|
+
|
|
+ len = strlen(tmp) + 1;
|
|
+ new = xcalloc(1, len);
|
|
+
|
|
+ if ('+' == *tmp) {
|
|
+ plus = 1;
|
|
+ tmp++;
|
|
+ }
|
|
+
|
|
+ while ((token = strsep(&tmp, ",")) != NULL) {
|
|
+ switch(filter) {
|
|
+ case FIPS_FILTER_CIPHERS:
|
|
+ valid = ciphers_valid(token);
|
|
+ if (!valid)
|
|
+ debug("Cipher '%s' is not allowed in FIPS mode",
|
|
+ token);
|
|
+ break;
|
|
+ case FIPS_FILTER_MACS:
|
|
+ valid = mac_valid(token);
|
|
+ if (!valid)
|
|
+ debug("MAC '%s' is not allowed in FIPS mode",
|
|
+ token);
|
|
+ break;
|
|
+ case FIPS_FILTER_KEX_ALGS:
|
|
+ valid = kex_names_valid(token);
|
|
+ if (!valid)
|
|
+ debug("KEX '%s' is not allowed in FIPS mode",
|
|
+ token);
|
|
+ break;
|
|
+ default:
|
|
+ /* should not be reached */
|
|
+ fatal("Fatal error: incorrect FIPS filter '%i' requested at %s:%u",
|
|
+ filter, __FILE__, __LINE__);
|
|
+ }
|
|
+
|
|
+ if (valid) {
|
|
+ empty = 0;
|
|
+ if (plus) {
|
|
+ strlcat(new, "+", len);
|
|
+ plus = 0;
|
|
+ }
|
|
+ if (comma)
|
|
+ strlcat(new, ",", len);
|
|
+ else
|
|
+ comma = 1;
|
|
+ strlcat(new, token, len);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ /* free tmp and re-allocate shorter buffer for result if necessary */
|
|
+ free(tmp_sav);
|
|
+ free(*crypto);
|
|
+ *crypto = new;
|
|
+
|
|
+ return (!empty);
|
|
+}
|
|
+
|
|
+int
|
|
+fips_dgst_min(void)
|
|
+{
|
|
+ int fips;
|
|
+ int dgst;
|
|
+
|
|
+ fips = fips_mode();
|
|
+ switch (fips) {
|
|
+ case 0:
|
|
+ dgst = SSH_DIGEST_MD5;
|
|
+ break;
|
|
+ case 1:
|
|
+ dgst = SSH_DIGEST_SHA256;
|
|
+ break;
|
|
+ default:
|
|
+ /* should not be reached */
|
|
+ fatal("Fatal error: incorrect FIPS mode '%i' at %s:%u",
|
|
+ fips, __FILE__, __LINE__);
|
|
+ }
|
|
+ return dgst;
|
|
+}
|
|
+
|
|
Index: openssh-8.8p1/fips.h
|
|
===================================================================
|
|
--- /dev/null
|
|
+++ openssh-8.8p1/fips.h
|
|
@@ -0,0 +1,44 @@
|
|
+/*
|
|
+ * Copyright (c) 2012 Petr Cerny. All rights reserved.
|
|
+ *
|
|
+ * Redistribution and use in source and binary forms, with or without
|
|
+ * modification, are permitted provided that the following conditions
|
|
+ * are met:
|
|
+ * 1. Redistributions of source code must retain the above copyright
|
|
+ * notice, this list of conditions and the following disclaimer.
|
|
+ * 2. Redistributions in binary form must reproduce the above copyright
|
|
+ * notice, this list of conditions and the following disclaimer in the
|
|
+ * documentation and/or other materials provided with the distribution.
|
|
+ *
|
|
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
+ */
|
|
+#ifndef FIPS_H
|
|
+#define FIPS_H
|
|
+
|
|
+#include "sshkey.h"
|
|
+
|
|
+#define SSH_FORCE_FIPS_ENV "SSH_FORCE_FIPS"
|
|
+
|
|
+typedef enum {
|
|
+ FIPS_FILTER_CIPHERS,
|
|
+ FIPS_FILTER_MACS,
|
|
+ FIPS_FILTER_KEX_ALGS
|
|
+} fips_filters;
|
|
+
|
|
+int fips_mode(void);
|
|
+int fips_correct_dgst(int);
|
|
+int fips_dgst_min(void);
|
|
+enum fp_type fips_correct_fp_type(enum fp_type);
|
|
+int fips_filter_crypto(char **, fips_filters);
|
|
+
|
|
+#endif
|
|
+
|
|
Index: openssh-8.8p1/hmac.c
|
|
===================================================================
|
|
--- openssh-8.8p1.orig/hmac.c
|
|
+++ openssh-8.8p1/hmac.c
|
|
@@ -145,7 +145,7 @@ hmac_test(void *key, size_t klen, void *
|
|
size_t i;
|
|
u_char digest[16];
|
|
|
|
- if ((ctx = ssh_hmac_start(SSH_DIGEST_MD5)) == NULL)
|
|
+ if ((ctx = ssh_hmac_start(fips_correct_dgst(SSH_DIGEST_MD5))) == NULL)
|
|
printf("ssh_hmac_start failed");
|
|
if (ssh_hmac_init(ctx, key, klen) < 0 ||
|
|
ssh_hmac_update(ctx, m, mlen) < 0 ||
|
|
Index: openssh-8.8p1/kex.c
|
|
===================================================================
|
|
--- openssh-8.8p1.orig/kex.c
|
|
+++ openssh-8.8p1/kex.c
|
|
@@ -62,6 +62,8 @@
|
|
#include "sshbuf.h"
|
|
#include "digest.h"
|
|
|
|
+#include "fips.h"
|
|
+
|
|
/* prototype */
|
|
static int kex_choose_conf(struct ssh *);
|
|
static int kex_input_newkeys(int, u_int32_t, struct ssh *);
|
|
@@ -85,7 +87,7 @@ struct kexalg {
|
|
int ec_nid;
|
|
int hash_alg;
|
|
};
|
|
-static const struct kexalg kexalgs[] = {
|
|
+static const struct kexalg kexalgs_all[] = {
|
|
#ifdef WITH_OPENSSL
|
|
{ KEX_DH1, KEX_DH_GRP1_SHA1, 0, SSH_DIGEST_SHA1 },
|
|
{ KEX_DH14_SHA1, KEX_DH_GRP14_SHA1, 0, SSH_DIGEST_SHA1 },
|
|
@@ -118,6 +120,47 @@ static const struct kexalg kexalgs[] = {
|
|
{ NULL, 0, -1, -1},
|
|
};
|
|
|
|
+static const struct kexalg kexalgs_fips140_2[] = {
|
|
+#ifdef WITH_OPENSSL
|
|
+ { KEX_DH14_SHA1, KEX_DH_GRP14_SHA1, 0, SSH_DIGEST_SHA1 },
|
|
+ { KEX_DH14_SHA256, KEX_DH_GRP14_SHA256, 0, SSH_DIGEST_SHA256 },
|
|
+ { KEX_DH16_SHA512, KEX_DH_GRP16_SHA512, 0, SSH_DIGEST_SHA512 },
|
|
+ { KEX_DH18_SHA512, KEX_DH_GRP18_SHA512, 0, SSH_DIGEST_SHA512 },
|
|
+ { KEX_DHGEX_SHA1, KEX_DH_GEX_SHA1, 0, SSH_DIGEST_SHA1 },
|
|
+#ifdef HAVE_EVP_SHA256
|
|
+ { KEX_DHGEX_SHA256, KEX_DH_GEX_SHA256, 0, SSH_DIGEST_SHA256 },
|
|
+#endif /* HAVE_EVP_SHA256 */
|
|
+#ifdef OPENSSL_HAS_ECC
|
|
+ { KEX_ECDH_SHA2_NISTP256, KEX_ECDH_SHA2,
|
|
+ NID_X9_62_prime256v1, SSH_DIGEST_SHA256 },
|
|
+ { KEX_ECDH_SHA2_NISTP384, KEX_ECDH_SHA2, NID_secp384r1,
|
|
+ SSH_DIGEST_SHA384 },
|
|
+# ifdef OPENSSL_HAS_NISTP521
|
|
+ { KEX_ECDH_SHA2_NISTP521, KEX_ECDH_SHA2, NID_secp521r1,
|
|
+ SSH_DIGEST_SHA512 },
|
|
+# endif /* OPENSSL_HAS_NISTP521 */
|
|
+#endif /* OPENSSL_HAS_ECC */
|
|
+#endif /* WITH_OPENSSL */
|
|
+ { NULL, -1, -1, -1},
|
|
+};
|
|
+
|
|
+/* Returns array of macs available depending on selected FIPS mode */
|
|
+static const struct kexalg *
|
|
+fips_select_kexalgs(void)
|
|
+{
|
|
+ int fips = fips_mode();
|
|
+ switch (fips) {
|
|
+ case 0:
|
|
+ return kexalgs_all;
|
|
+ case 1:
|
|
+ return kexalgs_fips140_2;
|
|
+ default:
|
|
+ /* should not be reached */
|
|
+ fatal("Fatal error: incorrect FIPS mode '%i' at %s:%u",
|
|
+ fips, __FILE__, __LINE__);
|
|
+ }
|
|
+}
|
|
+
|
|
char *
|
|
kex_alg_list(char sep)
|
|
{
|
|
@@ -125,7 +168,7 @@ kex_alg_list(char sep)
|
|
size_t nlen, rlen = 0;
|
|
const struct kexalg *k;
|
|
|
|
- for (k = kexalgs; k->name != NULL; k++) {
|
|
+ for (k = fips_select_kexalgs(); k->name != NULL; k++) {
|
|
if (ret != NULL)
|
|
ret[rlen++] = sep;
|
|
nlen = strlen(k->name);
|
|
@@ -145,7 +188,7 @@ kex_alg_by_name(const char *name)
|
|
{
|
|
const struct kexalg *k;
|
|
|
|
- for (k = kexalgs; k->name != NULL; k++) {
|
|
+ for (k = fips_select_kexalgs(); k->name != NULL; k++) {
|
|
if (strcmp(k->name, name) == 0)
|
|
return k;
|
|
}
|
|
@@ -165,7 +208,10 @@ kex_names_valid(const char *names)
|
|
for ((p = strsep(&cp, ",")); p && *p != '\0';
|
|
(p = strsep(&cp, ","))) {
|
|
if (kex_alg_by_name(p) == NULL) {
|
|
+ /* do not complain here - MACs and ciphers checks
|
|
+ * are silent here
|
|
error("Unsupported KEX algorithm \"%.100s\"", p);
|
|
+ */
|
|
free(s);
|
|
return 0;
|
|
}
|
|
Index: openssh-8.8p1/mac.c
|
|
===================================================================
|
|
--- openssh-8.8p1.orig/mac.c
|
|
+++ openssh-8.8p1/mac.c
|
|
@@ -41,6 +41,9 @@
|
|
|
|
#include "openbsd-compat/openssl-compat.h"
|
|
|
|
+#include "fips.h"
|
|
+#include "log.h"
|
|
+
|
|
#define SSH_DIGEST 1 /* SSH_DIGEST_XXX */
|
|
#define SSH_UMAC 2 /* UMAC (not integrated with OpenSSL) */
|
|
#define SSH_UMAC128 3
|
|
@@ -55,7 +58,7 @@ struct macalg {
|
|
int etm; /* Encrypt-then-MAC */
|
|
};
|
|
|
|
-static const struct macalg macs[] = {
|
|
+static const struct macalg macs_all[] = {
|
|
/* Encrypt-and-MAC (encrypt-and-authenticate) variants */
|
|
{ "hmac-sha1", SSH_DIGEST, SSH_DIGEST_SHA1, 0, 0, 0, 0 },
|
|
{ "hmac-sha1-96", SSH_DIGEST, SSH_DIGEST_SHA1, 96, 0, 0, 0 },
|
|
@@ -79,6 +82,41 @@ static const struct macalg macs[] = {
|
|
{ NULL, 0, 0, 0, 0, 0, 0 }
|
|
};
|
|
|
|
+static const struct macalg macs_fips140_2[] = {
|
|
+ /* Encrypt-and-MAC (encrypt-and-authenticate) variants */
|
|
+ { "hmac-sha1", SSH_DIGEST, SSH_DIGEST_SHA1, 0, 0, 0, 0 },
|
|
+#ifdef HAVE_EVP_SHA256
|
|
+ { "hmac-sha2-256", SSH_DIGEST, SSH_DIGEST_SHA256, 0, 0, 0, 0 },
|
|
+ { "hmac-sha2-512", SSH_DIGEST, SSH_DIGEST_SHA512, 0, 0, 0, 0 },
|
|
+#endif
|
|
+
|
|
+ /* Encrypt-then-MAC variants */
|
|
+ { "hmac-sha1-etm@openssh.com", SSH_DIGEST, SSH_DIGEST_SHA1, 0, 0, 0, 1 },
|
|
+#ifdef HAVE_EVP_SHA256
|
|
+ { "hmac-sha2-256-etm@openssh.com", SSH_DIGEST, SSH_DIGEST_SHA256, 0, 0, 0, 1 },
|
|
+ { "hmac-sha2-512-etm@openssh.com", SSH_DIGEST, SSH_DIGEST_SHA512, 0, 0, 0, 1 },
|
|
+#endif
|
|
+
|
|
+ { NULL, 0, 0, 0, 0, 0, 0 }
|
|
+};
|
|
+
|
|
+/* Returns array of macs available depending on selected FIPS mode */
|
|
+static const struct macalg *
|
|
+fips_select_macs(void)
|
|
+{
|
|
+ int fips = fips_mode();
|
|
+ switch (fips) {
|
|
+ case 0:
|
|
+ return macs_all;
|
|
+ case 1:
|
|
+ return macs_fips140_2;
|
|
+ default:
|
|
+ /* should not be reached */
|
|
+ fatal("Fatal error: incorrect FIPS mode '%i' at %s:%u",
|
|
+ fips, __FILE__, __LINE__);
|
|
+ }
|
|
+}
|
|
+
|
|
/* Returns a list of supported MACs separated by the specified char. */
|
|
char *
|
|
mac_alg_list(char sep)
|
|
@@ -87,7 +125,7 @@ mac_alg_list(char sep)
|
|
size_t nlen, rlen = 0;
|
|
const struct macalg *m;
|
|
|
|
- for (m = macs; m->name != NULL; m++) {
|
|
+ for (m = fips_select_macs(); m->name != NULL; m++) {
|
|
if (ret != NULL)
|
|
ret[rlen++] = sep;
|
|
nlen = strlen(m->name);
|
|
@@ -126,7 +164,7 @@ mac_setup(struct sshmac *mac, char *name
|
|
{
|
|
const struct macalg *m;
|
|
|
|
- for (m = macs; m->name != NULL; m++) {
|
|
+ for (m = fips_select_macs(); m->name != NULL; m++) {
|
|
if (strcmp(name, m->name) != 0)
|
|
continue;
|
|
if (mac != NULL)
|
|
Index: openssh-8.8p1/readconf.c
|
|
===================================================================
|
|
--- openssh-8.8p1.orig/readconf.c
|
|
+++ openssh-8.8p1/readconf.c
|
|
@@ -68,6 +68,8 @@
|
|
#include "myproposal.h"
|
|
#include "digest.h"
|
|
|
|
+#include "fips.h"
|
|
+
|
|
/* Format of the configuration file:
|
|
|
|
# Configuration data is parsed as follows:
|
|
@@ -2307,6 +2309,23 @@ config_has_permitted_cnames(Options *opt
|
|
return options->num_permitted_cnames > 0;
|
|
}
|
|
|
|
+/* remove algorithms not approved for use in FIPS mode, when running in FIPS
|
|
+ * mode
|
|
+ */
|
|
+void
|
|
+filter_fips_algorithms(Options *o)
|
|
+{
|
|
+ if (fips_mode()) {
|
|
+ if (!fips_filter_crypto(&o->ciphers, FIPS_FILTER_CIPHERS))
|
|
+ fatal("None of selected ciphers can be used in FIPS mode");
|
|
+ if (!fips_filter_crypto(&o->macs, FIPS_FILTER_MACS))
|
|
+ fatal("None of selected MAC algorithms can be used in FIPS mode");
|
|
+ if (!fips_filter_crypto(&o->kex_algorithms, FIPS_FILTER_KEX_ALGS))
|
|
+ fatal("None of selected KEX algorithms can be used in FIPS mode");
|
|
+ }
|
|
+ return;
|
|
+}
|
|
+
|
|
/*
|
|
* Initializes options to special values that indicate that they have not yet
|
|
* been set. Read_config_file will only set options with this value. Options
|
|
@@ -2618,6 +2637,9 @@ fill_default_options(Options * options)
|
|
options->canonicalize_hostname = SSH_CANONICALISE_NO;
|
|
if (options->fingerprint_hash == -1)
|
|
options->fingerprint_hash = SSH_FP_HASH_DEFAULT;
|
|
+ options->fingerprint_hash =
|
|
+ fips_correct_dgst(options->fingerprint_hash);
|
|
+
|
|
#ifdef ENABLE_SK_INTERNAL
|
|
if (options->sk_provider == NULL)
|
|
options->sk_provider = xstrdup("internal");
|
|
@@ -2654,6 +2676,8 @@ fill_default_options(Options * options)
|
|
ASSEMBLE(ca_sign_algorithms, def_sig, all_sig);
|
|
#undef ASSEMBLE
|
|
|
|
+ filter_fips_algorithms(options);
|
|
+
|
|
#define CLEAR_ON_NONE(v) \
|
|
do { \
|
|
if (option_clear_or_none(v)) { \
|
|
Index: openssh-8.8p1/readconf.h
|
|
===================================================================
|
|
--- openssh-8.8p1.orig/readconf.h
|
|
+++ openssh-8.8p1/readconf.h
|
|
@@ -212,6 +212,7 @@ typedef struct {
|
|
#define SSH_STRICT_HOSTKEY_YES 2
|
|
#define SSH_STRICT_HOSTKEY_ASK 3
|
|
|
|
+void filter_fips_algorithms(Options *o);
|
|
const char *kex_default_pk_alg(void);
|
|
char *ssh_connection_hash(const char *thishost, const char *host,
|
|
const char *portstr, const char *user);
|
|
Index: openssh-8.8p1/servconf.c
|
|
===================================================================
|
|
--- openssh-8.8p1.orig/servconf.c
|
|
+++ openssh-8.8p1/servconf.c
|
|
@@ -70,6 +70,7 @@
|
|
#include "auth.h"
|
|
#include "myproposal.h"
|
|
#include "digest.h"
|
|
+#include "fips.h"
|
|
|
|
static void add_listen_addr(ServerOptions *, const char *,
|
|
const char *, int);
|
|
@@ -205,6 +206,23 @@ option_clear_or_none(const char *o)
|
|
return o == NULL || strcasecmp(o, "none") == 0;
|
|
}
|
|
|
|
+/* remove algorithms not approved for use in FIPS mode, when running in FIPS
|
|
+ * mode
|
|
+ */
|
|
+static void
|
|
+filter_fips_algorithms_s(ServerOptions *o)
|
|
+{
|
|
+ if (fips_mode()) {
|
|
+ if (!fips_filter_crypto(&o->ciphers, FIPS_FILTER_CIPHERS))
|
|
+ fatal("None of selected ciphers can be used in FIPS mode");
|
|
+ if (!fips_filter_crypto(&o->macs, FIPS_FILTER_MACS))
|
|
+ fatal("None of selected MAC algorithms can be used in FIPS mode");
|
|
+ if (!fips_filter_crypto(&o->kex_algorithms, FIPS_FILTER_KEX_ALGS))
|
|
+ fatal("None of selected KEX algorithms can be used in FIPS mode");
|
|
+ }
|
|
+ return;
|
|
+}
|
|
+
|
|
static void
|
|
assemble_algorithms(ServerOptions *o)
|
|
{
|
|
@@ -246,6 +264,8 @@ assemble_algorithms(ServerOptions *o)
|
|
free(def_kex);
|
|
free(def_key);
|
|
free(def_sig);
|
|
+
|
|
+ filter_fips_algorithms_s(o);
|
|
}
|
|
|
|
void
|
|
@@ -438,6 +458,8 @@ fill_default_server_options(ServerOption
|
|
options->fwd_opts.streamlocal_bind_unlink = 0;
|
|
if (options->fingerprint_hash == -1)
|
|
options->fingerprint_hash = SSH_FP_HASH_DEFAULT;
|
|
+ options->fingerprint_hash =
|
|
+ fips_correct_dgst(options->fingerprint_hash);
|
|
if (options->disable_forwarding == -1)
|
|
options->disable_forwarding = 0;
|
|
if (options->expose_userauth_info == -1)
|
|
Index: openssh-8.8p1/ssh-keygen.c
|
|
===================================================================
|
|
--- openssh-8.8p1.orig/ssh-keygen.c
|
|
+++ openssh-8.8p1/ssh-keygen.c
|
|
@@ -67,6 +67,8 @@
|
|
#include "sk-api.h" /* XXX for SSH_SK_USER_PRESENCE_REQD; remove */
|
|
#include "cipher.h"
|
|
|
|
+#include "fips.h"
|
|
+
|
|
#ifdef WITH_OPENSSL
|
|
# define DEFAULT_KEY_TYPE_NAME "rsa"
|
|
#else
|
|
@@ -1037,11 +1039,13 @@ do_fingerprint(struct passwd *pw)
|
|
static void
|
|
do_gen_all_hostkeys(struct passwd *pw)
|
|
{
|
|
- struct {
|
|
+ struct Key_types {
|
|
char *key_type;
|
|
char *key_type_display;
|
|
char *path;
|
|
- } key_types[] = {
|
|
+ };
|
|
+
|
|
+ struct Key_types key_types_all[] = {
|
|
#ifdef WITH_OPENSSL
|
|
{ "rsa", "RSA" ,_PATH_HOST_RSA_KEY_FILE },
|
|
{ "dsa", "DSA", _PATH_HOST_DSA_KEY_FILE },
|
|
@@ -1056,6 +1060,17 @@ do_gen_all_hostkeys(struct passwd *pw)
|
|
{ NULL, NULL, NULL }
|
|
};
|
|
|
|
+ struct Key_types key_types_fips140_2[] = {
|
|
+#ifdef WITH_OPENSSL
|
|
+ { "rsa", "RSA" ,_PATH_HOST_RSA_KEY_FILE },
|
|
+#ifdef OPENSSL_HAS_ECC
|
|
+ { "ecdsa", "ECDSA",_PATH_HOST_ECDSA_KEY_FILE },
|
|
+#endif /* OPENSSL_HAS_ECC */
|
|
+#endif /* WITH_OPENSSL */
|
|
+ { NULL, NULL, NULL }
|
|
+ };
|
|
+
|
|
+ struct Key_types *key_types;
|
|
u_int32_t bits = 0;
|
|
int first = 0;
|
|
struct stat st;
|
|
@@ -1063,6 +1078,12 @@ do_gen_all_hostkeys(struct passwd *pw)
|
|
char comment[1024], *prv_tmp, *pub_tmp, *prv_file, *pub_file;
|
|
int i, type, fd, r;
|
|
|
|
+ if (fips_mode()) {
|
|
+ key_types = key_types_fips140_2;
|
|
+ } else {
|
|
+ key_types = key_types_all;
|
|
+ }
|
|
+
|
|
for (i = 0; key_types[i].key_type; i++) {
|
|
public = private = NULL;
|
|
prv_tmp = pub_tmp = prv_file = pub_file = NULL;
|
|
@@ -3620,6 +3641,15 @@ main(int argc, char **argv)
|
|
key_type_name = DEFAULT_KEY_TYPE_NAME;
|
|
|
|
type = sshkey_type_from_name(key_type_name);
|
|
+
|
|
+ /* protocol v1 is not allowed in FIPS mode, DSA is not acceptable because
|
|
+ * it has to be 1024 bit due to RFC 4253 using SHA-1 which implies 1024 bit
|
|
+ * keys due to FIPS-186 specification for DSS */
|
|
+ if (fips_mode() &&
|
|
+ (type == KEY_DSA || type == KEY_ED25519 ||
|
|
+ type == KEY_DSA_CERT || type == KEY_ED25519_CERT))
|
|
+ fatal("Key type %s not alowed in FIPS mode", key_type_name);
|
|
+
|
|
type_bits_valid(type, key_type_name, &bits);
|
|
|
|
if (!quiet)
|
|
Index: openssh-8.8p1/ssh_config.5
|
|
===================================================================
|
|
--- openssh-8.8p1.orig/ssh_config.5
|
|
+++ openssh-8.8p1/ssh_config.5
|
|
@@ -736,6 +736,8 @@ The argument to this keyword must be
|
|
option) or
|
|
.Cm no
|
|
(the default).
|
|
+.Pp
|
|
+In the FIPS mode the minimum of SHA-1 is enforced (which means sha256).
|
|
.It Cm ForwardAgent
|
|
Specifies whether the connection to the authentication agent (if any)
|
|
will be forwarded to the remote machine.
|
|
Index: openssh-8.8p1/sshd.c
|
|
===================================================================
|
|
--- openssh-8.8p1.orig/sshd.c
|
|
+++ openssh-8.8p1/sshd.c
|
|
@@ -126,6 +126,8 @@
|
|
#include "srclimit.h"
|
|
#include "dh.h"
|
|
|
|
+#include "fips.h"
|
|
+
|
|
/* Re-exec fds */
|
|
#define REEXEC_DEVCRYPTO_RESERVED_FD (STDERR_FILENO + 1)
|
|
#define REEXEC_STARTUP_PIPE_FD (STDERR_FILENO + 2)
|
|
Index: openssh-8.8p1/sshd_config.5
|
|
===================================================================
|
|
--- openssh-8.8p1.orig/sshd_config.5
|
|
+++ openssh-8.8p1/sshd_config.5
|
|
@@ -600,6 +600,8 @@ and
|
|
.Cm sha256 .
|
|
The default is
|
|
.Cm sha256 .
|
|
+.Pp
|
|
+In the FIPS mode the minimum of SHA-1 is enforced (which means sha256).
|
|
.It Cm ForceCommand
|
|
Forces the execution of the command specified by
|
|
.Cm ForceCommand ,
|