2018-08-08 08:17:43 +00:00
|
|
|
diff -up openssh-7.7p1/cipher.c.fips openssh-7.7p1/cipher.c
|
|
|
|
--- openssh-7.7p1/cipher.c.fips 2018-08-08 10:08:40.814719906 +0200
|
|
|
|
+++ openssh-7.7p1/cipher.c 2018-08-08 10:08:40.821719965 +0200
|
2014-07-09 19:16:53 +00:00
|
|
|
@@ -39,6 +39,8 @@
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
+#include <openssl/fips.h>
|
|
|
|
+
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
2018-08-08 08:17:43 +00:00
|
|
|
@@ -90,6 +92,33 @@ static const struct sshcipher ciphers[]
|
2017-09-26 12:04:45 +00:00
|
|
|
{ NULL, 0, 0, 0, 0, 0, NULL }
|
2014-07-09 19:16:53 +00:00
|
|
|
};
|
|
|
|
|
2015-01-20 12:18:45 +00:00
|
|
|
+static const struct sshcipher fips_ciphers[] = {
|
2017-09-26 12:04:45 +00:00
|
|
|
+#ifdef WITH_OPENSSL
|
|
|
|
+ { "3des-cbc", 8, 24, 0, 0, CFLAG_CBC, EVP_des_ede3_cbc },
|
|
|
|
+ { "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 },
|
2014-07-09 19:16:53 +00:00
|
|
|
+ { "rijndael-cbc@lysator.liu.se",
|
2017-09-26 12:04:45 +00:00
|
|
|
+ 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 },
|
2018-08-07 16:08:08 +00:00
|
|
|
+# 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 */
|
2017-09-26 12:04:45 +00:00
|
|
|
+#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 }
|
2014-07-09 19:16:53 +00:00
|
|
|
+};
|
2015-01-20 12:18:45 +00:00
|
|
|
+
|
2014-07-09 19:16:53 +00:00
|
|
|
/*--*/
|
|
|
|
|
2015-01-20 12:18:45 +00:00
|
|
|
/* Returns a comma-separated list of supported ciphers. */
|
2018-08-08 08:17:43 +00:00
|
|
|
@@ -100,7 +129,7 @@ cipher_alg_list(char sep, int auth_only)
|
2014-07-09 19:16:53 +00:00
|
|
|
size_t nlen, rlen = 0;
|
2015-01-20 12:18:45 +00:00
|
|
|
const struct sshcipher *c;
|
2014-07-09 19:16:53 +00:00
|
|
|
|
|
|
|
- for (c = ciphers; c->name != NULL; c++) {
|
|
|
|
+ for (c = FIPS_mode() ? fips_ciphers : ciphers; c->name != NULL; c++) {
|
2017-09-26 12:04:45 +00:00
|
|
|
if ((c->flags & CFLAG_INTERNAL) != 0)
|
2014-07-09 19:16:53 +00:00
|
|
|
continue;
|
|
|
|
if (auth_only && c->auth_len == 0)
|
2018-08-08 08:17:43 +00:00
|
|
|
@@ -172,7 +201,7 @@ const struct sshcipher *
|
2014-07-09 19:16:53 +00:00
|
|
|
cipher_by_name(const char *name)
|
|
|
|
{
|
2015-01-20 12:18:45 +00:00
|
|
|
const struct sshcipher *c;
|
2014-07-09 19:16:53 +00:00
|
|
|
- for (c = ciphers; c->name != NULL; c++)
|
|
|
|
+ for (c = FIPS_mode() ? fips_ciphers : ciphers; c->name != NULL; c++)
|
|
|
|
if (strcmp(c->name, name) == 0)
|
|
|
|
return c;
|
|
|
|
return NULL;
|
2018-08-08 08:17:43 +00:00
|
|
|
diff -up openssh-7.7p1/cipher-ctr.c.fips openssh-7.7p1/cipher-ctr.c
|
|
|
|
--- openssh-7.7p1/cipher-ctr.c.fips 2018-08-08 10:08:40.709719021 +0200
|
|
|
|
+++ openssh-7.7p1/cipher-ctr.c 2018-08-08 10:08:40.821719965 +0200
|
2015-06-24 12:11:59 +00:00
|
|
|
@@ -179,7 +179,8 @@ evp_aes_128_ctr(void)
|
|
|
|
aes_ctr.do_cipher = ssh_aes_ctr;
|
|
|
|
#ifndef SSH_OLD_EVP
|
|
|
|
aes_ctr.flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH |
|
|
|
|
- EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CUSTOM_IV;
|
|
|
|
+ EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CUSTOM_IV |
|
|
|
|
+ EVP_CIPH_FLAG_FIPS;
|
|
|
|
#endif
|
|
|
|
return (&aes_ctr);
|
|
|
|
}
|
2018-08-08 08:17:43 +00:00
|
|
|
diff -up openssh-7.7p1/clientloop.c.fips openssh-7.7p1/clientloop.c
|
|
|
|
--- openssh-7.7p1/clientloop.c.fips 2018-08-08 10:08:40.769719527 +0200
|
|
|
|
+++ openssh-7.7p1/clientloop.c 2018-08-08 10:08:40.822719973 +0200
|
|
|
|
@@ -1978,7 +1978,8 @@ key_accepted_by_hostkeyalgs(const struct
|
2017-06-30 10:18:02 +00:00
|
|
|
{
|
|
|
|
const char *ktype = sshkey_ssh_name(key);
|
|
|
|
const char *hostkeyalgs = options.hostkeyalgorithms != NULL ?
|
|
|
|
- options.hostkeyalgorithms : KEX_DEFAULT_PK_ALG;
|
|
|
|
+ options.hostkeyalgorithms : (FIPS_mode() ?
|
|
|
|
+ KEX_FIPS_PK_ALG : KEX_DEFAULT_PK_ALG);
|
|
|
|
|
|
|
|
if (key == NULL || key->type == KEY_UNSPEC)
|
|
|
|
return 0;
|
2018-08-08 08:17:43 +00:00
|
|
|
diff -up openssh-7.7p1/dh.h.fips openssh-7.7p1/dh.h
|
|
|
|
--- openssh-7.7p1/dh.h.fips 2018-04-02 07:38:28.000000000 +0200
|
|
|
|
+++ openssh-7.7p1/dh.h 2018-08-08 10:08:40.822719973 +0200
|
2017-01-02 14:42:13 +00:00
|
|
|
@@ -51,6 +51,7 @@ u_int dh_estimate(int);
|
2016-02-29 14:16:45 +00:00
|
|
|
* Miniumum increased in light of DH precomputation attacks.
|
|
|
|
*/
|
2016-02-19 13:42:33 +00:00
|
|
|
#define DH_GRP_MIN 2048
|
2014-07-09 19:16:53 +00:00
|
|
|
+#define DH_GRP_MIN_FIPS 2048
|
|
|
|
#define DH_GRP_MAX 8192
|
|
|
|
|
|
|
|
/*
|
2018-08-08 08:17:43 +00:00
|
|
|
diff -up openssh-7.7p1/entropy.c.fips openssh-7.7p1/entropy.c
|
|
|
|
--- openssh-7.7p1/entropy.c.fips 2018-08-08 10:08:40.698718928 +0200
|
|
|
|
+++ openssh-7.7p1/entropy.c 2018-08-08 10:08:40.822719973 +0200
|
2018-10-12 13:54:56 +00:00
|
|
|
@@ -217,6 +217,11 @@ seed_rng(void)
|
2014-07-09 19:16:53 +00:00
|
|
|
fatal("OpenSSL version mismatch. Built against %lx, you "
|
|
|
|
"have %lx", (u_long)OPENSSL_VERSION_NUMBER, SSLeay());
|
|
|
|
|
|
|
|
+ /* clean the PRNG status when exiting the program */
|
2018-10-12 13:54:56 +00:00
|
|
|
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
2014-07-09 19:16:53 +00:00
|
|
|
+ atexit(RAND_cleanup);
|
2018-10-12 13:54:56 +00:00
|
|
|
+#endif
|
2014-07-09 19:16:53 +00:00
|
|
|
+
|
|
|
|
#ifndef OPENSSL_PRNG_ONLY
|
|
|
|
if (RAND_status() == 1) {
|
|
|
|
debug3("RNG is ready, skipping seeding");
|
2018-08-08 08:17:43 +00:00
|
|
|
diff -up openssh-7.7p1/kex.c.fips openssh-7.7p1/kex.c
|
|
|
|
--- openssh-7.7p1/kex.c.fips 2018-08-08 10:08:40.815719915 +0200
|
|
|
|
+++ openssh-7.7p1/kex.c 2018-08-08 10:11:24.109081924 +0200
|
2015-01-20 12:18:45 +00:00
|
|
|
@@ -35,6 +35,7 @@
|
|
|
|
#ifdef WITH_OPENSSL
|
2014-07-09 19:16:53 +00:00
|
|
|
#include <openssl/crypto.h>
|
2016-07-25 14:21:15 +00:00
|
|
|
#include <openssl/dh.h>
|
2014-07-09 19:16:53 +00:00
|
|
|
+#include <openssl/fips.h>
|
2015-01-20 12:18:45 +00:00
|
|
|
#endif
|
2014-07-09 19:16:53 +00:00
|
|
|
|
2015-03-20 13:56:04 +00:00
|
|
|
#include "ssh2.h"
|
2018-08-08 08:17:43 +00:00
|
|
|
@@ -122,6 +123,26 @@ static const struct kexalg kexalgs[] = {
|
2014-07-09 19:16:53 +00:00
|
|
|
{ NULL, -1, -1, -1},
|
|
|
|
};
|
|
|
|
|
|
|
|
+static const struct kexalg kexalgs_fips[] = {
|
2017-03-08 13:37:07 +00:00
|
|
|
+ { 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 },
|
2014-07-09 19:16:53 +00:00
|
|
|
+#ifdef HAVE_EVP_SHA256
|
|
|
|
+ { KEX_DHGEX_SHA256, KEX_DH_GEX_SHA256, 0, SSH_DIGEST_SHA256 },
|
|
|
|
+#endif
|
|
|
|
+#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
|
|
|
|
+#endif
|
2015-01-30 13:27:43 +00:00
|
|
|
+ { NULL, -1, -1, -1},
|
2014-07-09 19:16:53 +00:00
|
|
|
+};
|
|
|
|
+
|
|
|
|
char *
|
|
|
|
kex_alg_list(char sep)
|
|
|
|
{
|
2018-08-08 08:17:43 +00:00
|
|
|
@@ -129,7 +150,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_mode() ? kexalgs_fips : kexalgs); k->name != NULL; k++) {
|
|
|
|
if (ret != NULL)
|
|
|
|
ret[rlen++] = sep;
|
|
|
|
nlen = strlen(k->name);
|
|
|
|
@@ -149,7 +170,7 @@ kex_alg_by_name(const char *name)
|
2014-07-09 19:16:53 +00:00
|
|
|
{
|
|
|
|
const struct kexalg *k;
|
|
|
|
|
|
|
|
- for (k = kexalgs; k->name != NULL; k++) {
|
|
|
|
+ for (k = (FIPS_mode() ? kexalgs_fips : kexalgs); k->name != NULL; k++) {
|
|
|
|
if (strcmp(k->name, name) == 0)
|
|
|
|
return k;
|
|
|
|
#ifdef GSSAPI
|
2018-08-08 08:17:43 +00:00
|
|
|
@@ -175,7 +196,10 @@ kex_names_valid(const char *names)
|
2014-07-09 19:16:53 +00:00
|
|
|
for ((p = strsep(&cp, ",")); p && *p != '\0';
|
|
|
|
(p = strsep(&cp, ","))) {
|
|
|
|
if (kex_alg_by_name(p) == NULL) {
|
|
|
|
- error("Unsupported KEX algorithm \"%.100s\"", p);
|
|
|
|
+ if (FIPS_mode())
|
|
|
|
+ error("\"%.100s\" is not allowed in FIPS mode", p);
|
|
|
|
+ else
|
|
|
|
+ error("Unsupported KEX algorithm \"%.100s\"", p);
|
|
|
|
free(s);
|
|
|
|
return 0;
|
|
|
|
}
|
2018-08-08 08:17:43 +00:00
|
|
|
diff -up openssh-7.7p1/kexgexc.c.fips openssh-7.7p1/kexgexc.c
|
|
|
|
--- openssh-7.7p1/kexgexc.c.fips 2018-04-02 07:38:28.000000000 +0200
|
|
|
|
+++ openssh-7.7p1/kexgexc.c 2018-08-08 10:08:40.822719973 +0200
|
2015-06-24 12:11:59 +00:00
|
|
|
@@ -28,6 +28,7 @@
|
2014-07-09 19:16:53 +00:00
|
|
|
|
2015-03-20 13:56:04 +00:00
|
|
|
#ifdef WITH_OPENSSL
|
2014-07-09 19:16:53 +00:00
|
|
|
|
|
|
|
+#include <openssl/fips.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
2017-01-02 14:42:13 +00:00
|
|
|
#include <openssl/dh.h>
|
2015-06-24 12:11:59 +00:00
|
|
|
@@ -63,7 +64,7 @@ kexgex_client(struct ssh *ssh)
|
2015-03-20 13:56:04 +00:00
|
|
|
|
|
|
|
nbits = dh_estimate(kex->dh_need * 8);
|
2014-12-01 15:48:15 +00:00
|
|
|
|
2015-03-20 13:56:04 +00:00
|
|
|
- kex->min = DH_GRP_MIN;
|
|
|
|
+ kex->min = FIPS_mode() ? DH_GRP_MIN_FIPS : DH_GRP_MIN;
|
|
|
|
kex->max = DH_GRP_MAX;
|
2015-06-24 12:11:59 +00:00
|
|
|
kex->nbits = nbits;
|
|
|
|
if (datafellows & SSH_BUG_DHGEX_LARGE)
|
2018-08-08 08:17:43 +00:00
|
|
|
diff -up openssh-7.7p1/kexgexs.c.fips openssh-7.7p1/kexgexs.c
|
|
|
|
--- openssh-7.7p1/kexgexs.c.fips 2018-04-02 07:38:28.000000000 +0200
|
|
|
|
+++ openssh-7.7p1/kexgexs.c 2018-08-08 10:08:40.823719982 +0200
|
|
|
|
@@ -82,9 +82,9 @@ input_kex_dh_gex_request(int type, u_int
|
2015-06-24 12:11:59 +00:00
|
|
|
kex->nbits = nbits;
|
2016-02-29 14:16:45 +00:00
|
|
|
kex->min = min;
|
2015-06-24 12:11:59 +00:00
|
|
|
kex->max = max;
|
2017-01-02 14:42:13 +00:00
|
|
|
- min = MAXIMUM(DH_GRP_MIN, min);
|
|
|
|
+ min = MAXIMUM(FIPS_mode() ? DH_GRP_MIN_FIPS : DH_GRP_MIN, min);
|
|
|
|
max = MINIMUM(DH_GRP_MAX, max);
|
|
|
|
- nbits = MAXIMUM(DH_GRP_MIN, nbits);
|
|
|
|
+ nbits = MAXIMUM(FIPS_mode() ? DH_GRP_MIN_FIPS : DH_GRP_MIN, nbits);
|
|
|
|
nbits = MINIMUM(DH_GRP_MAX, nbits);
|
2015-06-24 12:11:59 +00:00
|
|
|
|
|
|
|
if (kex->max < kex->min || kex->nbits < kex->min ||
|
2018-08-08 08:17:43 +00:00
|
|
|
diff -up openssh-7.7p1/mac.c.fips openssh-7.7p1/mac.c
|
|
|
|
--- openssh-7.7p1/mac.c.fips 2018-08-08 10:08:40.815719915 +0200
|
|
|
|
+++ openssh-7.7p1/mac.c 2018-08-08 10:11:56.915352642 +0200
|
2014-07-09 19:16:53 +00:00
|
|
|
@@ -27,6 +27,8 @@
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
+#include <openssl/fips.h>
|
|
|
|
+
|
|
|
|
#include <string.h>
|
2015-03-20 13:56:04 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
@@ -54,7 +56,7 @@ struct macalg {
|
2014-07-09 19:16:53 +00:00
|
|
|
int etm; /* Encrypt-then-MAC */
|
|
|
|
};
|
|
|
|
|
|
|
|
-static const struct macalg macs[] = {
|
|
|
|
+static const struct macalg all_macs[] = {
|
|
|
|
/* 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 },
|
2018-08-08 08:17:43 +00:00
|
|
|
@@ -82,6 +84,24 @@ static const struct macalg macs[] = {
|
2014-07-09 19:16:53 +00:00
|
|
|
{ NULL, 0, 0, 0, 0, 0, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
+static const struct macalg fips_macs[] = {
|
|
|
|
+ /* 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 a list of supported MACs separated by the specified char. */
|
|
|
|
char *
|
|
|
|
mac_alg_list(char sep)
|
2018-08-08 08:17:43 +00:00
|
|
|
@@ -90,7 +110,7 @@ mac_alg_list(char sep)
|
2014-07-09 19:16:53 +00:00
|
|
|
size_t nlen, rlen = 0;
|
|
|
|
const struct macalg *m;
|
|
|
|
|
|
|
|
- for (m = macs; m->name != NULL; m++) {
|
|
|
|
+ for (m = FIPS_mode() ? fips_macs : all_macs; m->name != NULL; m++) {
|
|
|
|
if (ret != NULL)
|
|
|
|
ret[rlen++] = sep;
|
|
|
|
nlen = strlen(m->name);
|
2018-08-08 08:17:43 +00:00
|
|
|
@@ -129,7 +149,7 @@ mac_setup(struct sshmac *mac, char *name
|
2014-07-09 19:16:53 +00:00
|
|
|
{
|
|
|
|
const struct macalg *m;
|
|
|
|
|
|
|
|
- for (m = macs; m->name != NULL; m++) {
|
|
|
|
+ for (m = FIPS_mode() ? fips_macs : all_macs; m->name != NULL; m++) {
|
|
|
|
if (strcmp(name, m->name) != 0)
|
|
|
|
continue;
|
2015-03-20 13:56:04 +00:00
|
|
|
if (mac != NULL)
|
2018-08-08 08:17:43 +00:00
|
|
|
diff -up openssh-7.7p1/Makefile.in.fips openssh-7.7p1/Makefile.in
|
|
|
|
--- openssh-7.7p1/Makefile.in.fips 2018-08-08 10:08:40.815719915 +0200
|
|
|
|
+++ openssh-7.7p1/Makefile.in 2018-08-08 10:08:40.823719982 +0200
|
|
|
|
@@ -179,25 +179,25 @@ libssh.a: $(LIBSSH_OBJS)
|
2015-06-24 12:11:59 +00:00
|
|
|
$(RANLIB) $@
|
|
|
|
|
|
|
|
ssh$(EXEEXT): $(LIBCOMPAT) libssh.a $(SSHOBJS)
|
|
|
|
- $(LD) -o $@ $(SSHOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(SSHLIBS) $(LIBS) $(GSSLIBS)
|
|
|
|
+ $(LD) -o $@ $(SSHOBJS) $(LDFLAGS) -lssh -lopenbsd-compat -lfipscheck $(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 -lfipscheck $(SSHDLIBS) $(LIBS) $(GSSLIBS) $(K5LIBS)
|
|
|
|
|
2016-07-25 14:21:15 +00:00
|
|
|
scp$(EXEEXT): $(LIBCOMPAT) libssh.a scp.o progressmeter.o
|
2018-08-24 20:40:20 +00:00
|
|
|
$(LD) -o $@ scp.o progressmeter.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
|
2015-06-24 12:11:59 +00:00
|
|
|
|
|
|
|
ssh-add$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-add.o
|
|
|
|
- $(LD) -o $@ ssh-add.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
|
|
|
|
+ $(LD) -o $@ ssh-add.o $(LDFLAGS) -lssh -lopenbsd-compat -lfipscheck $(LIBS)
|
|
|
|
|
|
|
|
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)
|
|
|
|
+ $(LD) -o $@ ssh-agent.o ssh-pkcs11-client.o $(LDFLAGS) -lssh -lopenbsd-compat -lfipscheck $(LIBS)
|
|
|
|
|
|
|
|
ssh-keygen$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keygen.o
|
|
|
|
- $(LD) -o $@ ssh-keygen.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
|
|
|
|
+ $(LD) -o $@ ssh-keygen.o $(LDFLAGS) -lssh -lopenbsd-compat -lfipscheck $(LIBS)
|
|
|
|
|
2018-08-24 20:40:20 +00:00
|
|
|
ssh-keysign$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keysign.o readconf.o uidswap.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 -lfipscheck $(LIBS)
|
2015-06-24 12:11:59 +00:00
|
|
|
|
|
|
|
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)
|
2018-08-08 08:17:43 +00:00
|
|
|
@@ -215,7 +215,7 @@ ssh-cavs$(EXEEXT): $(LIBCOMPAT) libssh.a
|
2016-02-19 13:42:33 +00:00
|
|
|
$(LD) -o $@ ssh-cavs.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
|
2015-06-24 12:11:59 +00:00
|
|
|
|
2016-02-19 13:42:33 +00:00
|
|
|
ssh-keyscan$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keyscan.o
|
|
|
|
- $(LD) -o $@ ssh-keyscan.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh $(LIBS)
|
|
|
|
+ $(LD) -o $@ ssh-keyscan.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh -lfipscheck $(LIBS)
|
2015-06-24 12:11:59 +00:00
|
|
|
|
|
|
|
sftp-server$(EXEEXT): $(LIBCOMPAT) libssh.a sftp.o sftp-common.o sftp-server.o sftp-server-main.o
|
|
|
|
$(LD) -o $@ sftp-server.o sftp-common.o sftp-server-main.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
|
2018-08-08 08:17:43 +00:00
|
|
|
diff -up openssh-7.7p1/myproposal.h.fips openssh-7.7p1/myproposal.h
|
|
|
|
--- openssh-7.7p1/myproposal.h.fips 2018-04-02 07:38:28.000000000 +0200
|
|
|
|
+++ openssh-7.7p1/myproposal.h 2018-08-08 10:08:40.823719982 +0200
|
2017-06-30 10:18:02 +00:00
|
|
|
@@ -114,6 +114,14 @@
|
|
|
|
"rsa-sha2-256," \
|
|
|
|
"ssh-rsa"
|
|
|
|
|
|
|
|
+#define KEX_FIPS_PK_ALG \
|
|
|
|
+ HOSTKEY_ECDSA_CERT_METHODS \
|
|
|
|
+ "ssh-rsa-cert-v01@openssh.com," \
|
|
|
|
+ HOSTKEY_ECDSA_METHODS \
|
|
|
|
+ "rsa-sha2-512," \
|
|
|
|
+ "rsa-sha2-256," \
|
|
|
|
+ "ssh-rsa"
|
|
|
|
+
|
|
|
|
/* the actual algorithms */
|
|
|
|
|
|
|
|
#define KEX_SERVER_ENCRYPT \
|
2018-08-08 08:17:43 +00:00
|
|
|
@@ -137,6 +145,38 @@
|
2016-02-29 14:16:45 +00:00
|
|
|
|
|
|
|
#define KEX_CLIENT_MAC KEX_SERVER_MAC
|
2014-07-09 19:16:53 +00:00
|
|
|
|
|
|
|
+#define KEX_FIPS_ENCRYPT \
|
|
|
|
+ "aes128-ctr,aes192-ctr,aes256-ctr," \
|
|
|
|
+ "aes128-cbc,3des-cbc," \
|
2018-08-07 16:08:08 +00:00
|
|
|
+ "aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se" \
|
|
|
|
+ AESGCM_CIPHER_MODES
|
2014-07-09 19:16:53 +00:00
|
|
|
+#ifdef HAVE_EVP_SHA256
|
2017-04-26 12:26:25 +00:00
|
|
|
+# define KEX_DEFAULT_KEX_FIPS \
|
|
|
|
+ KEX_ECDH_METHODS \
|
|
|
|
+ KEX_SHA2_METHODS \
|
|
|
|
+ "diffie-hellman-group14-sha256"
|
|
|
|
+# define KEX_FIPS_MAC \
|
2014-07-09 19:16:53 +00:00
|
|
|
+ "hmac-sha1," \
|
|
|
|
+ "hmac-sha2-256," \
|
|
|
|
+ "hmac-sha2-512," \
|
|
|
|
+ "hmac-sha1-etm@openssh.com," \
|
|
|
|
+ "hmac-sha2-256-etm@openssh.com," \
|
|
|
|
+ "hmac-sha2-512-etm@openssh.com"
|
|
|
|
+#else
|
2017-04-26 12:26:25 +00:00
|
|
|
+# ifdef OPENSSL_HAS_NISTP521
|
|
|
|
+# define KEX_DEFAULT_KEX_FIPS \
|
|
|
|
+ "ecdh-sha2-nistp256," \
|
|
|
|
+ "ecdh-sha2-nistp384," \
|
|
|
|
+ "ecdh-sha2-nistp521"
|
|
|
|
+# else
|
|
|
|
+# define KEX_DEFAULT_KEX_FIPS \
|
|
|
|
+ "ecdh-sha2-nistp256," \
|
|
|
|
+ "ecdh-sha2-nistp384"
|
|
|
|
+# endif
|
2014-07-09 19:16:53 +00:00
|
|
|
+#define KEX_FIPS_MAC \
|
|
|
|
+ "hmac-sha1"
|
|
|
|
+#endif
|
2015-01-20 12:18:45 +00:00
|
|
|
+
|
2018-10-12 13:54:56 +00:00
|
|
|
/* Not a KEX value, but here so all the algorithm defaults are together */
|
|
|
|
#define SSH_ALLOWED_CA_SIGALGS \
|
|
|
|
"ecdsa-sha2-nistp256," \
|
2018-08-08 08:17:43 +00:00
|
|
|
diff -up openssh-7.7p1/readconf.c.fips openssh-7.7p1/readconf.c
|
|
|
|
--- openssh-7.7p1/readconf.c.fips 2018-08-08 10:08:40.769719527 +0200
|
|
|
|
+++ openssh-7.7p1/readconf.c 2018-08-08 10:08:40.824719990 +0200
|
2018-10-12 13:54:56 +00:00
|
|
|
@@ -2081,18 +2081,19 @@ fill_default_options(Options * options)
|
2018-08-24 20:40:20 +00:00
|
|
|
all_kex = kex_alg_list(',');
|
|
|
|
all_key = sshkey_alg_list(0, 0, 1, ',');
|
2018-10-12 13:54:56 +00:00
|
|
|
all_sig = sshkey_alg_list(0, 1, 1, ',');
|
2018-08-24 20:40:20 +00:00
|
|
|
-#define ASSEMBLE(what, defaults, all) \
|
|
|
|
+#define ASSEMBLE(what, defaults, fips_defaults, all) \
|
|
|
|
do { \
|
|
|
|
if ((r = kex_assemble_names(&options->what, \
|
|
|
|
- defaults, all)) != 0) \
|
|
|
|
+ (FIPS_mode() ? fips_defaults : defaults), \
|
|
|
|
+ all)) != 0) \
|
|
|
|
fatal("%s: %s: %s", __func__, #what, ssh_err(r)); \
|
|
|
|
} while (0)
|
|
|
|
- ASSEMBLE(ciphers, KEX_SERVER_ENCRYPT, all_cipher);
|
|
|
|
- ASSEMBLE(macs, KEX_SERVER_MAC, all_mac);
|
|
|
|
- ASSEMBLE(kex_algorithms, KEX_SERVER_KEX, all_kex);
|
|
|
|
- ASSEMBLE(hostbased_key_types, KEX_DEFAULT_PK_ALG, all_key);
|
|
|
|
- ASSEMBLE(pubkey_key_types, KEX_DEFAULT_PK_ALG, all_key);
|
2018-10-12 13:54:56 +00:00
|
|
|
- ASSEMBLE(ca_sign_algorithms, SSH_ALLOWED_CA_SIGALGS, all_sig);
|
2018-08-24 20:40:20 +00:00
|
|
|
+ ASSEMBLE(ciphers, KEX_SERVER_ENCRYPT, KEX_FIPS_ENCRYPT, all_cipher);
|
|
|
|
+ ASSEMBLE(macs, KEX_SERVER_MAC, KEX_FIPS_MAC, all_mac);
|
|
|
|
+ ASSEMBLE(kex_algorithms, KEX_SERVER_KEX, KEX_DEFAULT_KEX_FIPS, all_kex);
|
|
|
|
+ ASSEMBLE(hostbased_key_types, KEX_DEFAULT_PK_ALG, KEX_FIPS_PK_ALG, all_key);
|
|
|
|
+ ASSEMBLE(pubkey_key_types, KEX_DEFAULT_PK_ALG, KEX_FIPS_PK_ALG, all_key);
|
2018-10-12 13:54:56 +00:00
|
|
|
+ ASSEMBLE(ca_sign_algorithms, SSH_ALLOWED_CA_SIGALGS, KEX_FIPS_PK_ALG, all_sig);
|
2018-08-24 20:40:20 +00:00
|
|
|
#undef ASSEMBLE
|
|
|
|
free(all_cipher);
|
|
|
|
free(all_mac);
|
2018-08-08 08:17:43 +00:00
|
|
|
diff -up openssh-7.7p1/sandbox-seccomp-filter.c.fips openssh-7.7p1/sandbox-seccomp-filter.c
|
|
|
|
--- openssh-7.7p1/sandbox-seccomp-filter.c.fips 2018-08-08 10:08:40.794719737 +0200
|
|
|
|
+++ openssh-7.7p1/sandbox-seccomp-filter.c 2018-08-08 10:08:40.824719990 +0200
|
2017-06-30 10:18:02 +00:00
|
|
|
@@ -137,6 +137,9 @@ static const struct sock_filter preauth_
|
2017-01-02 14:42:13 +00:00
|
|
|
#ifdef __NR_open
|
2017-03-20 14:55:43 +00:00
|
|
|
SC_DENY(__NR_open, EACCES),
|
2017-01-02 14:42:13 +00:00
|
|
|
#endif
|
|
|
|
+#ifdef __NR_socket
|
2017-03-20 14:55:43 +00:00
|
|
|
+ SC_DENY(__NR_socket, EACCES),
|
2017-01-02 14:42:13 +00:00
|
|
|
+#endif
|
|
|
|
#ifdef __NR_openat
|
2017-03-20 14:55:43 +00:00
|
|
|
SC_DENY(__NR_openat, EACCES),
|
2017-01-02 14:42:13 +00:00
|
|
|
#endif
|
2018-08-08 08:17:43 +00:00
|
|
|
diff -up openssh-7.7p1/servconf.c.fips openssh-7.7p1/servconf.c
|
|
|
|
--- openssh-7.7p1/servconf.c.fips 2018-08-08 10:08:40.778719603 +0200
|
|
|
|
+++ openssh-7.7p1/servconf.c 2018-08-08 10:08:40.824719990 +0200
|
2018-10-12 13:54:56 +00:00
|
|
|
@@ -196,18 +196,19 @@ option_clear_or_none(const char *o)
|
2018-08-24 20:40:20 +00:00
|
|
|
all_kex = kex_alg_list(',');
|
|
|
|
all_key = sshkey_alg_list(0, 0, 1, ',');
|
2018-10-12 13:54:56 +00:00
|
|
|
all_sig = sshkey_alg_list(0, 1, 1, ',');
|
2018-08-24 20:40:20 +00:00
|
|
|
-#define ASSEMBLE(what, defaults, all) \
|
|
|
|
+#define ASSEMBLE(what, defaults, fips_defaults, all) \
|
|
|
|
do { \
|
|
|
|
- if ((r = kex_assemble_names(&o->what, defaults, all)) != 0) \
|
|
|
|
+ if ((r = kex_assemble_names(&o->what, (FIPS_mode() \
|
|
|
|
+ ? fips_defaults : defaults), all)) != 0) \
|
|
|
|
fatal("%s: %s: %s", __func__, #what, ssh_err(r)); \
|
|
|
|
} while (0)
|
|
|
|
- ASSEMBLE(ciphers, KEX_SERVER_ENCRYPT, all_cipher);
|
|
|
|
- ASSEMBLE(macs, KEX_SERVER_MAC, all_mac);
|
|
|
|
- ASSEMBLE(kex_algorithms, KEX_SERVER_KEX, all_kex);
|
|
|
|
- ASSEMBLE(hostkeyalgorithms, KEX_DEFAULT_PK_ALG, all_key);
|
|
|
|
- ASSEMBLE(hostbased_key_types, KEX_DEFAULT_PK_ALG, all_key);
|
|
|
|
- ASSEMBLE(pubkey_key_types, KEX_DEFAULT_PK_ALG, all_key);
|
2018-10-12 13:54:56 +00:00
|
|
|
- ASSEMBLE(ca_sign_algorithms, SSH_ALLOWED_CA_SIGALGS, all_sig);
|
2018-08-24 20:40:20 +00:00
|
|
|
+ ASSEMBLE(ciphers, KEX_SERVER_ENCRYPT, KEX_FIPS_ENCRYPT, all_cipher);
|
|
|
|
+ ASSEMBLE(macs, KEX_SERVER_MAC, KEX_FIPS_MAC, all_mac);
|
|
|
|
+ ASSEMBLE(kex_algorithms, KEX_SERVER_KEX, KEX_DEFAULT_KEX_FIPS, all_kex);
|
|
|
|
+ ASSEMBLE(hostkeyalgorithms, KEX_DEFAULT_PK_ALG, KEX_FIPS_PK_ALG, all_key);
|
|
|
|
+ ASSEMBLE(hostbased_key_types, KEX_DEFAULT_PK_ALG, KEX_FIPS_PK_ALG, all_key);
|
|
|
|
+ ASSEMBLE(pubkey_key_types, KEX_DEFAULT_PK_ALG, KEX_FIPS_PK_ALG, all_key);
|
2018-10-12 13:54:56 +00:00
|
|
|
+ ASSEMBLE(ca_sign_algorithms, SSH_ALLOWED_CA_SIGALGS, KEX_FIPS_PK_ALG, all_sig);
|
2018-08-24 20:40:20 +00:00
|
|
|
#undef ASSEMBLE
|
|
|
|
free(all_cipher);
|
|
|
|
free(all_mac);
|
2018-08-08 08:17:43 +00:00
|
|
|
diff -up openssh-7.7p1/ssh.c.fips openssh-7.7p1/ssh.c
|
|
|
|
--- openssh-7.7p1/ssh.c.fips 2018-08-08 10:08:40.811719881 +0200
|
|
|
|
+++ openssh-7.7p1/ssh.c 2018-08-08 10:08:40.825719999 +0200
|
2017-01-02 14:42:13 +00:00
|
|
|
@@ -76,6 +76,8 @@
|
2014-07-09 19:16:53 +00:00
|
|
|
#include <openssl/evp.h>
|
|
|
|
#include <openssl/err.h>
|
2015-01-20 12:18:45 +00:00
|
|
|
#endif
|
2014-07-09 19:16:53 +00:00
|
|
|
+#include <openssl/fips.h>
|
|
|
|
+#include <fipscheck.h>
|
|
|
|
#include "openbsd-compat/openssl-compat.h"
|
|
|
|
#include "openbsd-compat/sys-queue.h"
|
|
|
|
|
2018-10-12 13:54:56 +00:00
|
|
|
@@ -579,6 +581,16 @@ main(int ac, char **av)
|
2014-07-09 19:16:53 +00:00
|
|
|
sanitise_stdfd();
|
|
|
|
|
|
|
|
__progname = ssh_get_progname(av[0]);
|
2018-10-12 13:54:56 +00:00
|
|
|
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
|
|
|
+ SSLeay_add_all_algorithms();
|
|
|
|
+#endif
|
2014-07-09 19:16:53 +00:00
|
|
|
+ if (access("/etc/system-fips", F_OK) == 0)
|
2015-01-30 13:27:43 +00:00
|
|
|
+ if (! FIPSCHECK_verify(NULL, NULL)){
|
2014-07-09 19:16:53 +00:00
|
|
|
+ if (FIPS_mode())
|
|
|
|
+ fatal("FIPS integrity verification test failed.");
|
|
|
|
+ else
|
|
|
|
+ logit("FIPS integrity verification test failed.");
|
2015-01-30 13:27:43 +00:00
|
|
|
+ }
|
2014-07-09 19:16:53 +00:00
|
|
|
|
|
|
|
#ifndef HAVE_SETPROCTITLE
|
|
|
|
/* Prepare for later setproctitle emulation */
|
2018-08-08 08:17:43 +00:00
|
|
|
@@ -1045,7 +1055,6 @@ main(int ac, char **av)
|
2014-07-09 19:16:53 +00:00
|
|
|
host_arg = xstrdup(host);
|
|
|
|
|
2015-01-20 12:18:45 +00:00
|
|
|
#ifdef WITH_OPENSSL
|
2014-07-09 19:16:53 +00:00
|
|
|
- OpenSSL_add_all_algorithms();
|
|
|
|
ERR_load_crypto_strings();
|
2015-01-20 12:18:45 +00:00
|
|
|
#endif
|
2014-07-09 19:16:53 +00:00
|
|
|
|
2018-08-08 08:17:43 +00:00
|
|
|
@@ -1268,6 +1277,10 @@ main(int ac, char **av)
|
2014-07-09 19:16:53 +00:00
|
|
|
|
|
|
|
seed_rng();
|
|
|
|
|
|
|
|
+ if (FIPS_mode()) {
|
|
|
|
+ logit("FIPS mode initialized");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
if (options.user == NULL)
|
|
|
|
options.user = xstrdup(pw->pw_name);
|
|
|
|
|
2018-08-08 08:17:43 +00:00
|
|
|
diff -up openssh-7.7p1/sshconnect2.c.fips openssh-7.7p1/sshconnect2.c
|
|
|
|
--- openssh-7.7p1/sshconnect2.c.fips 2018-08-08 10:08:40.786719670 +0200
|
|
|
|
+++ openssh-7.7p1/sshconnect2.c 2018-08-08 10:08:40.825719999 +0200
|
2015-08-13 15:43:12 +00:00
|
|
|
@@ -44,6 +44,8 @@
|
2014-07-09 19:16:53 +00:00
|
|
|
#include <vis.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
+#include <openssl/fips.h>
|
|
|
|
+
|
|
|
|
#include "openbsd-compat/sys-queue.h"
|
|
|
|
|
|
|
|
#include "xmalloc.h"
|
2018-08-08 08:17:43 +00:00
|
|
|
@@ -235,7 +237,8 @@ order_hostkeyalgs(char *host, struct soc
|
2017-06-30 10:18:02 +00:00
|
|
|
for (i = 0; i < options.num_system_hostfiles; i++)
|
|
|
|
load_hostkeys(hostkeys, hostname, options.system_hostfiles[i]);
|
|
|
|
|
|
|
|
- oavail = avail = xstrdup(KEX_DEFAULT_PK_ALG);
|
|
|
|
+ oavail = avail = xstrdup((FIPS_mode()
|
|
|
|
+ ? KEX_FIPS_PK_ALG : KEX_DEFAULT_PK_ALG));
|
|
|
|
maxlen = strlen(avail) + 1;
|
|
|
|
first = xmalloc(maxlen);
|
|
|
|
last = xmalloc(maxlen);
|
2018-08-08 08:17:43 +00:00
|
|
|
@@ -290,21 +293,26 @@ ssh_kex2(char *host, struct sockaddr *ho
|
2014-07-09 19:16:53 +00:00
|
|
|
|
|
|
|
#ifdef GSSAPI
|
|
|
|
if (options.gss_keyex) {
|
|
|
|
- /* Add the GSSAPI mechanisms currently supported on this
|
|
|
|
- * client to the key exchange algorithm proposal */
|
2015-09-23 12:16:43 +00:00
|
|
|
- orig = options.kex_algorithms;
|
2015-03-20 13:56:04 +00:00
|
|
|
-
|
|
|
|
- if (options.gss_trust_dns)
|
2016-07-26 08:54:13 +00:00
|
|
|
- gss_host = (char *)get_canonical_hostname(active_state, 1);
|
2015-03-20 13:56:04 +00:00
|
|
|
- else
|
|
|
|
- gss_host = host;
|
|
|
|
-
|
2015-08-19 11:14:20 +00:00
|
|
|
- gss = ssh_gssapi_client_mechanisms(gss_host,
|
|
|
|
- options.gss_client_identity, options.gss_kex_algorithms);
|
2015-03-20 13:56:04 +00:00
|
|
|
- if (gss) {
|
|
|
|
- debug("Offering GSSAPI proposal: %s", gss);
|
2015-09-23 12:16:43 +00:00
|
|
|
- xasprintf(&options.kex_algorithms,
|
2015-03-20 13:56:04 +00:00
|
|
|
- "%s,%s", gss, orig);
|
2014-07-09 19:16:53 +00:00
|
|
|
+ if (FIPS_mode()) {
|
|
|
|
+ logit("Disabling GSSAPIKeyExchange. Not usable in FIPS mode");
|
|
|
|
+ options.gss_keyex = 0;
|
|
|
|
+ } else {
|
|
|
|
+ /* Add the GSSAPI mechanisms currently supported on this
|
|
|
|
+ * client to the key exchange algorithm proposal */
|
2015-09-23 12:16:43 +00:00
|
|
|
+ orig = options.kex_algorithms;
|
2015-03-20 13:56:04 +00:00
|
|
|
+
|
2014-07-09 19:16:53 +00:00
|
|
|
+ if (options.gss_trust_dns)
|
2016-07-26 08:54:13 +00:00
|
|
|
+ gss_host = (char *)get_canonical_hostname(active_state, 1);
|
2014-07-09 19:16:53 +00:00
|
|
|
+ else
|
|
|
|
+ gss_host = host;
|
2015-03-20 13:56:04 +00:00
|
|
|
+
|
2015-08-19 11:14:20 +00:00
|
|
|
+ gss = ssh_gssapi_client_mechanisms(gss_host,
|
|
|
|
+ options.gss_client_identity, options.gss_kex_algorithms);
|
2014-07-09 19:16:53 +00:00
|
|
|
+ if (gss) {
|
|
|
|
+ debug("Offering GSSAPI proposal: %s", gss);
|
2015-09-23 12:16:43 +00:00
|
|
|
+ xasprintf(&options.kex_algorithms,
|
2014-07-09 19:16:53 +00:00
|
|
|
+ "%s,%s", gss, orig);
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2018-08-08 08:17:43 +00:00
|
|
|
@@ -322,14 +330,16 @@ ssh_kex2(char *host, struct sockaddr *ho
|
2017-06-30 10:18:02 +00:00
|
|
|
if (options.hostkeyalgorithms != NULL) {
|
2018-08-24 20:40:20 +00:00
|
|
|
all_key = sshkey_alg_list(0, 0, 1, ',');
|
|
|
|
if (kex_assemble_names(&options.hostkeyalgorithms,
|
|
|
|
- KEX_DEFAULT_PK_ALG, all_key) != 0)
|
|
|
|
+ (FIPS_mode() ? KEX_FIPS_PK_ALG : KEX_DEFAULT_PK_ALG),
|
|
|
|
+ all_key) != 0)
|
2017-06-30 10:18:02 +00:00
|
|
|
fatal("%s: kex_assemble_namelist", __func__);
|
2018-08-24 20:40:20 +00:00
|
|
|
free(all_key);
|
2017-06-30 10:18:02 +00:00
|
|
|
myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] =
|
|
|
|
compat_pkalg_proposal(options.hostkeyalgorithms);
|
|
|
|
} else {
|
|
|
|
/* Enforce default */
|
|
|
|
- options.hostkeyalgorithms = xstrdup(KEX_DEFAULT_PK_ALG);
|
|
|
|
+ options.hostkeyalgorithms = xstrdup((FIPS_mode()
|
|
|
|
+ ? KEX_FIPS_PK_ALG : KEX_DEFAULT_PK_ALG));
|
|
|
|
/* Prefer algorithms that we already have keys for */
|
|
|
|
myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] =
|
|
|
|
compat_pkalg_proposal(
|
2018-08-08 08:17:43 +00:00
|
|
|
diff -up openssh-7.7p1/sshd.c.fips openssh-7.7p1/sshd.c
|
|
|
|
--- openssh-7.7p1/sshd.c.fips 2018-08-08 10:08:40.818719940 +0200
|
|
|
|
+++ openssh-7.7p1/sshd.c 2018-08-08 10:08:40.826720007 +0200
|
2015-01-20 12:18:45 +00:00
|
|
|
@@ -66,6 +66,7 @@
|
|
|
|
#include <grp.h>
|
|
|
|
#include <pwd.h>
|
|
|
|
#include <signal.h>
|
|
|
|
+#include <syslog.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2015-03-20 13:56:04 +00:00
|
|
|
@@ -77,6 +78,8 @@
|
2014-07-09 19:16:53 +00:00
|
|
|
#include <openssl/dh.h>
|
|
|
|
#include <openssl/bn.h>
|
|
|
|
#include <openssl/rand.h>
|
|
|
|
+#include <openssl/fips.h>
|
|
|
|
+#include <fipscheck.h>
|
|
|
|
#include "openbsd-compat/openssl-compat.h"
|
2015-01-20 12:18:45 +00:00
|
|
|
#endif
|
2014-07-09 19:16:53 +00:00
|
|
|
|
2018-08-08 08:17:43 +00:00
|
|
|
@@ -1534,6 +1537,18 @@ main(int ac, char **av)
|
2014-07-09 19:16:53 +00:00
|
|
|
#endif
|
|
|
|
__progname = ssh_get_progname(av[0]);
|
|
|
|
|
2018-10-12 13:54:56 +00:00
|
|
|
+ OpenSSL_add_all_algorithms();
|
2014-07-09 19:16:53 +00:00
|
|
|
+ if (access("/etc/system-fips", F_OK) == 0)
|
|
|
|
+ if (! FIPSCHECK_verify(NULL, NULL)) {
|
|
|
|
+ openlog(__progname, LOG_PID, LOG_AUTHPRIV);
|
|
|
|
+ if (FIPS_mode()) {
|
|
|
|
+ syslog(LOG_CRIT, "FIPS integrity verification test failed.");
|
|
|
|
+ cleanup_exit(255);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ syslog(LOG_INFO, "FIPS integrity verification test failed.");
|
|
|
|
+ closelog();
|
|
|
|
+ }
|
|
|
|
/* Save argv. Duplicate so setproctitle emulation doesn't clobber it */
|
|
|
|
saved_argc = ac;
|
|
|
|
rexec_argc = ac;
|
2018-08-08 08:17:43 +00:00
|
|
|
@@ -1675,7 +1690,7 @@ main(int ac, char **av)
|
2014-07-09 19:16:53 +00:00
|
|
|
else
|
|
|
|
closefrom(REEXEC_DEVCRYPTO_RESERVED_FD);
|
|
|
|
|
2015-01-20 12:18:45 +00:00
|
|
|
-#ifdef WITH_OPENSSL
|
|
|
|
+#if 0 /* FIPS */
|
|
|
|
OpenSSL_add_all_algorithms();
|
|
|
|
#endif
|
|
|
|
|
2018-08-08 08:17:43 +00:00
|
|
|
@@ -1979,6 +1994,10 @@ main(int ac, char **av)
|
2014-07-09 19:16:53 +00:00
|
|
|
/* Reinitialize the log (because of the fork above). */
|
|
|
|
log_init(__progname, options.log_level, options.log_facility, log_stderr);
|
|
|
|
|
|
|
|
+ if (FIPS_mode()) {
|
|
|
|
+ logit("FIPS mode initialized");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
/* Chdir to the root directory so that the current disk can be
|
|
|
|
unmounted if desired. */
|
|
|
|
if (chdir("/") == -1)
|
2018-08-08 08:17:43 +00:00
|
|
|
@@ -2359,10 +2378,14 @@ do_ssh2_kex(void)
|
2014-07-09 19:16:53 +00:00
|
|
|
if (strlen(myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS]) == 0)
|
|
|
|
orig = NULL;
|
|
|
|
|
|
|
|
- if (options.gss_keyex)
|
|
|
|
- gss = ssh_gssapi_server_mechanisms();
|
|
|
|
- else
|
|
|
|
- gss = NULL;
|
|
|
|
+ if (options.gss_keyex) {
|
|
|
|
+ if (FIPS_mode()) {
|
|
|
|
+ logit("Disabling GSSAPIKeyExchange. Not usable in FIPS mode");
|
|
|
|
+ options.gss_keyex = 0;
|
|
|
|
+ } else {
|
|
|
|
+ gss = ssh_gssapi_server_mechanisms();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
|
|
if (gss && orig)
|
|
|
|
xasprintf(&newstr, "%s,%s", gss, orig);
|
2018-08-08 08:17:43 +00:00
|
|
|
diff -up openssh-7.7p1/sshkey.c.fips openssh-7.7p1/sshkey.c
|
|
|
|
--- openssh-7.7p1/sshkey.c.fips 2018-08-08 10:08:40.818719940 +0200
|
|
|
|
+++ openssh-7.7p1/sshkey.c 2018-08-08 10:08:40.826720007 +0200
|
2017-01-02 14:42:13 +00:00
|
|
|
@@ -34,6 +34,7 @@
|
2015-01-20 12:18:45 +00:00
|
|
|
#include <openssl/evp.h>
|
|
|
|
#include <openssl/err.h>
|
|
|
|
#include <openssl/pem.h>
|
|
|
|
+#include <openssl/fips.h>
|
2015-03-20 13:56:04 +00:00
|
|
|
#endif
|
2015-01-20 12:18:45 +00:00
|
|
|
|
|
|
|
#include "crypto_api.h"
|
2018-08-08 08:17:43 +00:00
|
|
|
@@ -57,6 +58,7 @@
|
2016-06-03 10:40:12 +00:00
|
|
|
#include "sshkey.h"
|
2018-03-27 14:52:07 +00:00
|
|
|
#include "sshkey-xmss.h"
|
2016-06-03 10:40:12 +00:00
|
|
|
#include "match.h"
|
2017-06-30 10:18:02 +00:00
|
|
|
+#include "log.h"
|
2016-06-03 10:40:12 +00:00
|
|
|
|
2018-03-27 14:52:07 +00:00
|
|
|
#include "xmss_fast.h"
|
|
|
|
|
2018-08-08 08:17:43 +00:00
|
|
|
@@ -1526,6 +1528,8 @@ rsa_generate_private_key(u_int bits, RSA
|
2015-01-20 12:18:45 +00:00
|
|
|
}
|
|
|
|
if (!BN_set_word(f4, RSA_F4) ||
|
|
|
|
!RSA_generate_key_ex(private, bits, f4, NULL)) {
|
|
|
|
+ if (FIPS_mode())
|
|
|
|
+ logit("%s: the key length might be unsupported by FIPS mode approved key generation method", __func__);
|
|
|
|
ret = SSH_ERR_LIBCRYPTO_ERROR;
|
|
|
|
goto out;
|
|
|
|
}
|
2018-08-08 08:17:43 +00:00
|
|
|
diff -up openssh-7.7p1/ssh-keygen.c.fips openssh-7.7p1/ssh-keygen.c
|
|
|
|
--- openssh-7.7p1/ssh-keygen.c.fips 2018-08-08 10:08:40.801719797 +0200
|
|
|
|
+++ openssh-7.7p1/ssh-keygen.c 2018-08-08 10:08:40.827720016 +0200
|
|
|
|
@@ -229,6 +229,12 @@ type_bits_valid(int type, const char *na
|
2017-06-30 10:18:02 +00:00
|
|
|
OPENSSL_DSA_MAX_MODULUS_BITS : OPENSSL_RSA_MAX_MODULUS_BITS;
|
|
|
|
if (*bitsp > maxbits)
|
|
|
|
fatal("key bits exceeds maximum %d", maxbits);
|
|
|
|
+ if (FIPS_mode()) {
|
|
|
|
+ if (type == KEY_DSA)
|
|
|
|
+ fatal("DSA keys are not allowed in FIPS mode");
|
|
|
|
+ if (type == KEY_ED25519)
|
|
|
|
+ fatal("ED25519 keys are not allowed in FIPS mode");
|
|
|
|
+ }
|
2017-09-26 12:04:45 +00:00
|
|
|
switch (type) {
|
|
|
|
case KEY_DSA:
|
|
|
|
if (*bitsp != 1024)
|