|
Jakub Jelen |
9dbec7 |
diff -up openssh-7.5p1/cipher.c.fips openssh-7.5p1/cipher.c
|
|
Jakub Jelen |
9dbec7 |
--- openssh-7.5p1/cipher.c.fips 2017-06-30 12:06:36.455713788 +0200
|
|
Jakub Jelen |
9dbec7 |
+++ openssh-7.5p1/cipher.c 2017-06-30 12:06:36.465713761 +0200
|
|
Petr Lautrbach |
802815 |
@@ -39,6 +39,8 @@
|
|
Petr Lautrbach |
802815 |
|
|
Petr Lautrbach |
802815 |
#include <sys/types.h>
|
|
Petr Lautrbach |
802815 |
|
|
Petr Lautrbach |
802815 |
+#include <openssl/fips.h>
|
|
Petr Lautrbach |
802815 |
+
|
|
Petr Lautrbach |
802815 |
#include <string.h>
|
|
Petr Lautrbach |
802815 |
#include <stdarg.h>
|
|
Petr Lautrbach |
802815 |
#include <stdio.h>
|
|
Jakub Jelen |
5b55d0 |
@@ -116,6 +118,27 @@ static const struct sshcipher ciphers[]
|
|
Jakub Jelen |
5b55d0 |
{ NULL, 0, 0, 0, 0, 0, NULL }
|
|
Petr Lautrbach |
802815 |
};
|
|
Petr Lautrbach |
802815 |
|
|
Petr Lautrbach |
190035 |
+static const struct sshcipher fips_ciphers[] = {
|
|
Jakub Jelen |
5b55d0 |
+#ifdef WITH_OPENSSL
|
|
Jakub Jelen |
5b55d0 |
+ { "3des-cbc", 8, 24, 0, 0, CFLAG_CBC, EVP_des_ede3_cbc },
|
|
Jakub Jelen |
5b55d0 |
+ { "aes128-cbc", 16, 16, 0, 0, CFLAG_CBC, EVP_aes_128_cbc },
|
|
Jakub Jelen |
5b55d0 |
+ { "aes192-cbc", 16, 24, 0, 0, CFLAG_CBC, EVP_aes_192_cbc },
|
|
Jakub Jelen |
5b55d0 |
+ { "aes256-cbc", 16, 32, 0, 0, CFLAG_CBC, EVP_aes_256_cbc },
|
|
Petr Lautrbach |
802815 |
+ { "rijndael-cbc@lysator.liu.se",
|
|
Jakub Jelen |
5b55d0 |
+ 16, 32, 0, 0, CFLAG_CBC, EVP_aes_256_cbc },
|
|
Jakub Jelen |
5b55d0 |
+ { "aes128-ctr", 16, 16, 0, 0, 0, EVP_aes_128_ctr },
|
|
Jakub Jelen |
5b55d0 |
+ { "aes192-ctr", 16, 24, 0, 0, 0, EVP_aes_192_ctr },
|
|
Jakub Jelen |
5b55d0 |
+ { "aes256-ctr", 16, 32, 0, 0, 0, EVP_aes_256_ctr },
|
|
Jakub Jelen |
5b55d0 |
+#else
|
|
Jakub Jelen |
5b55d0 |
+ { "aes128-ctr", 16, 16, 0, 0, CFLAG_AESCTR, NULL },
|
|
Jakub Jelen |
5b55d0 |
+ { "aes192-ctr", 16, 24, 0, 0, CFLAG_AESCTR, NULL },
|
|
Jakub Jelen |
5b55d0 |
+ { "aes256-ctr", 16, 32, 0, 0, CFLAG_AESCTR, NULL },
|
|
Jakub Jelen |
5b55d0 |
+#endif
|
|
Jakub Jelen |
5b55d0 |
+ { "none", 8, 0, 0, 0, CFLAG_NONE, NULL },
|
|
Jakub Jelen |
5b55d0 |
+
|
|
Jakub Jelen |
5b55d0 |
+ { NULL, 0, 0, 0, 0, 0, NULL }
|
|
Petr Lautrbach |
802815 |
+};
|
|
Petr Lautrbach |
190035 |
+
|
|
Petr Lautrbach |
802815 |
/*--*/
|
|
Petr Lautrbach |
802815 |
|
|
Petr Lautrbach |
190035 |
/* Returns a comma-separated list of supported ciphers. */
|
|
Jakub Jelen |
6cf9b8 |
@@ -126,7 +142,7 @@ cipher_alg_list(char sep, int auth_only)
|
|
Petr Lautrbach |
802815 |
size_t nlen, rlen = 0;
|
|
Petr Lautrbach |
190035 |
const struct sshcipher *c;
|
|
Petr Lautrbach |
802815 |
|
|
Petr Lautrbach |
802815 |
- for (c = ciphers; c->name != NULL; c++) {
|
|
Petr Lautrbach |
802815 |
+ for (c = FIPS_mode() ? fips_ciphers : ciphers; c->name != NULL; c++) {
|
|
Jakub Jelen |
5b55d0 |
if ((c->flags & CFLAG_INTERNAL) != 0)
|
|
Petr Lautrbach |
802815 |
continue;
|
|
Petr Lautrbach |
802815 |
if (auth_only && c->auth_len == 0)
|
|
Jakub Jelen |
6cf9b8 |
@@ -222,7 +238,7 @@ const struct sshcipher *
|
|
Petr Lautrbach |
802815 |
cipher_by_name(const char *name)
|
|
Petr Lautrbach |
802815 |
{
|
|
Petr Lautrbach |
190035 |
const struct sshcipher *c;
|
|
Petr Lautrbach |
802815 |
- for (c = ciphers; c->name != NULL; c++)
|
|
Petr Lautrbach |
802815 |
+ for (c = FIPS_mode() ? fips_ciphers : ciphers; c->name != NULL; c++)
|
|
Petr Lautrbach |
802815 |
if (strcmp(c->name, name) == 0)
|
|
Petr Lautrbach |
802815 |
return c;
|
|
Petr Lautrbach |
802815 |
return NULL;
|
|
Jakub Jelen |
9dbec7 |
diff -up openssh-7.5p1/cipher-ctr.c.fips openssh-7.5p1/cipher-ctr.c
|
|
Jakub Jelen |
9dbec7 |
--- openssh-7.5p1/cipher-ctr.c.fips 2017-06-30 12:06:36.386713974 +0200
|
|
Jakub Jelen |
9dbec7 |
+++ openssh-7.5p1/cipher-ctr.c 2017-06-30 12:06:36.465713761 +0200
|
|
Jakub Jelen |
535d34 |
@@ -179,7 +179,8 @@ evp_aes_128_ctr(void)
|
|
Jakub Jelen |
535d34 |
aes_ctr.do_cipher = ssh_aes_ctr;
|
|
Jakub Jelen |
535d34 |
#ifndef SSH_OLD_EVP
|
|
Jakub Jelen |
535d34 |
aes_ctr.flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH |
|
|
Jakub Jelen |
535d34 |
- EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CUSTOM_IV;
|
|
Jakub Jelen |
535d34 |
+ EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CUSTOM_IV |
|
|
Jakub Jelen |
535d34 |
+ EVP_CIPH_FLAG_FIPS;
|
|
Jakub Jelen |
535d34 |
#endif
|
|
Jakub Jelen |
535d34 |
return (&aes_ctr);
|
|
Jakub Jelen |
535d34 |
}
|
|
Jakub Jelen |
9dbec7 |
diff -up openssh-7.5p1/clientloop.c.fips openssh-7.5p1/clientloop.c
|
|
Jakub Jelen |
9dbec7 |
--- openssh-7.5p1/clientloop.c.fips 2017-06-30 12:06:36.466713758 +0200
|
|
Jakub Jelen |
9dbec7 |
+++ openssh-7.5p1/clientloop.c 2017-06-30 12:09:11.503295871 +0200
|
|
Jakub Jelen |
9dbec7 |
@@ -2412,7 +2412,8 @@ key_accepted_by_hostkeyalgs(const struct
|
|
Jakub Jelen |
9dbec7 |
{
|
|
Jakub Jelen |
9dbec7 |
const char *ktype = sshkey_ssh_name(key);
|
|
Jakub Jelen |
9dbec7 |
const char *hostkeyalgs = options.hostkeyalgorithms != NULL ?
|
|
Jakub Jelen |
9dbec7 |
- options.hostkeyalgorithms : KEX_DEFAULT_PK_ALG;
|
|
Jakub Jelen |
9dbec7 |
+ options.hostkeyalgorithms : (FIPS_mode() ?
|
|
Jakub Jelen |
9dbec7 |
+ KEX_FIPS_PK_ALG : KEX_DEFAULT_PK_ALG);
|
|
Jakub Jelen |
9dbec7 |
|
|
Jakub Jelen |
9dbec7 |
if (key == NULL || key->type == KEY_UNSPEC)
|
|
Jakub Jelen |
9dbec7 |
return 0;
|
|
Jakub Jelen |
9dbec7 |
diff -up openssh-7.5p1/dh.h.fips openssh-7.5p1/dh.h
|
|
Jakub Jelen |
9dbec7 |
--- openssh-7.5p1/dh.h.fips 2017-03-20 03:39:27.000000000 +0100
|
|
Jakub Jelen |
9dbec7 |
+++ openssh-7.5p1/dh.h 2017-06-30 12:06:36.466713758 +0200
|
|
Jakub Jelen |
6cf9b8 |
@@ -51,6 +51,7 @@ u_int dh_estimate(int);
|
|
Jakub Jelen |
13bf5b |
* Miniumum increased in light of DH precomputation attacks.
|
|
Jakub Jelen |
13bf5b |
*/
|
|
Jakub Jelen |
13073f |
#define DH_GRP_MIN 2048
|
|
Petr Lautrbach |
802815 |
+#define DH_GRP_MIN_FIPS 2048
|
|
Petr Lautrbach |
802815 |
#define DH_GRP_MAX 8192
|
|
Petr Lautrbach |
802815 |
|
|
Petr Lautrbach |
802815 |
/*
|
|
Jakub Jelen |
9dbec7 |
diff -up openssh-7.5p1/entropy.c.fips openssh-7.5p1/entropy.c
|
|
Jakub Jelen |
9dbec7 |
--- openssh-7.5p1/entropy.c.fips 2017-06-30 12:06:36.377713998 +0200
|
|
Jakub Jelen |
9dbec7 |
+++ openssh-7.5p1/entropy.c 2017-06-30 12:06:36.466713758 +0200
|
|
Jakub Jelen |
132f8f |
@@ -217,6 +217,9 @@ seed_rng(void)
|
|
Petr Lautrbach |
802815 |
fatal("OpenSSL version mismatch. Built against %lx, you "
|
|
Petr Lautrbach |
802815 |
"have %lx", (u_long)OPENSSL_VERSION_NUMBER, SSLeay());
|
|
Petr Lautrbach |
802815 |
|
|
Petr Lautrbach |
802815 |
+ /* clean the PRNG status when exiting the program */
|
|
Petr Lautrbach |
802815 |
+ atexit(RAND_cleanup);
|
|
Petr Lautrbach |
802815 |
+
|
|
Petr Lautrbach |
802815 |
#ifndef OPENSSL_PRNG_ONLY
|
|
Petr Lautrbach |
802815 |
if (RAND_status() == 1) {
|
|
Petr Lautrbach |
802815 |
debug3("RNG is ready, skipping seeding");
|
|
Jakub Jelen |
9dbec7 |
diff -up openssh-7.5p1/kex.c.fips openssh-7.5p1/kex.c
|
|
Jakub Jelen |
9dbec7 |
--- openssh-7.5p1/kex.c.fips 2017-06-30 12:06:36.455713788 +0200
|
|
Jakub Jelen |
9dbec7 |
+++ openssh-7.5p1/kex.c 2017-06-30 12:06:36.466713758 +0200
|
|
Petr Lautrbach |
190035 |
@@ -35,6 +35,7 @@
|
|
Petr Lautrbach |
190035 |
#ifdef WITH_OPENSSL
|
|
Petr Lautrbach |
802815 |
#include <openssl/crypto.h>
|
|
Jakub Jelen |
5878eb |
#include <openssl/dh.h>
|
|
Petr Lautrbach |
802815 |
+#include <openssl/fips.h>
|
|
Petr Lautrbach |
190035 |
#endif
|
|
Petr Lautrbach |
802815 |
|
|
Jakub Jelen |
132f8f |
#include "ssh2.h"
|
|
Jakub Jelen |
fd58b9 |
@@ -125,6 +126,26 @@ static const struct kexalg kexalgs[] = {
|
|
Petr Lautrbach |
802815 |
{ NULL, -1, -1, -1},
|
|
Petr Lautrbach |
802815 |
};
|
|
Petr Lautrbach |
802815 |
|
|
Petr Lautrbach |
802815 |
+static const struct kexalg kexalgs_fips[] = {
|
|
Jakub Jelen |
fd58b9 |
+ { KEX_DH14_SHA256, KEX_DH_GRP14_SHA256, 0, SSH_DIGEST_SHA256 },
|
|
Jakub Jelen |
fd58b9 |
+ { KEX_DH16_SHA512, KEX_DH_GRP16_SHA512, 0, SSH_DIGEST_SHA512 },
|
|
Jakub Jelen |
fd58b9 |
+ { KEX_DH18_SHA512, KEX_DH_GRP18_SHA512, 0, SSH_DIGEST_SHA512 },
|
|
Petr Lautrbach |
802815 |
+#ifdef HAVE_EVP_SHA256
|
|
Petr Lautrbach |
802815 |
+ { KEX_DHGEX_SHA256, KEX_DH_GEX_SHA256, 0, SSH_DIGEST_SHA256 },
|
|
Petr Lautrbach |
802815 |
+#endif
|
|
Petr Lautrbach |
802815 |
+#ifdef OPENSSL_HAS_ECC
|
|
Petr Lautrbach |
802815 |
+ { KEX_ECDH_SHA2_NISTP256, KEX_ECDH_SHA2,
|
|
Petr Lautrbach |
802815 |
+ NID_X9_62_prime256v1, SSH_DIGEST_SHA256 },
|
|
Petr Lautrbach |
802815 |
+ { KEX_ECDH_SHA2_NISTP384, KEX_ECDH_SHA2, NID_secp384r1,
|
|
Petr Lautrbach |
802815 |
+ SSH_DIGEST_SHA384 },
|
|
Petr Lautrbach |
802815 |
+# ifdef OPENSSL_HAS_NISTP521
|
|
Petr Lautrbach |
802815 |
+ { KEX_ECDH_SHA2_NISTP521, KEX_ECDH_SHA2, NID_secp521r1,
|
|
Petr Lautrbach |
802815 |
+ SSH_DIGEST_SHA512 },
|
|
Petr Lautrbach |
802815 |
+# endif
|
|
Petr Lautrbach |
802815 |
+#endif
|
|
Jakub Jelen |
580f98 |
+ { NULL, -1, -1, -1},
|
|
Petr Lautrbach |
802815 |
+};
|
|
Petr Lautrbach |
802815 |
+
|
|
Petr Lautrbach |
802815 |
char *
|
|
Petr Lautrbach |
802815 |
kex_alg_list(char sep)
|
|
Petr Lautrbach |
802815 |
{
|
|
Jakub Jelen |
9dbec7 |
@@ -152,7 +173,7 @@ kex_alg_by_name(const char *name)
|
|
Petr Lautrbach |
802815 |
{
|
|
Petr Lautrbach |
802815 |
const struct kexalg *k;
|
|
Petr Lautrbach |
802815 |
|
|
Petr Lautrbach |
802815 |
- for (k = kexalgs; k->name != NULL; k++) {
|
|
Petr Lautrbach |
802815 |
+ for (k = (FIPS_mode() ? kexalgs_fips : kexalgs); k->name != NULL; k++) {
|
|
Petr Lautrbach |
802815 |
if (strcmp(k->name, name) == 0)
|
|
Petr Lautrbach |
802815 |
return k;
|
|
Petr Lautrbach |
802815 |
#ifdef GSSAPI
|
|
Jakub Jelen |
9dbec7 |
@@ -178,7 +199,10 @@ kex_names_valid(const char *names)
|
|
Petr Lautrbach |
802815 |
for ((p = strsep(&cp, ",")); p && *p != '\0';
|
|
Petr Lautrbach |
802815 |
(p = strsep(&cp, ","))) {
|
|
Petr Lautrbach |
802815 |
if (kex_alg_by_name(p) == NULL) {
|
|
Petr Lautrbach |
802815 |
- error("Unsupported KEX algorithm \"%.100s\"", p);
|
|
Petr Lautrbach |
802815 |
+ if (FIPS_mode())
|
|
Petr Lautrbach |
802815 |
+ error("\"%.100s\" is not allowed in FIPS mode", p);
|
|
Petr Lautrbach |
802815 |
+ else
|
|
Petr Lautrbach |
802815 |
+ error("Unsupported KEX algorithm \"%.100s\"", p);
|
|
Petr Lautrbach |
802815 |
free(s);
|
|
Petr Lautrbach |
802815 |
return 0;
|
|
Petr Lautrbach |
802815 |
}
|
|
Jakub Jelen |
9dbec7 |
diff -up openssh-7.5p1/kexgexc.c.fips openssh-7.5p1/kexgexc.c
|
|
Jakub Jelen |
9dbec7 |
--- openssh-7.5p1/kexgexc.c.fips 2017-03-20 03:39:27.000000000 +0100
|
|
Jakub Jelen |
9dbec7 |
+++ openssh-7.5p1/kexgexc.c 2017-06-30 12:06:36.467713756 +0200
|
|
Jakub Jelen |
535d34 |
@@ -28,6 +28,7 @@
|
|
Petr Lautrbach |
802815 |
|
|
Jakub Jelen |
132f8f |
#ifdef WITH_OPENSSL
|
|
Petr Lautrbach |
802815 |
|
|
Petr Lautrbach |
802815 |
+#include <openssl/fips.h>
|
|
Petr Lautrbach |
802815 |
#include <sys/types.h>
|
|
Petr Lautrbach |
802815 |
|
|
Jakub Jelen |
6cf9b8 |
#include <openssl/dh.h>
|
|
Jakub Jelen |
535d34 |
@@ -63,7 +64,7 @@ kexgex_client(struct ssh *ssh)
|
|
Jakub Jelen |
132f8f |
|
|
Jakub Jelen |
132f8f |
nbits = dh_estimate(kex->dh_need * 8);
|
|
Petr Lautrbach |
08fe9e |
|
|
Jakub Jelen |
132f8f |
- kex->min = DH_GRP_MIN;
|
|
Jakub Jelen |
132f8f |
+ kex->min = FIPS_mode() ? DH_GRP_MIN_FIPS : DH_GRP_MIN;
|
|
Jakub Jelen |
132f8f |
kex->max = DH_GRP_MAX;
|
|
Jakub Jelen |
535d34 |
kex->nbits = nbits;
|
|
Jakub Jelen |
535d34 |
if (datafellows & SSH_BUG_DHGEX_LARGE)
|
|
Jakub Jelen |
9dbec7 |
diff -up openssh-7.5p1/kexgexs.c.fips openssh-7.5p1/kexgexs.c
|
|
Jakub Jelen |
9dbec7 |
--- openssh-7.5p1/kexgexs.c.fips 2017-03-20 03:39:27.000000000 +0100
|
|
Jakub Jelen |
9dbec7 |
+++ openssh-7.5p1/kexgexs.c 2017-06-30 12:06:36.467713756 +0200
|
|
Jakub Jelen |
13bf5b |
@@ -83,9 +83,9 @@ input_kex_dh_gex_request(int type, u_int
|
|
Jakub Jelen |
535d34 |
kex->nbits = nbits;
|
|
Jakub Jelen |
13bf5b |
kex->min = min;
|
|
Jakub Jelen |
535d34 |
kex->max = max;
|
|
Jakub Jelen |
6cf9b8 |
- min = MAXIMUM(DH_GRP_MIN, min);
|
|
Jakub Jelen |
6cf9b8 |
+ min = MAXIMUM(FIPS_mode() ? DH_GRP_MIN_FIPS : DH_GRP_MIN, min);
|
|
Jakub Jelen |
6cf9b8 |
max = MINIMUM(DH_GRP_MAX, max);
|
|
Jakub Jelen |
6cf9b8 |
- nbits = MAXIMUM(DH_GRP_MIN, nbits);
|
|
Jakub Jelen |
6cf9b8 |
+ nbits = MAXIMUM(FIPS_mode() ? DH_GRP_MIN_FIPS : DH_GRP_MIN, nbits);
|
|
Jakub Jelen |
6cf9b8 |
nbits = MINIMUM(DH_GRP_MAX, nbits);
|
|
Jakub Jelen |
535d34 |
|
|
Jakub Jelen |
535d34 |
if (kex->max < kex->min || kex->nbits < kex->min ||
|
|
Jakub Jelen |
9dbec7 |
diff -up openssh-7.5p1/mac.c.fips openssh-7.5p1/mac.c
|
|
Jakub Jelen |
9dbec7 |
--- openssh-7.5p1/mac.c.fips 2017-06-30 12:06:36.456713785 +0200
|
|
Jakub Jelen |
9dbec7 |
+++ openssh-7.5p1/mac.c 2017-06-30 12:06:36.467713756 +0200
|
|
Petr Lautrbach |
802815 |
@@ -27,6 +27,8 @@
|
|
Petr Lautrbach |
802815 |
|
|
Petr Lautrbach |
802815 |
#include <sys/types.h>
|
|
Petr Lautrbach |
802815 |
|
|
Petr Lautrbach |
802815 |
+#include <openssl/fips.h>
|
|
Petr Lautrbach |
802815 |
+
|
|
Petr Lautrbach |
802815 |
#include <string.h>
|
|
Jakub Jelen |
132f8f |
#include <stdio.h>
|
|
Jakub Jelen |
132f8f |
|
|
Jakub Jelen |
132f8f |
@@ -54,7 +56,7 @@ struct macalg {
|
|
Petr Lautrbach |
802815 |
int etm; /* Encrypt-then-MAC */
|
|
Petr Lautrbach |
802815 |
};
|
|
Petr Lautrbach |
802815 |
|
|
Petr Lautrbach |
802815 |
-static const struct macalg macs[] = {
|
|
Petr Lautrbach |
802815 |
+static const struct macalg all_macs[] = {
|
|
Petr Lautrbach |
802815 |
/* Encrypt-and-MAC (encrypt-and-authenticate) variants */
|
|
Petr Lautrbach |
802815 |
{ "hmac-sha1", SSH_DIGEST, SSH_DIGEST_SHA1, 0, 0, 0, 0 },
|
|
Petr Lautrbach |
802815 |
{ "hmac-sha1-96", SSH_DIGEST, SSH_DIGEST_SHA1, 96, 0, 0, 0 },
|
|
Jakub Jelen |
6cf9b8 |
@@ -89,6 +91,24 @@ static const struct macalg macs[] = {
|
|
Petr Lautrbach |
802815 |
{ NULL, 0, 0, 0, 0, 0, 0 }
|
|
Petr Lautrbach |
802815 |
};
|
|
Petr Lautrbach |
802815 |
|
|
Petr Lautrbach |
802815 |
+static const struct macalg fips_macs[] = {
|
|
Petr Lautrbach |
802815 |
+ /* Encrypt-and-MAC (encrypt-and-authenticate) variants */
|
|
Petr Lautrbach |
802815 |
+ { "hmac-sha1", SSH_DIGEST, SSH_DIGEST_SHA1, 0, 0, 0, 0 },
|
|
Petr Lautrbach |
802815 |
+#ifdef HAVE_EVP_SHA256
|
|
Petr Lautrbach |
802815 |
+ { "hmac-sha2-256", SSH_DIGEST, SSH_DIGEST_SHA256, 0, 0, 0, 0 },
|
|
Petr Lautrbach |
802815 |
+ { "hmac-sha2-512", SSH_DIGEST, SSH_DIGEST_SHA512, 0, 0, 0, 0 },
|
|
Petr Lautrbach |
802815 |
+#endif
|
|
Petr Lautrbach |
802815 |
+
|
|
Petr Lautrbach |
802815 |
+ /* Encrypt-then-MAC variants */
|
|
Petr Lautrbach |
802815 |
+ { "hmac-sha1-etm@openssh.com", SSH_DIGEST, SSH_DIGEST_SHA1, 0, 0, 0, 1 },
|
|
Petr Lautrbach |
802815 |
+#ifdef HAVE_EVP_SHA256
|
|
Petr Lautrbach |
802815 |
+ { "hmac-sha2-256-etm@openssh.com", SSH_DIGEST, SSH_DIGEST_SHA256, 0, 0, 0, 1 },
|
|
Petr Lautrbach |
802815 |
+ { "hmac-sha2-512-etm@openssh.com", SSH_DIGEST, SSH_DIGEST_SHA512, 0, 0, 0, 1 },
|
|
Petr Lautrbach |
802815 |
+#endif
|
|
Petr Lautrbach |
802815 |
+
|
|
Petr Lautrbach |
802815 |
+ { NULL, 0, 0, 0, 0, 0, 0 }
|
|
Petr Lautrbach |
802815 |
+};
|
|
Petr Lautrbach |
802815 |
+
|
|
Petr Lautrbach |
802815 |
/* Returns a list of supported MACs separated by the specified char. */
|
|
Petr Lautrbach |
802815 |
char *
|
|
Petr Lautrbach |
802815 |
mac_alg_list(char sep)
|
|
Jakub Jelen |
6cf9b8 |
@@ -97,7 +117,7 @@ mac_alg_list(char sep)
|
|
Petr Lautrbach |
802815 |
size_t nlen, rlen = 0;
|
|
Petr Lautrbach |
802815 |
const struct macalg *m;
|
|
Petr Lautrbach |
802815 |
|
|
Petr Lautrbach |
802815 |
- for (m = macs; m->name != NULL; m++) {
|
|
Petr Lautrbach |
802815 |
+ for (m = FIPS_mode() ? fips_macs : all_macs; m->name != NULL; m++) {
|
|
Petr Lautrbach |
802815 |
if (ret != NULL)
|
|
Petr Lautrbach |
802815 |
ret[rlen++] = sep;
|
|
Petr Lautrbach |
802815 |
nlen = strlen(m->name);
|
|
Jakub Jelen |
6cf9b8 |
@@ -136,7 +156,7 @@ mac_setup(struct sshmac *mac, char *name
|
|
Petr Lautrbach |
802815 |
{
|
|
Petr Lautrbach |
802815 |
const struct macalg *m;
|
|
Petr Lautrbach |
802815 |
|
|
Petr Lautrbach |
802815 |
- for (m = macs; m->name != NULL; m++) {
|
|
Petr Lautrbach |
802815 |
+ for (m = FIPS_mode() ? fips_macs : all_macs; m->name != NULL; m++) {
|
|
Petr Lautrbach |
802815 |
if (strcmp(name, m->name) != 0)
|
|
Petr Lautrbach |
802815 |
continue;
|
|
Jakub Jelen |
132f8f |
if (mac != NULL)
|
|
Jakub Jelen |
9dbec7 |
diff -up openssh-7.5p1/Makefile.in.fips openssh-7.5p1/Makefile.in
|
|
Jakub Jelen |
9dbec7 |
--- openssh-7.5p1/Makefile.in.fips 2017-06-30 12:06:36.456713785 +0200
|
|
Jakub Jelen |
9dbec7 |
+++ openssh-7.5p1/Makefile.in 2017-06-30 12:06:36.467713756 +0200
|
|
Jakub Jelen |
6cf9b8 |
@@ -169,25 +169,25 @@ libssh.a: $(LIBSSH_OBJS)
|
|
Jakub Jelen |
535d34 |
$(RANLIB) $@
|
|
Jakub Jelen |
535d34 |
|
|
Jakub Jelen |
535d34 |
ssh$(EXEEXT): $(LIBCOMPAT) libssh.a $(SSHOBJS)
|
|
Jakub Jelen |
535d34 |
- $(LD) -o $@ $(SSHOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(SSHLIBS) $(LIBS) $(GSSLIBS)
|
|
Jakub Jelen |
535d34 |
+ $(LD) -o $@ $(SSHOBJS) $(LDFLAGS) -lssh -lopenbsd-compat -lfipscheck $(SSHLIBS) $(LIBS) $(GSSLIBS)
|
|
Jakub Jelen |
535d34 |
|
|
Jakub Jelen |
535d34 |
sshd$(EXEEXT): libssh.a $(LIBCOMPAT) $(SSHDOBJS)
|
|
Jakub Jelen |
535d34 |
- $(LD) -o $@ $(SSHDOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(SSHDLIBS) $(LIBS) $(GSSLIBS) $(K5LIBS)
|
|
Jakub Jelen |
535d34 |
+ $(LD) -o $@ $(SSHDOBJS) $(LDFLAGS) -lssh -lopenbsd-compat -lfipscheck $(SSHDLIBS) $(LIBS) $(GSSLIBS) $(K5LIBS)
|
|
Jakub Jelen |
535d34 |
|
|
Jakub Jelen |
5878eb |
scp$(EXEEXT): $(LIBCOMPAT) libssh.a scp.o progressmeter.o
|
|
Jakub Jelen |
5878eb |
$(LD) -o $@ scp.o progressmeter.o bufaux.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
|
|
Jakub Jelen |
535d34 |
|
|
Jakub Jelen |
535d34 |
ssh-add$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-add.o
|
|
Jakub Jelen |
535d34 |
- $(LD) -o $@ ssh-add.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
|
|
Jakub Jelen |
535d34 |
+ $(LD) -o $@ ssh-add.o $(LDFLAGS) -lssh -lopenbsd-compat -lfipscheck $(LIBS)
|
|
Jakub Jelen |
535d34 |
|
|
Jakub Jelen |
535d34 |
ssh-agent$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-agent.o ssh-pkcs11-client.o
|
|
Jakub Jelen |
535d34 |
- $(LD) -o $@ ssh-agent.o ssh-pkcs11-client.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
|
|
Jakub Jelen |
535d34 |
+ $(LD) -o $@ ssh-agent.o ssh-pkcs11-client.o $(LDFLAGS) -lssh -lopenbsd-compat -lfipscheck $(LIBS)
|
|
Jakub Jelen |
535d34 |
|
|
Jakub Jelen |
535d34 |
ssh-keygen$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keygen.o
|
|
Jakub Jelen |
535d34 |
- $(LD) -o $@ ssh-keygen.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
|
|
Jakub Jelen |
535d34 |
+ $(LD) -o $@ ssh-keygen.o $(LDFLAGS) -lssh -lopenbsd-compat -lfipscheck $(LIBS)
|
|
Jakub Jelen |
535d34 |
|
|
Jakub Jelen |
13073f |
ssh-keysign$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keysign.o readconf.o
|
|
Jakub Jelen |
13073f |
- $(LD) -o $@ ssh-keysign.o readconf.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
|
|
Jakub Jelen |
13073f |
+ $(LD) -o $@ ssh-keysign.o readconf.o $(LDFLAGS) -lssh -lopenbsd-compat -lfipscheck $(LIBS)
|
|
Jakub Jelen |
535d34 |
|
|
Jakub Jelen |
535d34 |
ssh-pkcs11-helper$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-pkcs11-helper.o ssh-pkcs11.o
|
|
Jakub Jelen |
535d34 |
$(LD) -o $@ ssh-pkcs11-helper.o ssh-pkcs11.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
|
|
Jakub Jelen |
6cf9b8 |
@@ -205,7 +205,7 @@ ssh-cavs$(EXEEXT): $(LIBCOMPAT) libssh.a
|
|
Jakub Jelen |
13073f |
$(LD) -o $@ ssh-cavs.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
|
|
Jakub Jelen |
535d34 |
|
|
Jakub Jelen |
13073f |
ssh-keyscan$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keyscan.o
|
|
Jakub Jelen |
13073f |
- $(LD) -o $@ ssh-keyscan.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh $(LIBS)
|
|
Jakub Jelen |
13073f |
+ $(LD) -o $@ ssh-keyscan.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh -lfipscheck $(LIBS)
|
|
Jakub Jelen |
535d34 |
|
|
Jakub Jelen |
535d34 |
sftp-server$(EXEEXT): $(LIBCOMPAT) libssh.a sftp.o sftp-common.o sftp-server.o sftp-server-main.o
|
|
Jakub Jelen |
535d34 |
$(LD) -o $@ sftp-server.o sftp-common.o sftp-server-main.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
|
|
Jakub Jelen |
9dbec7 |
diff -up openssh-7.5p1/myproposal.h.fips openssh-7.5p1/myproposal.h
|
|
Jakub Jelen |
9dbec7 |
--- openssh-7.5p1/myproposal.h.fips 2017-03-20 03:39:27.000000000 +0100
|
|
Jakub Jelen |
9dbec7 |
+++ openssh-7.5p1/myproposal.h 2017-06-30 12:10:21.953116208 +0200
|
|
Jakub Jelen |
9dbec7 |
@@ -114,6 +114,14 @@
|
|
Jakub Jelen |
9dbec7 |
"rsa-sha2-256," \
|
|
Jakub Jelen |
9dbec7 |
"ssh-rsa"
|
|
Jakub Jelen |
9dbec7 |
|
|
Jakub Jelen |
9dbec7 |
+#define KEX_FIPS_PK_ALG \
|
|
Jakub Jelen |
9dbec7 |
+ HOSTKEY_ECDSA_CERT_METHODS \
|
|
Jakub Jelen |
9dbec7 |
+ "ssh-rsa-cert-v01@openssh.com," \
|
|
Jakub Jelen |
9dbec7 |
+ HOSTKEY_ECDSA_METHODS \
|
|
Jakub Jelen |
9dbec7 |
+ "rsa-sha2-512," \
|
|
Jakub Jelen |
9dbec7 |
+ "rsa-sha2-256," \
|
|
Jakub Jelen |
9dbec7 |
+ "ssh-rsa"
|
|
Jakub Jelen |
9dbec7 |
+
|
|
Jakub Jelen |
9dbec7 |
/* the actual algorithms */
|
|
Jakub Jelen |
9dbec7 |
|
|
Jakub Jelen |
9dbec7 |
#define KEX_SERVER_ENCRYPT \
|
|
Jakub Jelen |
9dbec7 |
@@ -138,6 +146,37 @@
|
|
Jakub Jelen |
13bf5b |
|
|
Jakub Jelen |
13bf5b |
#define KEX_CLIENT_MAC KEX_SERVER_MAC
|
|
Petr Lautrbach |
802815 |
|
|
Petr Lautrbach |
802815 |
+#define KEX_FIPS_ENCRYPT \
|
|
Petr Lautrbach |
802815 |
+ "aes128-ctr,aes192-ctr,aes256-ctr," \
|
|
Petr Lautrbach |
802815 |
+ "aes128-cbc,3des-cbc," \
|
|
Petr Lautrbach |
802815 |
+ "aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se"
|
|
Petr Lautrbach |
802815 |
+#ifdef HAVE_EVP_SHA256
|
|
Jakub Jelen |
eb751f |
+# define KEX_DEFAULT_KEX_FIPS \
|
|
Jakub Jelen |
eb751f |
+ KEX_ECDH_METHODS \
|
|
Jakub Jelen |
eb751f |
+ KEX_SHA2_METHODS \
|
|
Jakub Jelen |
eb751f |
+ "diffie-hellman-group14-sha256"
|
|
Jakub Jelen |
eb751f |
+# define KEX_FIPS_MAC \
|
|
Petr Lautrbach |
802815 |
+ "hmac-sha1," \
|
|
Petr Lautrbach |
802815 |
+ "hmac-sha2-256," \
|
|
Petr Lautrbach |
802815 |
+ "hmac-sha2-512," \
|
|
Petr Lautrbach |
802815 |
+ "hmac-sha1-etm@openssh.com," \
|
|
Petr Lautrbach |
802815 |
+ "hmac-sha2-256-etm@openssh.com," \
|
|
Petr Lautrbach |
802815 |
+ "hmac-sha2-512-etm@openssh.com"
|
|
Petr Lautrbach |
802815 |
+#else
|
|
Jakub Jelen |
eb751f |
+# ifdef OPENSSL_HAS_NISTP521
|
|
Jakub Jelen |
eb751f |
+# define KEX_DEFAULT_KEX_FIPS \
|
|
Jakub Jelen |
eb751f |
+ "ecdh-sha2-nistp256," \
|
|
Jakub Jelen |
eb751f |
+ "ecdh-sha2-nistp384," \
|
|
Jakub Jelen |
eb751f |
+ "ecdh-sha2-nistp521"
|
|
Jakub Jelen |
eb751f |
+# else
|
|
Jakub Jelen |
eb751f |
+# define KEX_DEFAULT_KEX_FIPS \
|
|
Jakub Jelen |
eb751f |
+ "ecdh-sha2-nistp256," \
|
|
Jakub Jelen |
eb751f |
+ "ecdh-sha2-nistp384"
|
|
Jakub Jelen |
eb751f |
+# endif
|
|
Petr Lautrbach |
802815 |
+#define KEX_FIPS_MAC \
|
|
Petr Lautrbach |
802815 |
+ "hmac-sha1"
|
|
Petr Lautrbach |
802815 |
+#endif
|
|
Petr Lautrbach |
190035 |
+
|
|
Jakub Jelen |
13bf5b |
#else /* WITH_OPENSSL */
|
|
Petr Lautrbach |
802815 |
|
|
Petr Lautrbach |
190035 |
#define KEX_SERVER_KEX \
|
|
Jakub Jelen |
9dbec7 |
diff -up openssh-7.5p1/pam_ssh_agent_auth-0.10.3/pam_user_key_allowed2.c.fips openssh-7.5p1/pam_ssh_agent_auth-0.10.3/pam_user_key_allowed2.c
|
|
Jakub Jelen |
9dbec7 |
--- openssh-7.5p1/pam_ssh_agent_auth-0.10.3/pam_user_key_allowed2.c.fips 2017-06-30 12:06:36.340714098 +0200
|
|
Jakub Jelen |
9dbec7 |
+++ openssh-7.5p1/pam_ssh_agent_auth-0.10.3/pam_user_key_allowed2.c 2017-06-30 12:06:36.467713756 +0200
|
|
Jakub Jelen |
6cf9b8 |
@@ -55,6 +55,7 @@
|
|
Jakub Jelen |
6cf9b8 |
#include "secure_filename.h"
|
|
Jakub Jelen |
6cf9b8 |
#include "uidswap.h"
|
|
Jakub Jelen |
6cf9b8 |
#include <unistd.h>
|
|
Jakub Jelen |
6cf9b8 |
+#include <openssl/crypto.h>
|
|
Jakub Jelen |
6cf9b8 |
|
|
Jakub Jelen |
6cf9b8 |
#include "identity.h"
|
|
Jakub Jelen |
6cf9b8 |
|
|
Jakub Jelen |
6cf9b8 |
@@ -104,7 +105,8 @@ pamsshagentauth_check_authkeys_file(FILE
|
|
Jakub Jelen |
6cf9b8 |
found_key = 1;
|
|
Jakub Jelen |
6cf9b8 |
logit("matching key found: file/command %s, line %lu", file,
|
|
Jakub Jelen |
6cf9b8 |
linenum);
|
|
Jakub Jelen |
6cf9b8 |
- fp = sshkey_fingerprint(found, SSH_DIGEST_MD5, SSH_FP_HEX);
|
|
Jakub Jelen |
6cf9b8 |
+ fp = sshkey_fingerprint(found, FIPS_mode() ? SSH_DIGEST_SHA1 : SSH_DIGEST_MD5,
|
|
Jakub Jelen |
6cf9b8 |
+ SSH_FP_HEX);
|
|
Jakub Jelen |
6cf9b8 |
logit("Found matching %s key: %s",
|
|
Jakub Jelen |
5b55d0 |
sshkey_type(found), fp);
|
|
Jakub Jelen |
6cf9b8 |
free(fp);
|
|
Jakub Jelen |
9dbec7 |
diff -up openssh-7.5p1/readconf.c.fips openssh-7.5p1/readconf.c
|
|
Jakub Jelen |
9dbec7 |
--- openssh-7.5p1/readconf.c.fips 2017-06-30 12:06:36.468713753 +0200
|
|
Jakub Jelen |
9dbec7 |
+++ openssh-7.5p1/readconf.c 2017-06-30 12:12:40.560769198 +0200
|
|
Jakub Jelen |
9dbec7 |
@@ -2132,12 +2132,17 @@ fill_default_options(Options * options)
|
|
Jakub Jelen |
4df30a |
}
|
|
Jakub Jelen |
3f5513 |
if (options->update_hostkeys == -1)
|
|
Jakub Jelen |
3f5513 |
options->update_hostkeys = 0;
|
|
Jakub Jelen |
3f5513 |
- if (kex_assemble_names(KEX_CLIENT_ENCRYPT, &options->ciphers) != 0 ||
|
|
Jakub Jelen |
3f5513 |
- kex_assemble_names(KEX_CLIENT_MAC, &options->macs) != 0 ||
|
|
Jakub Jelen |
3f5513 |
- kex_assemble_names(KEX_CLIENT_KEX, &options->kex_algorithms) != 0 ||
|
|
Jakub Jelen |
9dbec7 |
- kex_assemble_names(KEX_DEFAULT_PK_ALG,
|
|
Jakub Jelen |
3f5513 |
+ if (kex_assemble_names((FIPS_mode() ? KEX_FIPS_ENCRYPT
|
|
Jakub Jelen |
3f5513 |
+ : KEX_CLIENT_ENCRYPT), &options->ciphers) != 0 ||
|
|
Jakub Jelen |
3f5513 |
+ kex_assemble_names((FIPS_mode() ? KEX_FIPS_MAC
|
|
Jakub Jelen |
3f5513 |
+ : KEX_CLIENT_MAC), &options->macs) != 0 ||
|
|
Jakub Jelen |
3f5513 |
+ kex_assemble_names((FIPS_mode() ? KEX_DEFAULT_KEX_FIPS
|
|
Jakub Jelen |
3f5513 |
+ : KEX_CLIENT_KEX), &options->kex_algorithms) != 0 ||
|
|
Jakub Jelen |
9dbec7 |
+ kex_assemble_names((FIPS_mode() ? KEX_FIPS_PK_ALG
|
|
Jakub Jelen |
9dbec7 |
+ : KEX_DEFAULT_PK_ALG),
|
|
Jakub Jelen |
3f5513 |
&options->hostbased_key_types) != 0 ||
|
|
Jakub Jelen |
9dbec7 |
- kex_assemble_names(KEX_DEFAULT_PK_ALG,
|
|
Jakub Jelen |
9dbec7 |
+ kex_assemble_names((FIPS_mode() ? KEX_FIPS_PK_ALG
|
|
Jakub Jelen |
9dbec7 |
+ : KEX_DEFAULT_PK_ALG),
|
|
Jakub Jelen |
9dbec7 |
&options->pubkey_key_types) != 0)
|
|
Jakub Jelen |
9dbec7 |
fatal("%s: kex_assemble_names failed", __func__);
|
|
Jakub Jelen |
9dbec7 |
|
|
Jakub Jelen |
9dbec7 |
diff -up openssh-7.5p1/sandbox-seccomp-filter.c.fips openssh-7.5p1/sandbox-seccomp-filter.c
|
|
Jakub Jelen |
9dbec7 |
--- openssh-7.5p1/sandbox-seccomp-filter.c.fips 2017-06-30 12:06:36.458713780 +0200
|
|
Jakub Jelen |
9dbec7 |
+++ openssh-7.5p1/sandbox-seccomp-filter.c 2017-06-30 12:06:36.468713753 +0200
|
|
Jakub Jelen |
9dbec7 |
@@ -137,6 +137,9 @@ static const struct sock_filter preauth_
|
|
Jakub Jelen |
6cf9b8 |
#ifdef __NR_open
|
|
Jakub Jelen |
17b491 |
SC_DENY(__NR_open, EACCES),
|
|
Jakub Jelen |
6cf9b8 |
#endif
|
|
Jakub Jelen |
6cf9b8 |
+#ifdef __NR_socket
|
|
Jakub Jelen |
17b491 |
+ SC_DENY(__NR_socket, EACCES),
|
|
Jakub Jelen |
6cf9b8 |
+#endif
|
|
Jakub Jelen |
6cf9b8 |
#ifdef __NR_openat
|
|
Jakub Jelen |
17b491 |
SC_DENY(__NR_openat, EACCES),
|
|
Jakub Jelen |
6cf9b8 |
#endif
|
|
Jakub Jelen |
9dbec7 |
diff -up openssh-7.5p1/servconf.c.fips openssh-7.5p1/servconf.c
|
|
Jakub Jelen |
9dbec7 |
--- openssh-7.5p1/servconf.c.fips 2017-06-30 12:06:36.468713753 +0200
|
|
Jakub Jelen |
9dbec7 |
+++ openssh-7.5p1/servconf.c 2017-06-30 12:14:09.260547133 +0200
|
|
Jakub Jelen |
9dbec7 |
@@ -185,14 +185,20 @@ option_clear_or_none(const char *o)
|
|
Jakub Jelen |
13bf5b |
static void
|
|
Jakub Jelen |
13bf5b |
assemble_algorithms(ServerOptions *o)
|
|
Jakub Jelen |
13bf5b |
{
|
|
Jakub Jelen |
13bf5b |
- if (kex_assemble_names(KEX_SERVER_ENCRYPT, &o->ciphers) != 0 ||
|
|
Jakub Jelen |
13bf5b |
- kex_assemble_names(KEX_SERVER_MAC, &o->macs) != 0 ||
|
|
Jakub Jelen |
13bf5b |
- kex_assemble_names(KEX_SERVER_KEX, &o->kex_algorithms) != 0 ||
|
|
Jakub Jelen |
9dbec7 |
- kex_assemble_names(KEX_DEFAULT_PK_ALG,
|
|
Jakub Jelen |
3f5513 |
+ if (kex_assemble_names((FIPS_mode() ? KEX_FIPS_ENCRYPT
|
|
Jakub Jelen |
13bf5b |
+ : KEX_SERVER_ENCRYPT), &o->ciphers) != 0 ||
|
|
Jakub Jelen |
3f5513 |
+ kex_assemble_names((FIPS_mode() ? KEX_FIPS_MAC
|
|
Jakub Jelen |
13bf5b |
+ : KEX_SERVER_MAC), &o->macs) != 0 ||
|
|
Jakub Jelen |
3f5513 |
+ kex_assemble_names((FIPS_mode() ? KEX_DEFAULT_KEX_FIPS
|
|
Jakub Jelen |
13bf5b |
+ : KEX_SERVER_KEX), &o->kex_algorithms) != 0 ||
|
|
Jakub Jelen |
9dbec7 |
+ kex_assemble_names((FIPS_mode() ? KEX_FIPS_PK_ALG
|
|
Jakub Jelen |
9dbec7 |
+ : KEX_DEFAULT_PK_ALG),
|
|
Jakub Jelen |
13bf5b |
&o->hostkeyalgorithms) != 0 ||
|
|
Jakub Jelen |
9dbec7 |
- kex_assemble_names(KEX_DEFAULT_PK_ALG,
|
|
Jakub Jelen |
9dbec7 |
+ kex_assemble_names((FIPS_mode() ? KEX_FIPS_PK_ALG
|
|
Jakub Jelen |
9dbec7 |
+ : KEX_DEFAULT_PK_ALG),
|
|
Jakub Jelen |
9dbec7 |
&o->hostbased_key_types) != 0 ||
|
|
Jakub Jelen |
9dbec7 |
- kex_assemble_names(KEX_DEFAULT_PK_ALG, &o->pubkey_key_types) != 0)
|
|
Jakub Jelen |
9dbec7 |
+ kex_assemble_names((FIPS_mode() ? KEX_FIPS_PK_ALG
|
|
Jakub Jelen |
9dbec7 |
+ : KEX_DEFAULT_PK_ALG), &o->pubkey_key_types) != 0)
|
|
Jakub Jelen |
9dbec7 |
fatal("kex_assemble_names failed");
|
|
Jakub Jelen |
9dbec7 |
}
|
|
Jakub Jelen |
9dbec7 |
|
|
Jakub Jelen |
9dbec7 |
diff -up openssh-7.5p1/ssh.c.fips openssh-7.5p1/ssh.c
|
|
Jakub Jelen |
9dbec7 |
--- openssh-7.5p1/ssh.c.fips 2017-03-20 03:39:27.000000000 +0100
|
|
Jakub Jelen |
9dbec7 |
+++ openssh-7.5p1/ssh.c 2017-06-30 12:06:36.469713750 +0200
|
|
Jakub Jelen |
6cf9b8 |
@@ -76,6 +76,8 @@
|
|
Petr Lautrbach |
802815 |
#include <openssl/evp.h>
|
|
Petr Lautrbach |
802815 |
#include <openssl/err.h>
|
|
Petr Lautrbach |
190035 |
#endif
|
|
Petr Lautrbach |
802815 |
+#include <openssl/fips.h>
|
|
Petr Lautrbach |
802815 |
+#include <fipscheck.h>
|
|
Petr Lautrbach |
802815 |
#include "openbsd-compat/openssl-compat.h"
|
|
Petr Lautrbach |
802815 |
#include "openbsd-compat/sys-queue.h"
|
|
Petr Lautrbach |
802815 |
|
|
Jakub Jelen |
6cf9b8 |
@@ -530,6 +532,14 @@ main(int ac, char **av)
|
|
Petr Lautrbach |
802815 |
sanitise_stdfd();
|
|
Petr Lautrbach |
802815 |
|
|
Petr Lautrbach |
802815 |
__progname = ssh_get_progname(av[0]);
|
|
Petr Lautrbach |
802815 |
+ SSLeay_add_all_algorithms();
|
|
Petr Lautrbach |
802815 |
+ if (access("/etc/system-fips", F_OK) == 0)
|
|
Jakub Jelen |
580f98 |
+ if (! FIPSCHECK_verify(NULL, NULL)){
|
|
Petr Lautrbach |
802815 |
+ if (FIPS_mode())
|
|
Petr Lautrbach |
802815 |
+ fatal("FIPS integrity verification test failed.");
|
|
Petr Lautrbach |
802815 |
+ else
|
|
Petr Lautrbach |
802815 |
+ logit("FIPS integrity verification test failed.");
|
|
Jakub Jelen |
580f98 |
+ }
|
|
Petr Lautrbach |
802815 |
|
|
Petr Lautrbach |
802815 |
#ifndef HAVE_SETPROCTITLE
|
|
Petr Lautrbach |
802815 |
/* Prepare for later setproctitle emulation */
|
|
Jakub Jelen |
6cf9b8 |
@@ -964,7 +977,6 @@ main(int ac, char **av)
|
|
Petr Lautrbach |
802815 |
host_arg = xstrdup(host);
|
|
Petr Lautrbach |
802815 |
|
|
Petr Lautrbach |
190035 |
#ifdef WITH_OPENSSL
|
|
Petr Lautrbach |
802815 |
- OpenSSL_add_all_algorithms();
|
|
Petr Lautrbach |
802815 |
ERR_load_crypto_strings();
|
|
Petr Lautrbach |
190035 |
#endif
|
|
Petr Lautrbach |
802815 |
|
|
Jakub Jelen |
6cf9b8 |
@@ -1175,6 +1187,10 @@ main(int ac, char **av)
|
|
Petr Lautrbach |
802815 |
|
|
Petr Lautrbach |
802815 |
seed_rng();
|
|
Petr Lautrbach |
802815 |
|
|
Petr Lautrbach |
802815 |
+ if (FIPS_mode()) {
|
|
Petr Lautrbach |
802815 |
+ logit("FIPS mode initialized");
|
|
Petr Lautrbach |
802815 |
+ }
|
|
Petr Lautrbach |
802815 |
+
|
|
Petr Lautrbach |
802815 |
if (options.user == NULL)
|
|
Petr Lautrbach |
802815 |
options.user = xstrdup(pw->pw_name);
|
|
Petr Lautrbach |
802815 |
|
|
Jakub Jelen |
9dbec7 |
diff -up openssh-7.5p1/sshconnect2.c.fips openssh-7.5p1/sshconnect2.c
|
|
Jakub Jelen |
9dbec7 |
--- openssh-7.5p1/sshconnect2.c.fips 2017-06-30 12:06:36.439713831 +0200
|
|
Jakub Jelen |
9dbec7 |
+++ openssh-7.5p1/sshconnect2.c 2017-06-30 12:06:36.469713750 +0200
|
|
Jakub Jelen |
3f5513 |
@@ -44,6 +44,8 @@
|
|
Petr Lautrbach |
802815 |
#include <vis.h>
|
|
Petr Lautrbach |
802815 |
#endif
|
|
Petr Lautrbach |
802815 |
|
|
Petr Lautrbach |
802815 |
+#include <openssl/fips.h>
|
|
Petr Lautrbach |
802815 |
+
|
|
Petr Lautrbach |
802815 |
#include "openbsd-compat/sys-queue.h"
|
|
Petr Lautrbach |
802815 |
|
|
Petr Lautrbach |
802815 |
#include "xmalloc.h"
|
|
Jakub Jelen |
9dbec7 |
@@ -117,7 +119,8 @@ order_hostkeyalgs(char *host, struct soc
|
|
Jakub Jelen |
9dbec7 |
for (i = 0; i < options.num_system_hostfiles; i++)
|
|
Jakub Jelen |
9dbec7 |
load_hostkeys(hostkeys, hostname, options.system_hostfiles[i]);
|
|
Jakub Jelen |
9dbec7 |
|
|
Jakub Jelen |
9dbec7 |
- oavail = avail = xstrdup(KEX_DEFAULT_PK_ALG);
|
|
Jakub Jelen |
9dbec7 |
+ oavail = avail = xstrdup((FIPS_mode()
|
|
Jakub Jelen |
9dbec7 |
+ ? KEX_FIPS_PK_ALG : KEX_DEFAULT_PK_ALG));
|
|
Jakub Jelen |
9dbec7 |
maxlen = strlen(avail) + 1;
|
|
Jakub Jelen |
9dbec7 |
first = xmalloc(maxlen);
|
|
Jakub Jelen |
9dbec7 |
last = xmalloc(maxlen);
|
|
Jakub Jelen |
9dbec7 |
@@ -172,21 +175,26 @@ ssh_kex2(char *host, struct sockaddr *ho
|
|
Petr Lautrbach |
802815 |
|
|
Petr Lautrbach |
802815 |
#ifdef GSSAPI
|
|
Petr Lautrbach |
802815 |
if (options.gss_keyex) {
|
|
Petr Lautrbach |
802815 |
- /* Add the GSSAPI mechanisms currently supported on this
|
|
Petr Lautrbach |
802815 |
- * client to the key exchange algorithm proposal */
|
|
Jakub Jelen |
9a804f |
- orig = options.kex_algorithms;
|
|
Jakub Jelen |
132f8f |
-
|
|
Jakub Jelen |
132f8f |
- if (options.gss_trust_dns)
|
|
Jakub Jelen |
b487a6 |
- gss_host = (char *)get_canonical_hostname(active_state, 1);
|
|
Jakub Jelen |
132f8f |
- else
|
|
Jakub Jelen |
132f8f |
- gss_host = host;
|
|
Jakub Jelen |
132f8f |
-
|
|
Jakub Jelen |
bc4ef0 |
- gss = ssh_gssapi_client_mechanisms(gss_host,
|
|
Jakub Jelen |
bc4ef0 |
- options.gss_client_identity, options.gss_kex_algorithms);
|
|
Jakub Jelen |
132f8f |
- if (gss) {
|
|
Jakub Jelen |
132f8f |
- debug("Offering GSSAPI proposal: %s", gss);
|
|
Jakub Jelen |
9a804f |
- xasprintf(&options.kex_algorithms,
|
|
Jakub Jelen |
132f8f |
- "%s,%s", gss, orig);
|
|
Petr Lautrbach |
802815 |
+ if (FIPS_mode()) {
|
|
Petr Lautrbach |
802815 |
+ logit("Disabling GSSAPIKeyExchange. Not usable in FIPS mode");
|
|
Petr Lautrbach |
802815 |
+ options.gss_keyex = 0;
|
|
Petr Lautrbach |
802815 |
+ } else {
|
|
Petr Lautrbach |
802815 |
+ /* Add the GSSAPI mechanisms currently supported on this
|
|
Petr Lautrbach |
802815 |
+ * client to the key exchange algorithm proposal */
|
|
Jakub Jelen |
9a804f |
+ orig = options.kex_algorithms;
|
|
Jakub Jelen |
132f8f |
+
|
|
Petr Lautrbach |
802815 |
+ if (options.gss_trust_dns)
|
|
Jakub Jelen |
b487a6 |
+ gss_host = (char *)get_canonical_hostname(active_state, 1);
|
|
Petr Lautrbach |
802815 |
+ else
|
|
Petr Lautrbach |
802815 |
+ gss_host = host;
|
|
Jakub Jelen |
132f8f |
+
|
|
Jakub Jelen |
bc4ef0 |
+ gss = ssh_gssapi_client_mechanisms(gss_host,
|
|
Jakub Jelen |
bc4ef0 |
+ options.gss_client_identity, options.gss_kex_algorithms);
|
|
Petr Lautrbach |
802815 |
+ if (gss) {
|
|
Petr Lautrbach |
802815 |
+ debug("Offering GSSAPI proposal: %s", gss);
|
|
Jakub Jelen |
9a804f |
+ xasprintf(&options.kex_algorithms,
|
|
Petr Lautrbach |
802815 |
+ "%s,%s", gss, orig);
|
|
Petr Lautrbach |
802815 |
+ }
|
|
Petr Lautrbach |
802815 |
}
|
|
Petr Lautrbach |
802815 |
}
|
|
Petr Lautrbach |
802815 |
#endif
|
|
Jakub Jelen |
9dbec7 |
@@ -204,14 +212,16 @@ ssh_kex2(char *host, struct sockaddr *ho
|
|
Jakub Jelen |
9dbec7 |
myproposal[PROPOSAL_MAC_ALGS_CTOS] =
|
|
Jakub Jelen |
9dbec7 |
myproposal[PROPOSAL_MAC_ALGS_STOC] = options.macs;
|
|
Jakub Jelen |
9dbec7 |
if (options.hostkeyalgorithms != NULL) {
|
|
Jakub Jelen |
9dbec7 |
- if (kex_assemble_names(KEX_DEFAULT_PK_ALG,
|
|
Jakub Jelen |
9dbec7 |
+ if (kex_assemble_names((FIPS_mode() ? KEX_FIPS_PK_ALG
|
|
Jakub Jelen |
9dbec7 |
+ : KEX_DEFAULT_PK_ALG),
|
|
Jakub Jelen |
9dbec7 |
&options.hostkeyalgorithms) != 0)
|
|
Jakub Jelen |
9dbec7 |
fatal("%s: kex_assemble_namelist", __func__);
|
|
Jakub Jelen |
9dbec7 |
myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] =
|
|
Jakub Jelen |
9dbec7 |
compat_pkalg_proposal(options.hostkeyalgorithms);
|
|
Jakub Jelen |
9dbec7 |
} else {
|
|
Jakub Jelen |
9dbec7 |
/* Enforce default */
|
|
Jakub Jelen |
9dbec7 |
- options.hostkeyalgorithms = xstrdup(KEX_DEFAULT_PK_ALG);
|
|
Jakub Jelen |
9dbec7 |
+ options.hostkeyalgorithms = xstrdup((FIPS_mode()
|
|
Jakub Jelen |
9dbec7 |
+ ? KEX_FIPS_PK_ALG : KEX_DEFAULT_PK_ALG));
|
|
Jakub Jelen |
9dbec7 |
/* Prefer algorithms that we already have keys for */
|
|
Jakub Jelen |
9dbec7 |
myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] =
|
|
Jakub Jelen |
9dbec7 |
compat_pkalg_proposal(
|
|
Jakub Jelen |
9dbec7 |
diff -up openssh-7.5p1/sshd.c.fips openssh-7.5p1/sshd.c
|
|
Jakub Jelen |
9dbec7 |
--- openssh-7.5p1/sshd.c.fips 2017-06-30 12:06:36.459713777 +0200
|
|
Jakub Jelen |
9dbec7 |
+++ openssh-7.5p1/sshd.c 2017-06-30 12:06:36.469713750 +0200
|
|
Petr Lautrbach |
190035 |
@@ -66,6 +66,7 @@
|
|
Petr Lautrbach |
190035 |
#include <grp.h>
|
|
Petr Lautrbach |
190035 |
#include <pwd.h>
|
|
Petr Lautrbach |
190035 |
#include <signal.h>
|
|
Petr Lautrbach |
190035 |
+#include <syslog.h>
|
|
Petr Lautrbach |
190035 |
#include <stdarg.h>
|
|
Petr Lautrbach |
190035 |
#include <stdio.h>
|
|
Petr Lautrbach |
190035 |
#include <stdlib.h>
|
|
Jakub Jelen |
132f8f |
@@ -77,6 +78,8 @@
|
|
Petr Lautrbach |
802815 |
#include <openssl/dh.h>
|
|
Petr Lautrbach |
802815 |
#include <openssl/bn.h>
|
|
Petr Lautrbach |
802815 |
#include <openssl/rand.h>
|
|
Petr Lautrbach |
802815 |
+#include <openssl/fips.h>
|
|
Petr Lautrbach |
802815 |
+#include <fipscheck.h>
|
|
Petr Lautrbach |
802815 |
#include "openbsd-compat/openssl-compat.h"
|
|
Petr Lautrbach |
190035 |
#endif
|
|
Petr Lautrbach |
802815 |
|
|
Jakub Jelen |
9dbec7 |
@@ -1484,6 +1487,18 @@ main(int ac, char **av)
|
|
Petr Lautrbach |
802815 |
#endif
|
|
Petr Lautrbach |
802815 |
__progname = ssh_get_progname(av[0]);
|
|
Petr Lautrbach |
802815 |
|
|
Petr Lautrbach |
802815 |
+ SSLeay_add_all_algorithms();
|
|
Petr Lautrbach |
802815 |
+ if (access("/etc/system-fips", F_OK) == 0)
|
|
Petr Lautrbach |
802815 |
+ if (! FIPSCHECK_verify(NULL, NULL)) {
|
|
Petr Lautrbach |
802815 |
+ openlog(__progname, LOG_PID, LOG_AUTHPRIV);
|
|
Petr Lautrbach |
802815 |
+ if (FIPS_mode()) {
|
|
Petr Lautrbach |
802815 |
+ syslog(LOG_CRIT, "FIPS integrity verification test failed.");
|
|
Petr Lautrbach |
802815 |
+ cleanup_exit(255);
|
|
Petr Lautrbach |
802815 |
+ }
|
|
Petr Lautrbach |
802815 |
+ else
|
|
Petr Lautrbach |
802815 |
+ syslog(LOG_INFO, "FIPS integrity verification test failed.");
|
|
Petr Lautrbach |
802815 |
+ closelog();
|
|
Petr Lautrbach |
802815 |
+ }
|
|
Petr Lautrbach |
802815 |
/* Save argv. Duplicate so setproctitle emulation doesn't clobber it */
|
|
Petr Lautrbach |
802815 |
saved_argc = ac;
|
|
Petr Lautrbach |
802815 |
rexec_argc = ac;
|
|
Jakub Jelen |
9dbec7 |
@@ -1632,7 +1647,7 @@ main(int ac, char **av)
|
|
Petr Lautrbach |
802815 |
else
|
|
Petr Lautrbach |
802815 |
closefrom(REEXEC_DEVCRYPTO_RESERVED_FD);
|
|
Petr Lautrbach |
802815 |
|
|
Petr Lautrbach |
190035 |
-#ifdef WITH_OPENSSL
|
|
Petr Lautrbach |
190035 |
+#if 0 /* FIPS */
|
|
Petr Lautrbach |
190035 |
OpenSSL_add_all_algorithms();
|
|
Petr Lautrbach |
190035 |
#endif
|
|
Petr Lautrbach |
190035 |
|
|
Jakub Jelen |
9dbec7 |
@@ -1951,6 +1966,10 @@ main(int ac, char **av)
|
|
Petr Lautrbach |
802815 |
/* Reinitialize the log (because of the fork above). */
|
|
Petr Lautrbach |
802815 |
log_init(__progname, options.log_level, options.log_facility, log_stderr);
|
|
Petr Lautrbach |
802815 |
|
|
Petr Lautrbach |
802815 |
+ if (FIPS_mode()) {
|
|
Petr Lautrbach |
802815 |
+ logit("FIPS mode initialized");
|
|
Petr Lautrbach |
802815 |
+ }
|
|
Petr Lautrbach |
802815 |
+
|
|
Petr Lautrbach |
802815 |
/* Chdir to the root directory so that the current disk can be
|
|
Petr Lautrbach |
802815 |
unmounted if desired. */
|
|
Petr Lautrbach |
802815 |
if (chdir("/") == -1)
|
|
Jakub Jelen |
9dbec7 |
@@ -2328,10 +2347,14 @@ do_ssh2_kex(void)
|
|
Petr Lautrbach |
802815 |
if (strlen(myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS]) == 0)
|
|
Petr Lautrbach |
802815 |
orig = NULL;
|
|
Petr Lautrbach |
802815 |
|
|
Petr Lautrbach |
802815 |
- if (options.gss_keyex)
|
|
Petr Lautrbach |
802815 |
- gss = ssh_gssapi_server_mechanisms();
|
|
Petr Lautrbach |
802815 |
- else
|
|
Petr Lautrbach |
802815 |
- gss = NULL;
|
|
Petr Lautrbach |
802815 |
+ if (options.gss_keyex) {
|
|
Petr Lautrbach |
802815 |
+ if (FIPS_mode()) {
|
|
Petr Lautrbach |
802815 |
+ logit("Disabling GSSAPIKeyExchange. Not usable in FIPS mode");
|
|
Petr Lautrbach |
802815 |
+ options.gss_keyex = 0;
|
|
Petr Lautrbach |
802815 |
+ } else {
|
|
Petr Lautrbach |
802815 |
+ gss = ssh_gssapi_server_mechanisms();
|
|
Petr Lautrbach |
802815 |
+ }
|
|
Petr Lautrbach |
802815 |
+ }
|
|
Petr Lautrbach |
802815 |
|
|
Petr Lautrbach |
802815 |
if (gss && orig)
|
|
Petr Lautrbach |
802815 |
xasprintf(&newstr, "%s,%s", gss, orig);
|
|
Jakub Jelen |
9dbec7 |
diff -up openssh-7.5p1/sshkey.c.fips openssh-7.5p1/sshkey.c
|
|
Jakub Jelen |
9dbec7 |
--- openssh-7.5p1/sshkey.c.fips 2017-06-30 12:06:36.459713777 +0200
|
|
Jakub Jelen |
9dbec7 |
+++ openssh-7.5p1/sshkey.c 2017-06-30 12:06:36.470713747 +0200
|
|
Jakub Jelen |
6cf9b8 |
@@ -34,6 +34,7 @@
|
|
Petr Lautrbach |
190035 |
#include <openssl/evp.h>
|
|
Petr Lautrbach |
190035 |
#include <openssl/err.h>
|
|
Petr Lautrbach |
190035 |
#include <openssl/pem.h>
|
|
Petr Lautrbach |
190035 |
+#include <openssl/fips.h>
|
|
Jakub Jelen |
132f8f |
#endif
|
|
Petr Lautrbach |
190035 |
|
|
Petr Lautrbach |
190035 |
#include "crypto_api.h"
|
|
Jakub Jelen |
9dbec7 |
@@ -58,6 +59,7 @@
|
|
Jakub Jelen |
84d398 |
#include "sshkey.h"
|
|
Jakub Jelen |
3cd489 |
#include "sshkey-xmss.h"
|
|
Jakub Jelen |
84d398 |
#include "match.h"
|
|
Jakub Jelen |
9dbec7 |
+#include "log.h"
|
|
Jakub Jelen |
84d398 |
|
|
Jakub Jelen |
3cd489 |
#include "xmss_fast.h"
|
|
Jakub Jelen |
3cd489 |
|
|
Jakub Jelen |
9dbec7 |
@@ -1587,6 +1589,8 @@ rsa_generate_private_key(u_int bits, RSA
|
|
Petr Lautrbach |
190035 |
}
|
|
Petr Lautrbach |
190035 |
if (!BN_set_word(f4, RSA_F4) ||
|
|
Petr Lautrbach |
190035 |
!RSA_generate_key_ex(private, bits, f4, NULL)) {
|
|
Petr Lautrbach |
190035 |
+ if (FIPS_mode())
|
|
Petr Lautrbach |
190035 |
+ logit("%s: the key length might be unsupported by FIPS mode approved key generation method", __func__);
|
|
Petr Lautrbach |
190035 |
ret = SSH_ERR_LIBCRYPTO_ERROR;
|
|
Petr Lautrbach |
190035 |
goto out;
|
|
Petr Lautrbach |
190035 |
}
|
|
Jakub Jelen |
9dbec7 |
diff -up openssh-7.5p1/ssh-keygen.c.fips openssh-7.5p1/ssh-keygen.c
|
|
Jakub Jelen |
9dbec7 |
--- openssh-7.5p1/ssh-keygen.c.fips 2017-03-20 03:39:27.000000000 +0100
|
|
Jakub Jelen |
9dbec7 |
+++ openssh-7.5p1/ssh-keygen.c 2017-06-30 12:06:36.470713747 +0200
|
|
Jakub Jelen |
9dbec7 |
@@ -217,6 +217,12 @@ type_bits_valid(int type, const char *na
|
|
Jakub Jelen |
9dbec7 |
OPENSSL_DSA_MAX_MODULUS_BITS : OPENSSL_RSA_MAX_MODULUS_BITS;
|
|
Jakub Jelen |
9dbec7 |
if (*bitsp > maxbits)
|
|
Jakub Jelen |
9dbec7 |
fatal("key bits exceeds maximum %d", maxbits);
|
|
Jakub Jelen |
9dbec7 |
+ if (FIPS_mode()) {
|
|
Jakub Jelen |
9dbec7 |
+ if (type == KEY_DSA)
|
|
Jakub Jelen |
9dbec7 |
+ fatal("DSA keys are not allowed in FIPS mode");
|
|
Jakub Jelen |
9dbec7 |
+ if (type == KEY_ED25519)
|
|
Jakub Jelen |
9dbec7 |
+ fatal("ED25519 keys are not allowed in FIPS mode");
|
|
Jakub Jelen |
9dbec7 |
+ }
|
|
Jakub Jelen |
5b55d0 |
switch (type) {
|
|
Jakub Jelen |
5b55d0 |
case KEY_DSA:
|
|
Jakub Jelen |
5b55d0 |
if (*bitsp != 1024)
|