components/openssh/patches/035-fips.patch
author Tomas Kuthan <tomas.kuthan@oracle.com>
Wed, 20 Apr 2016 13:13:57 -0700
changeset 5819 c5f05bd2a9bc
parent 5310 a06a01eef195
child 6930 31ef2580c45d
permissions -rw-r--r--
PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates 22931214 upgrade OpenSSH to 7.2p2 22931349 problem in UTILITY/OPENSSH 20955968 remove servconf.c portion of 003-last_login.patch when upgrading to OpenSSH 7.2 22489925 Re-enable Curve25519 in OpenSSH
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5310
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
     1
#
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
     2
# Dynamically set FIPS mode, when underlying libcrypto is FIPS capable.
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
     3
# Limit ciphers and MACs in algorithm negotiation proposal.
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
     4
#
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
     5
# This patch is unlikely to be accepted upstream.
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
     6
#
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
     7
diff -pur old/cipher.c new/cipher.c
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
     8
--- old/cipher.c
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
     9
+++ new/cipher.c
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    10
@@ -77,7 +77,34 @@ struct sshcipher {
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    11
 #endif
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    12
 };
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    13
 
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    14
+#ifdef ENABLE_OPENSSL_FIPS
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    15
+/* in FIPS mode limit ciphers to FIPS compliant only */
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    16
+#define	ciphers (ssh_FIPS_mode() ? ciphers_fips : ciphers_dflt)
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    17
+
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    18
+static const struct sshcipher ciphers_fips[] = {
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    19
+	{ "none",	SSH_CIPHER_NONE, 8, 0, 0, 0, 0, 0, EVP_enc_null },
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    20
+	{ "3des-cbc",	SSH_CIPHER_SSH2, 8, 24, 0, 0, 0, 1, EVP_des_ede3_cbc },
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    21
+	{ "aes128-cbc",	SSH_CIPHER_SSH2, 16, 16, 0, 0, 0, 1, EVP_aes_128_cbc },
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    22
+	{ "aes192-cbc",	SSH_CIPHER_SSH2, 16, 24, 0, 0, 0, 1, EVP_aes_192_cbc },
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    23
+	{ "aes256-cbc",	SSH_CIPHER_SSH2, 16, 32, 0, 0, 0, 1, EVP_aes_256_cbc },
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    24
+	{ "[email protected]",
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    25
+			SSH_CIPHER_SSH2, 16, 32, 0, 0, 0, 1, EVP_aes_256_cbc },
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    26
+	{ "aes128-ctr",	SSH_CIPHER_SSH2, 16, 16, 0, 0, 0, 0, EVP_aes_128_ctr },
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    27
+	{ "aes192-ctr",	SSH_CIPHER_SSH2, 16, 24, 0, 0, 0, 0, EVP_aes_192_ctr },
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    28
+	{ "aes256-ctr",	SSH_CIPHER_SSH2, 16, 32, 0, 0, 0, 0, EVP_aes_256_ctr },
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    29
+# ifdef OPENSSL_HAVE_EVPGCM
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    30
+	{ "[email protected]",
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    31
+			SSH_CIPHER_SSH2, 16, 16, 12, 16, 0, 0, EVP_aes_128_gcm },
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    32
+	{ "[email protected]",
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    33
+			SSH_CIPHER_SSH2, 16, 32, 12, 16, 0, 0, EVP_aes_256_gcm },
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    34
+# endif /* OPENSSL_HAVE_EVPGCM */
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    35
+	{ NULL,		SSH_CIPHER_INVALID, 0, 0, 0, 0, 0, 0, NULL }
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    36
+};
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    37
+
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    38
+static const struct sshcipher ciphers_dflt[] = {
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    39
+#else /* ENABLE_OPENSSL_FIPS */
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    40
 static const struct sshcipher ciphers[] = {
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    41
+#endif /* ENABLE_OPENSSL_FIPS */
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    42
 #ifdef WITH_SSH1
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    43
 	{ "des",	SSH_CIPHER_DES, 8, 8, 0, 0, 0, 1, EVP_des_cbc },
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    44
 	{ "3des",	SSH_CIPHER_3DES, 8, 16, 0, 0, 0, 1, evp_ssh1_3des },
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    45
diff -pur old/digest-openssl.c new/digest-openssl.c
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    46
--- old/digest-openssl.c
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    47
+++ new/digest-openssl.c
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    48
@@ -53,8 +53,22 @@ struct ssh_digest {
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    49
 	const EVP_MD *(*mdfunc)(void);
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    50
 };
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    51
 
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    52
+#ifdef ENABLE_OPENSSL_FIPS
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    53
 /* NB. Indexed directly by algorithm number */
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    54
+const struct ssh_digest digests_fips[] = {
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    55
+	{ SSH_DIGEST_MD5,	"",	 	16,	NULL },
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    56
+	{ SSH_DIGEST_RIPEMD160,	"",		20,	NULL },
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    57
+	{ SSH_DIGEST_SHA1,	"SHA1",	 	20,	EVP_sha1 },
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    58
+	{ SSH_DIGEST_SHA256,	"SHA256", 	32,	EVP_sha256 },
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    59
+	{ SSH_DIGEST_SHA384,	"SHA384",	48,	EVP_sha384 },
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    60
+	{ SSH_DIGEST_SHA512,	"SHA512", 	64,	EVP_sha512 },
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    61
+	{ -1,			NULL,		0,	NULL },
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    62
+};
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    63
+/* NB. Indexed directly by algorithm number */
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    64
+const struct ssh_digest digests_dflt[] = {
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    65
+#else /* ENABLE_OPENSSL_FIPS */
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    66
 const struct ssh_digest digests[] = {
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    67
+#endif /* ENABLE_OPENSSL_FIPS */
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    68
 	{ SSH_DIGEST_MD5,	"MD5",	 	16,	EVP_md5 },
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    69
 	{ SSH_DIGEST_RIPEMD160,	"RIPEMD160",	20,	EVP_ripemd160 },
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    70
 	{ SSH_DIGEST_SHA1,	"SHA1",	 	20,	EVP_sha1 },
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    71
@@ -67,6 +81,9 @@ const struct ssh_digest digests[] = {
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    72
 static const struct ssh_digest *
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    73
 ssh_digest_by_alg(int alg)
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    74
 {
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    75
+#ifdef ENABLE_OPENSSL_FIPS
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    76
+	struct ssh_digest *digests = ssh_FIPS_mode() ? digests_fips : digests_dflt;
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    77
+#endif
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    78
 	if (alg < 0 || alg >= SSH_DIGEST_MAX)
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    79
 		return NULL;
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    80
 	if (digests[alg].id != alg) /* sanity */
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    81
@@ -79,6 +96,9 @@ ssh_digest_by_alg(int alg)
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    82
 int
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    83
 ssh_digest_alg_by_name(const char *name)
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    84
 {
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    85
+#ifdef ENABLE_OPENSSL_FIPS
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    86
+	struct ssh_digest *digests = ssh_FIPS_mode() ? digests_fips : digests_dflt;
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    87
+#endif
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    88
 	int alg;
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    89
 
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    90
 	for (alg = 0; digests[alg].id != -1; alg++) {
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    91
diff -pur old/gss-genr.c new/gss-genr.c
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    92
--- old/gss-genr.c
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    93
+++ new/gss-genr.c
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    94
@@ -100,6 +100,7 @@ ssh_gssapi_kex_mechs(gss_OID_set gss_sup
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    95
 	char deroid[2];
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    96
 	const EVP_MD *evp_md = EVP_md5();
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    97
 	EVP_MD_CTX md;
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    98
+	int fips_mode;
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    99
 
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   100
 	if (gss_enc2oid != NULL) {
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   101
 		for (i = 0; gss_enc2oid[i].encoded != NULL; i++)
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   102
@@ -112,6 +113,14 @@ ssh_gssapi_kex_mechs(gss_OID_set gss_sup
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   103
 
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   104
 	buffer_init(&buf);
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   105
 
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   106
+#ifdef ENABLE_OPENSSL_FIPS
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   107
+	fips_mode = ssh_FIPS_mode();
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   108
+	if (fips_mode) {
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   109
+		debug3("Temporarily unsetting FIPS mode to compute MD5 for "
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   110
+		    "GSS-API key exchange method names");
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   111
+		FIPS_mode_set(0);
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   112
+	}
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   113
+#endif
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   114
 	oidpos = 0;
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   115
 	for (i = 0; i < gss_supported->count; i++) {
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   116
 		if (gss_supported->elements[i].length < 128 &&
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   117
@@ -119,7 +128,6 @@ ssh_gssapi_kex_mechs(gss_OID_set gss_sup
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   118
 
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   119
 			deroid[0] = SSH_GSS_OIDTYPE;
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   120
 			deroid[1] = gss_supported->elements[i].length;
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   121
-
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   122
 			EVP_DigestInit(&md, evp_md);
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   123
 			EVP_DigestUpdate(&md, deroid, 2);
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   124
 			EVP_DigestUpdate(&md,
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   125
@@ -151,6 +159,12 @@ ssh_gssapi_kex_mechs(gss_OID_set gss_sup
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   126
 			oidpos++;
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   127
 		}
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   128
 	}
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   129
+#ifdef ENABLE_OPENSSL_FIPS
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   130
+	if (fips_mode) {
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   131
+		ssh_FIPS_mode_set_if_capable();
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   132
+		ssh_FIPS_check_status();
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   133
+	}
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   134
+#endif
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   135
 	gss_enc2oid[oidpos].oid = NULL;
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   136
 	gss_enc2oid[oidpos].encoded = NULL;
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   137
 
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   138
diff -pur old/kex.c new/kex.c
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   139
--- old/kex.c
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   140
+++ new/kex.c
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   141
@@ -89,7 +89,40 @@ struct kexalg {
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   142
 	int ec_nid;
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   143
 	int hash_alg;
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   144
 };
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   145
+
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   146
+#ifdef ENABLE_OPENSSL_FIPS
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   147
+/* in FIPS mode limit kexalgs to FIPS compliant only */
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   148
+#define        kexalgs (ssh_FIPS_mode() ? kexalgs_fips : kexalgs_dflt)
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   149
+static const struct kexalg kexalgs_fips[] = {
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   150
+#ifdef WITH_OPENSSL
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   151
+	{ KEX_DH1, KEX_DH_GRP1_SHA1, 0, SSH_DIGEST_SHA1 },
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   152
+	{ KEX_DH14, KEX_DH_GRP14_SHA1, 0, SSH_DIGEST_SHA1 },
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   153
+	{ KEX_DHGEX_SHA1, KEX_DH_GEX_SHA1, 0, SSH_DIGEST_SHA1 },
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   154
+#ifdef HAVE_EVP_SHA256
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   155
+	{ KEX_DHGEX_SHA256, KEX_DH_GEX_SHA256, 0, SSH_DIGEST_SHA256 },
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   156
+#endif /* HAVE_EVP_SHA256 */
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   157
+#ifdef OPENSSL_HAS_ECC
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   158
+	{ KEX_ECDH_SHA2_NISTP256, KEX_ECDH_SHA2,
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   159
+	    NID_X9_62_prime256v1, SSH_DIGEST_SHA256 },
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   160
+	{ KEX_ECDH_SHA2_NISTP384, KEX_ECDH_SHA2, NID_secp384r1,
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   161
+	    SSH_DIGEST_SHA384 },
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   162
+# ifdef OPENSSL_HAS_NISTP521
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   163
+	{ KEX_ECDH_SHA2_NISTP521, KEX_ECDH_SHA2, NID_secp521r1,
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   164
+	    SSH_DIGEST_SHA512 },
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   165
+# endif /* OPENSSL_HAS_NISTP521 */
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   166
+#endif /* OPENSSL_HAS_ECC */
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   167
+#endif /* WITH_OPENSSL */
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   168
+#ifdef GSSAPI
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   169
+	{ KEX_GSS_GEX_SHA1_ID, KEX_GSS_GEX_SHA1, 0, SSH_DIGEST_SHA1 },
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   170
+	{ KEX_GSS_GRP1_SHA1_ID, KEX_GSS_GRP1_SHA1, 0, SSH_DIGEST_SHA1 },
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   171
+	{ KEX_GSS_GRP14_SHA1_ID, KEX_GSS_GRP14_SHA1, 0, SSH_DIGEST_SHA1 },
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   172
+#endif
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   173
+	{ NULL, -1, -1, -1},
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   174
+};
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   175
+static const struct kexalg kexalgs_dflt[] = {
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   176
+#else
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   177
 static const struct kexalg kexalgs[] = {
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   178
+#endif 
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   179
 #ifdef WITH_OPENSSL
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   180
 	{ KEX_DH1, KEX_DH_GRP1_SHA1, 0, SSH_DIGEST_SHA1 },
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   181
 	{ KEX_DH14, KEX_DH_GRP14_SHA1, 0, SSH_DIGEST_SHA1 },
5310
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   182
diff -pur old/mac.c new/mac.c
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   183
--- old/mac.c
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   184
+++ new/mac.c
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   185
@@ -53,8 +53,33 @@ struct macalg {
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   186
 	int		len;		/* just for UMAC */
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   187
 	int		etm;		/* Encrypt-then-MAC */
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   188
 };
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   189
+#ifdef ENABLE_OPENSSL_FIPS
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   190
+/* in FIPS mode limit macs to FIPS compliant only */
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   191
+#define	macs (ssh_FIPS_mode() ? macs_fips : macs_dflt)
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   192
 
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   193
+static const struct macalg macs_fips[] = {
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   194
+	/* Encrypt-and-MAC (encrypt-and-authenticate) variants */
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   195
+	{ "hmac-sha1",				SSH_DIGEST, SSH_DIGEST_SHA1, 0, 0, 0, 0 },
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   196
+	{ "hmac-sha1-96",			SSH_DIGEST, SSH_DIGEST_SHA1, 96, 0, 0, 0 },
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   197
+#ifdef HAVE_EVP_SHA256
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   198
+	{ "hmac-sha2-256",			SSH_DIGEST, SSH_DIGEST_SHA256, 0, 0, 0, 0 },
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   199
+	{ "hmac-sha2-512",			SSH_DIGEST, SSH_DIGEST_SHA512, 0, 0, 0, 0 },
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   200
+#endif
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   201
+	/* Encrypt-then-MAC variants */
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   202
+	{ "[email protected]",		SSH_DIGEST, SSH_DIGEST_SHA1, 0, 0, 0, 1 },
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   203
+	{ "[email protected]",	SSH_DIGEST, SSH_DIGEST_SHA1, 96, 0, 0, 1 },
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   204
+#ifdef HAVE_EVP_SHA256
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   205
+	{ "[email protected]",	SSH_DIGEST, SSH_DIGEST_SHA256, 0, 0, 0, 1 },
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   206
+	{ "[email protected]",	SSH_DIGEST, SSH_DIGEST_SHA512, 0, 0, 0, 1 },
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   207
+#endif
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   208
+
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   209
+	{ NULL,					0, 0, 0, 0, 0, 0 }
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   210
+};
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   211
+
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   212
+static const struct macalg macs_dflt[] = {
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   213
+#else /* ENABLE_OPENSSL_FIPS */
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   214
 static const struct macalg macs[] = {
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   215
+#endif /* ENABLE_OPENSSL_FIPS */
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   216
 	/* Encrypt-and-MAC (encrypt-and-authenticate) variants */
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   217
 	{ "hmac-sha1",				SSH_DIGEST, SSH_DIGEST_SHA1, 0, 0, 0, 0 },
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   218
 	{ "hmac-sha1-96",			SSH_DIGEST, SSH_DIGEST_SHA1, 96, 0, 0, 0 },
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   219
diff -pur old/misc.c new/misc.c
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   220
--- old/misc.c
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   221
+++ new/misc.c
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   222
@@ -39,12 +39,15 @@
5310
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   223
 #include <string.h>
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   224
 #include <time.h>
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   225
 #include <unistd.h>
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   226
+#include <dlfcn.h>
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   227
 
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   228
 #include <netinet/in.h>
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   229
 #include <netinet/in_systm.h>
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   230
 #include <netinet/ip.h>
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   231
 #include <netinet/tcp.h>
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   232
 
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   233
+#include <openssl/crypto.h>
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   234
+
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   235
 #include <ctype.h>
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   236
 #include <errno.h>
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   237
 #include <fcntl.h>
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   238
@@ -78,6 +81,60 @@ chop(char *s)
5310
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   239
 
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   240
 }
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   241
 
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   242
+#ifdef ENABLE_OPENSSL_FIPS
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   243
+/* is OpenSSL FIPS mode set? */
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   244
+int
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   245
+ssh_FIPS_mode()
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   246
+{
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   247
+	return FIPS_mode();
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   248
+}
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   249
+
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   250
+/* store FIPS_mode_set() err code */
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   251
+static unsigned long ssh_FIPS_err_code = 0;
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   252
+
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   253
+#define	MSGBUFSIZ	1024 /* equals log.c:MSGBUFSIZ */
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   254
+
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   255
+/*
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   256
+ * Check and display FIPS mode status. 
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   257
+ * Called after ssh_FIPS_mode_set_if_capable() and when logging facility is
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   258
+ * available.
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   259
+ * If FIPS_mode_failed for FIPS capable libcrypto, exits with 255 code.
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   260
+ */
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   261
+void 
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   262
+ssh_FIPS_check_status()
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   263
+{
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   264
+	char ebuf[MSGBUFSIZ];
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   265
+
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   266
+	if (dlsym(RTLD_DEFAULT, "FIPS_module_mode_set") != NULL) {
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   267
+		if (ssh_FIPS_mode()) {
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   268
+			debug("Running in FIPS mode.");
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   269
+		} else {
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   270
+			ERR_error_string_n(ssh_FIPS_err_code, ebuf,
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   271
+			    sizeof (ebuf));
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   272
+			fatal("Setting FIPS mode failed! %s", ebuf);
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   273
+		}
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   274
+	} else {
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   275
+		debug3("Loaded libcrypto is not FIPS capable.");
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   276
+	}
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   277
+	
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   278
+}
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   279
+
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   280
+/* if underlying libcrypto is FIPS capable, set FIPS_mode to 1 */
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   281
+int
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   282
+ssh_FIPS_mode_set_if_capable()
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   283
+{
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   284
+	/* presence of FIPS_module_mode_set indicates FIPS capable OpenSSL */
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   285
+	if (dlsym(RTLD_DEFAULT, "FIPS_module_mode_set") != NULL) {
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   286
+		/* call the API function FIPS_mode_set*/
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   287
+		if (!FIPS_mode_set(1)) {
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   288
+			ssh_FIPS_err_code = ERR_get_error();
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   289
+			return 1;
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   290
+		}
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   291
+	}
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   292
+	return 0;
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   293
+}
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   294
+#endif
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   295
+
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   296
 /* set/unset filedescriptor to non-blocking */
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   297
 int
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   298
 set_nonblock(int fd)
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   299
diff -pur old/misc.h new/misc.h
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   300
--- old/misc.h
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   301
+++ new/misc.h
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   302
@@ -38,6 +38,11 @@ struct ForwardOptions {
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   303
 
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   304
 char	*chop(char *);
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   305
 char	*strdelim(char **);
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   306
+#ifdef ENABLE_OPENSSL_FIPS
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   307
+int	 ssh_FIPS_mode();
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   308
+int	 ssh_FIPS_mode_set_if_capable();
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   309
+void     ssh_FIPS_check_status();
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   310
+#endif
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   311
 int	 set_nonblock(int);
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   312
 int	 unset_nonblock(int);
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   313
 void	 set_nodelay(int);
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   314
diff -pur old/myproposal.h new/myproposal.h
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   315
--- old/myproposal.h
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   316
+++ new/myproposal.h
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   317
@@ -83,19 +83,31 @@
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   318
 # else
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   319
 #  define KEX_CURVE25519_METHODS ""
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   320
 # endif
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   321
-#define KEX_COMMON_KEX \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   322
+
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   323
+#define KEX_COMMON_KEX_DFLT \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   324
 	KEX_CURVE25519_METHODS \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   325
 	KEX_ECDH_METHODS \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   326
 	KEX_SHA256_METHODS
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   327
 
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   328
-#define KEX_SERVER_KEX KEX_COMMON_KEX \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   329
+#define KEX_SERVER_KEX_DFLT KEX_COMMON_KEX_DFLT \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   330
 	"diffie-hellman-group14-sha1" \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   331
 
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   332
-#define KEX_CLIENT_KEX KEX_COMMON_KEX \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   333
+#define KEX_CLIENT_KEX_DFLT KEX_COMMON_KEX_DFLT \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   334
 	"diffie-hellman-group-exchange-sha1," \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   335
 	"diffie-hellman-group14-sha1"
5310
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   336
 
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   337
-#define	KEX_DEFAULT_PK_ALG	\
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   338
+#define KEX_COMMON_KEX_FIPS \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   339
+	KEX_ECDH_METHODS \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   340
+	KEX_SHA256_METHODS
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   341
+
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   342
+#define KEX_SERVER_KEX_FIPS KEX_COMMON_KEX_FIPS \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   343
+	"diffie-hellman-group14-sha1" \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   344
+
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   345
+#define KEX_CLIENT_KEX_FIPS KEX_COMMON_KEX_FIPS \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   346
+	"diffie-hellman-group-exchange-sha1," \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   347
+	"diffie-hellman-group14-sha1"
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   348
+
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   349
+#define	KEX_DEFAULT_PK_ALG_DFLT	\
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   350
 	HOSTKEY_ECDSA_CERT_METHODS \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   351
 	"[email protected]," \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   352
 	"[email protected]," \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   353
@@ -105,17 +117,32 @@
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   354
 	"rsa-sha2-256," \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   355
 	"ssh-rsa"
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   356
 
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   357
+#define	KEX_DEFAULT_PK_ALG_FIPS	\
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   358
+	HOSTKEY_ECDSA_CERT_METHODS \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   359
+	"[email protected]," \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   360
+	HOSTKEY_ECDSA_METHODS \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   361
+	"rsa-sha2-512," \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   362
+	"rsa-sha2-256," \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   363
+	"ssh-rsa"
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   364
+
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   365
 /* the actual algorithms */
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   366
 
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   367
-#define KEX_SERVER_ENCRYPT \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   368
+#define KEX_SERVER_ENCRYPT_DFLT \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   369
 	"[email protected]," \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   370
 	"aes128-ctr,aes192-ctr,aes256-ctr" \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   371
 	AESGCM_CIPHER_MODES
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   372
 
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   373
-#define KEX_CLIENT_ENCRYPT KEX_SERVER_ENCRYPT "," \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   374
+#define KEX_CLIENT_ENCRYPT_DFLT KEX_SERVER_ENCRYPT_DFLT "," \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   375
+	"aes128-cbc,aes192-cbc,aes256-cbc,3des-cbc"
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   376
+
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   377
+#define KEX_SERVER_ENCRYPT_FIPS \
5310
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   378
+	"aes128-ctr,aes192-ctr,aes256-ctr" \
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   379
+	AESGCM_CIPHER_MODES
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   380
+
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   381
+#define KEX_CLIENT_ENCRYPT_FIPS KEX_SERVER_ENCRYPT_FIPS "," \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   382
 	"aes128-cbc,aes192-cbc,aes256-cbc,3des-cbc"
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   383
 
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   384
-#define KEX_SERVER_MAC \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   385
+#define KEX_SERVER_MAC_DFLT \
5310
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   386
 	"[email protected]," \
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   387
 	"[email protected]," \
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   388
 	"[email protected]," \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   389
@@ -127,7 +154,42 @@
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   390
 	"hmac-sha2-512," \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   391
 	"hmac-sha1"
5310
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   392
 
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   393
-#define KEX_CLIENT_MAC KEX_SERVER_MAC
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   394
+#define KEX_CLIENT_MAC_DFLT KEX_SERVER_MAC_DFLT
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   395
+
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   396
+#define KEX_SERVER_MAC_FIPS \
5310
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   397
+	"[email protected]," \
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   398
+	"[email protected]," \
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   399
+	"[email protected]," \
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   400
+	"hmac-sha2-256," \
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   401
+	"hmac-sha2-512," \
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   402
+	"hmac-sha1"
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   403
+
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   404
+#define KEX_CLIENT_MAC_FIPS KEX_SERVER_MAC_FIPS
5310
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   405
+
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   406
+#ifdef ENABLE_OPENSSL_FIPS
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   407
+ #define KEX_SERVER_KEX \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   408
+     (ssh_FIPS_mode() ? (KEX_SERVER_KEX_FIPS) : (KEX_SERVER_KEX_DFLT) )
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   409
+ #define KEX_CLIENT_KEX \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   410
+     (ssh_FIPS_mode() ? (KEX_CLIENT_KEX_FIPS) : (KEX_CLIENT_KEX_DFLT) )
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   411
+ #define KEX_DEFAULT_PK_ALG \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   412
+     (ssh_FIPS_mode() ? (KEX_DEFAULT_PK_ALG_FIPS) : (KEX_DEFAULT_PK_ALG_DFLT) )
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   413
+ #define KEX_SERVER_ENCRYPT \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   414
+    (ssh_FIPS_mode() ? (KEX_SERVER_ENCRYPT_FIPS) : (KEX_SERVER_ENCRYPT_DFLT))
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   415
+ #define KEX_CLIENT_ENCRYPT \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   416
+    (ssh_FIPS_mode() ? (KEX_CLIENT_ENCRYPT_FIPS) : (KEX_CLIENT_ENCRYPT_DFLT))
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   417
+ #define KEX_SERVER_MAC \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   418
+    (ssh_FIPS_mode() ? (KEX_SERVER_MAC_FIPS) : (KEX_SERVER_MAC_DFLT) )
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   419
+ #define KEX_CLIENT_MAC \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   420
+    (ssh_FIPS_mode() ? (KEX_CLIENT_MAC_FIPS) : (KEX_CLIENT_MAC_DFLT) )
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   421
+#else /* ENABLE_OPENSSL_FIPS */
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   422
+ #define KEX_SERVER_KEX KEX_SERVER_KEX_DFLT
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   423
+ #define KEX_CLIENT_KEX KEX_CLIENT_KEX_DFLT
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   424
+ #define KEX_DEFAULT_PK_ALG KEX_DEFAULT_PK_ALG_DFLT
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   425
+ #define KEX_SERVER_ENCRYPT KEX_SERVER_ENCRYPT_DFLT
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   426
+ #define KEX_CLIENT_ENCRYPT KEX_CLIENT_ENCRYPT_DFLT
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   427
+ #define KEX_SERVER_MAC KEX_SERVER_MAC_DFLT
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   428
+ #define KEX_CLIENT_MAC KEX_CLIENT_MAC_DFLT
5310
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   429
+#endif /* ENABLE_OPENSSL_FIPS */
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   430
 
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   431
 #else /* WITH_OPENSSL */
5310
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   432
 
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   433
diff -pur old/ssh-add.1 new/ssh-add.1
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   434
--- old/ssh-add.1
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   435
+++ new/ssh-add.1
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   436
@@ -116,6 +116,8 @@ and
5310
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   437
 .Dq sha256 .
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   438
 The default is
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   439
 .Dq sha256 .
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   440
+If OpenSSL is running in FIPS-140 mode, the only supported option is
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   441
+.Dq sha256 .
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   442
 .It Fl e Ar pkcs11
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   443
 Remove keys provided by the PKCS#11 shared library
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   444
 .Ar pkcs11 .
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   445
diff -pur old/ssh-add.c new/ssh-add.c
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   446
--- old/ssh-add.c
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   447
+++ new/ssh-add.c
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   448
@@ -488,6 +488,12 @@ main(int argc, char **argv)
5310
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   449
 	__progname = ssh_get_progname(argv[0]);
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   450
 	seed_rng();
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   451
 
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   452
+#ifdef ENABLE_OPENSSL_FIPS
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   453
+	if (ssh_FIPS_mode_set_if_capable()) {
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   454
+		fprintf(stderr, "Setting FIPS mode failed!");
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   455
+		exit(1);
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   456
+	}
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   457
+#endif
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   458
 #ifdef WITH_OPENSSL
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   459
 	OpenSSL_add_all_algorithms();
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   460
 #endif
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   461
diff -pur old/ssh-agent.1 new/ssh-agent.1
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   462
--- old/ssh-agent.1
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   463
+++ new/ssh-agent.1
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   464
@@ -117,6 +117,8 @@ and
5310
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   465
 .Dq sha256 .
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   466
 The default is
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   467
 .Dq sha256 .
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   468
+If OpenSSL is running in FIPS-140 mode, the only supported option is
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   469
+.Dq sha256 .
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   470
 .It Fl k
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   471
 Kill the current agent (given by the
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   472
 .Ev SSH_AGENT_PID
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   473
diff -pur old/ssh-agent.c new/ssh-agent.c
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   474
--- old/ssh-agent.c
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   475
+++ new/ssh-agent.c
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   476
@@ -1199,6 +1199,7 @@ main(int ac, char **av)
5310
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   477
 	struct timeval *tvp = NULL;
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   478
 	size_t len;
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   479
 	mode_t prev_mask;
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   480
+	int fips_err;
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   481
 
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   482
 	ssh_malloc_init();	/* must be called before any mallocs */
5310
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   483
 	/* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   484
@@ -1213,6 +1214,9 @@ main(int ac, char **av)
5310
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   485
 	prctl(PR_SET_DUMPABLE, 0);
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   486
 #endif
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   487
 
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   488
+#ifdef ENABLE_OPENSSL_FIPS
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   489
+	fips_err = ssh_FIPS_mode_set_if_capable();
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   490
+#endif
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   491
 #ifdef WITH_OPENSSL
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   492
 	OpenSSL_add_all_algorithms();
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   493
 #endif
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   494
@@ -1343,8 +1347,19 @@ main(int ac, char **av)
5310
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   495
 		printf(format, SSH_AUTHSOCKET_ENV_NAME, socket_name,
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   496
 		    SSH_AUTHSOCKET_ENV_NAME);
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   497
 		printf("echo Agent pid %ld;\n", (long)parent_pid);
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   498
+#ifdef ENABLE_OPENSSL_FIPS
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   499
+		ssh_FIPS_check_status();
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   500
+#endif
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   501
 		fflush(stdout);
5310
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   502
 		goto skip;
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   503
+#ifdef ENABLE_OPENSSL_FIPS
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   504
+	} else {
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   505
+		/* we still need to error out on FIPS_mode_set failure */
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   506
+		if (fips_err) {
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   507
+			fprintf(stderr, "Setting FIPS mode failed!");
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   508
+			cleanup_exit(1);
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   509
+		}
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   510
+#endif
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   511
 	}
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   512
 	pid = fork();
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   513
 	if (pid == -1) {
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   514
diff -pur old/ssh-keygen.1 new/ssh-keygen.1
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   515
--- old/ssh-keygen.1
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   516
+++ new/ssh-keygen.1
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   517
@@ -283,6 +283,8 @@ and
5310
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   518
 .Dq sha256 .
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   519
 The default is
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   520
 .Dq sha256 .
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   521
+If OpenSSL is running in FIPS-140 mode, the only supported option is
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   522
+.Dq sha256 .
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   523
 .It Fl e
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   524
 This option will read a private or public OpenSSH key file and
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   525
 print to stdout the key in one of the formats specified by the
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   526
diff -pur old/ssh-keygen.c new/ssh-keygen.c
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   527
--- old/ssh-keygen.c
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   528
+++ new/ssh-keygen.c
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   529
@@ -2267,11 +2267,18 @@ main(int argc, char **argv)
5310
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   530
 
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   531
 	__progname = ssh_get_progname(argv[0]);
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   532
 
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   533
+#ifdef ENABLE_OPENSSL_FIPS
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   534
+	ssh_FIPS_mode_set_if_capable();
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   535
+#endif
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   536
 #ifdef WITH_OPENSSL
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   537
 	OpenSSL_add_all_algorithms();
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   538
 #endif
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   539
 	log_init(argv[0], SYSLOG_LEVEL_INFO, SYSLOG_FACILITY_USER, 1);
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   540
 
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   541
+#ifdef ENABLE_OPENSSL_FIPS
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   542
+	ssh_FIPS_check_status();
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   543
+#endif
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   544
+
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   545
 	seed_rng();
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   546
 
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   547
 	/* we need this for the home * directory.  */
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   548
diff -pur old/ssh-keysign.c new/ssh-keysign.c
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   549
--- old/ssh-keysign.c
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   550
+++ new/ssh-keysign.c
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   551
@@ -178,6 +178,7 @@ main(int argc, char **argv)
5310
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   552
 	u_char *signature, *data, rver;
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   553
 	char *host, *fp;
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   554
 	size_t slen, dlen;
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   555
+	int fips_err;
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   556
 #ifdef WITH_OPENSSL
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   557
 	u_int32_t rnd[256];
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   558
 #endif
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   559
@@ -228,6 +229,16 @@ main(int argc, char **argv)
5310
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   560
 	if (found == 0)
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   561
 		fatal("could not open any host key");
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   562
 
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   563
+#ifdef ENABLE_OPENSSL_FIPS
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   564
+	fips_err = ssh_FIPS_mode_set_if_capable();
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   565
+#ifdef DEBUG_SSH_KEYSIGN
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   566
+	ssh_FIPS_check_status();
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   567
+#else
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   568
+	/* we still need to error out on FIPS_mode_set failure */
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   569
+	if (fips_err)
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   570
+		fatal("Setting FIPS mode failed!");
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   571
+#endif
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   572
+#endif
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   573
 #ifdef WITH_OPENSSL
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   574
 	OpenSSL_add_all_algorithms();
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   575
 	arc4random_buf(rnd, sizeof(rnd));
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   576
diff -pur old/ssh.1 new/ssh.1
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   577
--- old/ssh.1
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   578
+++ new/ssh.1
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   579
@@ -91,6 +91,9 @@ If
5310
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   580
 is specified,
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   581
 it is executed on the remote host instead of a login shell.
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   582
 .Pp
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   583
+If ssh links with FIPS-capable OpenSSL, ssh runs in FIPS-140 mode.
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   584
+In FIPS-140 mode non-FIPS approved ciphers, MACs and digests are disabled.
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   585
+.Pp
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   586
 The options are as follows:
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   587
 .Pp
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   588
 .Bl -tag -width Ds -compact
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   589
diff -pur old/ssh.c new/ssh.c
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   590
--- old/ssh.c
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   591
+++ new/ssh.c
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   592
@@ -606,6 +606,11 @@ main(int ac, char **av)
5310
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   593
 	 */
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   594
 	initialize_options(&options);
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   595
 
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   596
+#ifdef ENABLE_OPENSSL_FIPS
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   597
+	/* determine FIPS mode early to limit ciphers and macs */
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   598
+	ssh_FIPS_mode_set_if_capable();
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   599
+#endif
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   600
+
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   601
 	/* Parse command-line arguments. */
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   602
 	host = NULL;
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   603
 	use_syslog = 0;
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   604
@@ -1016,6 +1021,10 @@ main(int ac, char **av)
5310
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   605
 #endif
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   606
 		);
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   607
 
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   608
+#ifdef ENABLE_OPENSSL_FIPS
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   609
+	ssh_FIPS_check_status();
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   610
+#endif
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   611
+
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   612
 	/* Parse the configuration files */
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   613
 	process_config_files(host_arg, pw, 0);
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   614
 
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   615
diff -pur old/ssh_api.c new/ssh_api.c
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   616
--- old/ssh_api.c
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   617
+++ new/ssh_api.c
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   618
@@ -81,6 +81,10 @@ ssh_init(struct ssh **sshp, int is_serve
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   619
 	int r;
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   620
 
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   621
 	if (!called) {
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   622
+#ifdef ENABLE_OPENSSL_FIPS
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   623
+		ssh_FIPS_mode_set_if_capable();
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   624
+		ssh_FIPS_check_status();
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   625
+#endif
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   626
 #ifdef WITH_OPENSSL
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   627
 		OpenSSL_add_all_algorithms();
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   628
 #endif /* WITH_OPENSSL */
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   629
diff -pur old/ssh_config.5 new/ssh_config.5
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   630
--- old/ssh_config.5
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   631
+++ new/ssh_config.5
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   632
@@ -489,6 +489,13 @@ [email protected],aes256-gcm@openss
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   633
 aes128-cbc,aes192-cbc,aes256-cbc,3des-cbc
5310
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   634
 .Ed
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   635
 .Pp
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   636
+The following ciphers are FIPS-140 approved and are supported in FIPS-140 mode:
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   637
+.Bd -literal -offset indent
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   638
+aes128-ctr,aes192-ctr,aes256-ctr,
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   639
[email protected],[email protected],
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   640
+aes128-cbc,3des-cbc,aes192-cbc,aes256-cbc
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   641
+.Ed
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   642
+.Pp
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   643
 The list of available ciphers may also be obtained using the
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   644
 .Fl Q
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   645
 option of
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   646
@@ -738,6 +745,8 @@ and
5310
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   647
 .Dq sha256 .
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   648
 The default is
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   649
 .Dq sha256 .
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   650
+In FIPS-140 mode the only supported option is
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   651
+.Dq sha256 .
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   652
 .It Cm ForwardAgent
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   653
 Specifies whether the connection to the authentication agent (if any)
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   654
 will be forwarded to the remote machine.
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   655
@@ -1200,6 +1209,16 @@ [email protected],[email protected]
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   656
 hmac-sha2-256,hmac-sha2-512,hmac-sha1
5310
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   657
 .Ed
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   658
 .Pp
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   659
+The following MACs are FIPS-140 approved and are supported in FIPS-140 mode:
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   660
+.Bd -literal -offset indent
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   661
[email protected],
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   662
[email protected],
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   663
+hmac-sha2-256,hmac-sha2-512,
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   664
[email protected],
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   665
[email protected]
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   666
+hmac-sha1,hmac-sha1-96
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   667
+.Ed
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   668
+.Pp
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   669
 The list of available MAC algorithms may also be obtained using the
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   670
 .Fl Q
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   671
 option of
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   672
diff -pur old/sshconnect.c new/sshconnect.c
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   673
--- old/sshconnect.c
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   674
+++ new/sshconnect.c
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   675
@@ -530,8 +530,14 @@ send_client_banner(int connection_out, i
5310
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   676
 {
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   677
 	/* Send our own protocol version identification. */
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   678
 	if (compat20) {
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   679
+#ifdef ENABLE_OPENSSL_FIPS
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   680
+		xasprintf(&client_version_string, "SSH-%d.%d-%.100s%s\r\n",
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   681
+		    PROTOCOL_MAJOR_2, PROTOCOL_MINOR_2, SSH_VERSION,
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   682
+		    ssh_FIPS_mode() ? " FIPS" : "");
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   683
+#else
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   684
 		xasprintf(&client_version_string, "SSH-%d.%d-%.100s\r\n",
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   685
 		    PROTOCOL_MAJOR_2, PROTOCOL_MINOR_2, SSH_VERSION);
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   686
+#endif
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   687
 	} else {
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   688
 		xasprintf(&client_version_string, "SSH-%d.%d-%.100s\n",
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   689
 		    PROTOCOL_MAJOR_1, minor1, SSH_VERSION);
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   690
diff -pur old/sshd.8 new/sshd.8
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   691
--- old/sshd.8
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   692
+++ new/sshd.8
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   693
@@ -86,6 +86,9 @@ rereads its configuration file when it r
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   694
 by executing itself with the name and options it was started with, e.g.\&
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   695
 .Pa /usr/sbin/sshd .
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   696
 .Pp
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   697
+If sshd links with FIPS-capable OpenSSL, sshd runs in FIPS-140 mode.
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   698
+In FIPS-140 mode non-FIPS approved ciphers, MACs and digests are disabled.
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   699
+.Pp
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   700
 The options are as follows:
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   701
 .Bl -tag -width Ds
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   702
 .It Fl 4
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   703
diff -pur old/sshd.c new/sshd.c
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   704
--- old/sshd.c
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   705
+++ new/sshd.c
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   706
@@ -430,10 +430,18 @@ sshd_exchange_identification(int sock_in
5310
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   707
 		minor = PROTOCOL_MINOR_1;
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   708
 	}
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   709
 
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   710
+#ifdef ENABLE_OPENSSL_FIPS
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   711
+	xasprintf(&server_version_string, "SSH-%d.%d-%.100s%s%s%s%s",
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   712
+	    major, minor, SSH_VERSION,
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   713
+	    ssh_FIPS_mode() ? " FIPS" : " ",
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   714
+	    *options.version_addendum == '\0' ? "" : " ",
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   715
+	    options.version_addendum, newline);
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   716
+#else
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   717
 	xasprintf(&server_version_string, "SSH-%d.%d-%.100s%s%s%s",
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   718
 	    major, minor, SSH_VERSION,
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   719
 	    *options.version_addendum == '\0' ? "" : " ",
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   720
 	    options.version_addendum, newline);
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   721
+#endif
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   722
 
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   723
 	/* Send our protocol version identification. */
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   724
 	if (atomicio(vwrite, sock_out, server_version_string,
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   725
@@ -1503,6 +1511,10 @@ main(int ac, char **av)
5310
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   726
 	/* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   727
 	sanitise_stdfd();
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   728
 
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   729
+#ifdef ENABLE_OPENSSL_FIPS
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   730
+	ssh_FIPS_mode_set_if_capable();
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   731
+#endif
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   732
+
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   733
 	/* Initialize configuration options to their default values. */
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   734
 	initialize_server_options(&options);
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   735
 
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   736
@@ -1653,6 +1665,10 @@ main(int ac, char **av)
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   737
 	    SYSLOG_FACILITY_AUTH : options.log_facility,
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   738
 	    log_stderr || !inetd_flag);
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   739
 
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   740
+#ifdef ENABLE_OPENSSL_FIPS
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   741
+	ssh_FIPS_check_status();
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   742
+#endif
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   743
+
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   744
 	/*
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   745
 	 * Unset KRB5CCNAME, otherwise the user's session may inherit it from
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   746
 	 * root's environment
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   747
diff -pur old/sshd_config.5 new/sshd_config.5
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   748
--- old/sshd_config.5
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   749
+++ new/sshd_config.5
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   750
@@ -482,6 +482,13 @@ aes128-ctr,aes192-ctr,aes256-ctr,
5310
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   751
 [email protected],[email protected]
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   752
 .Ed
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   753
 .Pp
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   754
+The following ciphers are FIPS-140 approved and are supported in FIPS-140 mode:
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   755
+.Bd -literal -offset indent
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   756
+aes128-ctr,aes192-ctr,aes256-ctr,
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   757
[email protected],[email protected],
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   758
+aes128-cbc,3des-cbc,aes192-cbc,aes256-cbc
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   759
+.Ed
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   760
+.Pp
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   761
 The list of available ciphers may also be obtained using the
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   762
 .Fl Q
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   763
 option of
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   764
@@ -576,6 +583,8 @@ and
5310
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   765
 .Dq sha256 .
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   766
 The default is
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   767
 .Dq sha256 .
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   768
+In FIPS-140 mode the only supported option is
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   769
+.Dq sha256 .
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   770
 .It Cm ForceCommand
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   771
 Forces the execution of the command specified by
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   772
 .Cm ForceCommand ,
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   773
@@ -1025,6 +1034,16 @@ [email protected],[email protected]
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   774
 hmac-sha2-256,hmac-sha2-512,hmac-sha1
5310
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   775
 .Ed
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   776
 .Pp
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   777
+The following MACs are FIPS-140 approved and are supported in FIPS-140 mode:
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   778
+.Bd -literal -offset indent
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   779
[email protected],
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   780
[email protected],
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   781
+hmac-sha2-256,hmac-sha2-512,
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   782
[email protected],
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   783
[email protected]
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   784
+hmac-sha1,hmac-sha1-96
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   785
+.Ed
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   786
+.Pp
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   787
 The list of available MAC algorithms may also be obtained using the
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   788
 .Fl Q
a06a01eef195 22051483 Dynamically enabling FIPS mode in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   789
 option of
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   790
diff -pur old/sshkey.c new/sshkey.c
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   791
--- old/sshkey.c
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   792
+++ new/sshkey.c
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   793
@@ -85,7 +85,46 @@ struct keytype {
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   794
 	int cert;
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   795
 	int sigonly;
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   796
 };
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   797
+
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   798
+#ifdef ENABLE_OPENSSL_FIPS
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   799
+/* in FIPS mode limit keytypes to FIPS compliant only */
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   800
+#define	keytypes (ssh_FIPS_mode() ? keytypes_fips : keytypes_dflt)
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   801
+
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   802
+static const struct keytype keytypes_fips[] = {
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   803
+#ifdef WITH_OPENSSL
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   804
+	{ NULL, "RSA1", KEY_RSA1, 0, 0, 0 },
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   805
+	{ "ssh-rsa", "RSA", KEY_RSA, 0, 0, 0 },
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   806
+	{ "rsa-sha2-256", "RSA", KEY_RSA, 0, 0, 1 },
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   807
+	{ "rsa-sha2-512", "RSA", KEY_RSA, 0, 0, 1 },
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   808
+	{ "ssh-dss", "DSA", KEY_DSA, 0, 0, 0 },
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   809
+# ifdef OPENSSL_HAS_ECC
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   810
+	{ "ecdsa-sha2-nistp256", "ECDSA", KEY_ECDSA, NID_X9_62_prime256v1, 0, 0 },
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   811
+	{ "ecdsa-sha2-nistp384", "ECDSA", KEY_ECDSA, NID_secp384r1, 0, 0 },
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   812
+#  ifdef OPENSSL_HAS_NISTP521
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   813
+	{ "ecdsa-sha2-nistp521", "ECDSA", KEY_ECDSA, NID_secp521r1, 0, 0 },
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   814
+#  endif /* OPENSSL_HAS_NISTP521 */
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   815
+# endif /* OPENSSL_HAS_ECC */
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   816
+	{ "[email protected]", "RSA-CERT", KEY_RSA_CERT, 0, 1, 0 },
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   817
+	{ "[email protected]", "DSA-CERT", KEY_DSA_CERT, 0, 1, 0 },
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   818
+# ifdef OPENSSL_HAS_ECC
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   819
+	{ "[email protected]", "ECDSA-CERT",
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   820
+	    KEY_ECDSA_CERT, NID_X9_62_prime256v1, 1, 0 },
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   821
+	{ "[email protected]", "ECDSA-CERT",
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   822
+	    KEY_ECDSA_CERT, NID_secp384r1, 1, 0 },
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   823
+#  ifdef OPENSSL_HAS_NISTP521
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   824
+	{ "[email protected]", "ECDSA-CERT",
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   825
+	    KEY_ECDSA_CERT, NID_secp521r1, 1, 0 },
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   826
+#  endif /* OPENSSL_HAS_NISTP521 */
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   827
+# endif /* OPENSSL_HAS_ECC */
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   828
+#endif /* WITH_OPENSSL */
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   829
+	{ "null", "null", KEY_NULL, 0, 0 },
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   830
+	{ NULL, NULL, -1, -1, 0, 0 }
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   831
+};
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   832
+
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   833
+static const struct keytype keytypes_dflt[] = {
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   834
+#else /* ENABLE_OPENSSL_FIPS */
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   835
 static const struct keytype keytypes[] = {
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   836
+#endif /* ENABLE_OPENSSL_FIPS */
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   837
 	{ "ssh-ed25519", "ED25519", KEY_ED25519, 0, 0, 0 },
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   838
 	{ "[email protected]", "ED25519-CERT",
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5310
diff changeset
   839
 	    KEY_ED25519_CERT, 0, 1, 0 },