Bugzilla – Attachment 1789 Details for
Bug 1197
Enhancement request to enable fips compatibility mode in OpenSSH
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Adapted patch
FIPS_patch-openssh_5.3p1 (text/plain), 38.03 KB, created by
halsteaw
on 2010-02-09 06:43:24 AEDT
(
hide
)
Description:
Adapted patch
Filename:
MIME Type:
Creator:
halsteaw
Created:
2010-02-09 06:43:24 AEDT
Size:
38.03 KB
patch
obsolete
>diff -Naur openssh-5.3p1/auth2-pubkey.c openssh-5.3p1/auth2-pubkey.c >--- openssh-5.3p1/auth2-pubkey.c 2009-03-07 19:40:28.000000000 -0500 >+++ openssh-5.4p1/auth2-pubkey.c 2010-01-28 19:22:03.000000000 -0500 >@@ -54,6 +54,9 @@ > #endif > #include "monitor_wrap.h" > #include "misc.h" >+#ifdef OPENSSL_FIPS >+ #include "fips.h" >+#endif > > /* import */ > extern ServerOptions options; >@@ -184,6 +187,13 @@ > Key *found; > char *fp; > >+ enum fp_type dgst_type = SSH_FP_MD5; >+ #ifdef OPENSSL_FIPS >+ if (fips_mode) { >+ dgst_type = SSH_FP_SHA1; >+ } >+ #endif >+ > /* Temporarily use the user's uid. */ > temporarily_use_uid(pw); > >@@ -232,7 +242,7 @@ > found_key = 1; > debug("matching key found: file %s, line %lu", > file, linenum); >- fp = key_fingerprint(found, SSH_FP_MD5, SSH_FP_HEX); >+ fp = key_fingerprint(found, dgst_type, SSH_FP_HEX); > verbose("Found matching %s key: %s", > key_type(found), fp); > xfree(fp); >diff -Naur openssh-5.3p1/auth-rsa.c openssh-5.4p1/auth-rsa.c >--- openssh-5.3p1/auth-rsa.c 2008-07-02 08:37:30.000000000 -0400 >+++ openssh-5.3p1/auth-rsa.c 2010-01-28 19:22:04.000000000 -0500 >@@ -21,6 +21,7 @@ > > #include <openssl/rsa.h> > #include <openssl/md5.h> >+#include <openssl/fips_sha.h> > > #include <pwd.h> > #include <stdio.h> >@@ -47,6 +48,9 @@ > #include "monitor_wrap.h" > #include "ssh.h" > #include "misc.h" >+#ifdef OPENSSL_FIPS >+ #include "fips.h" >+#endif > > /* import */ > extern ServerOptions options; >@@ -88,10 +92,11 @@ > } > > int >-auth_rsa_verify_response(Key *key, BIGNUM *challenge, u_char response[16]) >+auth_rsa_verify_response(Key *key, BIGNUM *challenge, u_char response[20]) > { >- u_char buf[32], mdbuf[16]; >+ u_char buf[40], mdbuf[16], shabuf[20]; > MD5_CTX md; >+ SHA_CTX sha; > int len; > > /* don't allow short keys */ >@@ -101,10 +106,37 @@ > return (0); > } > >- /* The response is MD5 of decrypted challenge plus session id. */ > len = BN_num_bytes(challenge); >+ >+ if (len <= 0 || len > 40) >+ fatal("auth_rsa_verify_response: bad challenge length %d". len); >+ >+ /* The response is SHA1 of decrypted challenge plus session is */ >+ memset(buf, 0, 40); >+ BN_bn2bin(challenge, buf+ 40 - len); >+ SHA1_Init(&sha); >+ SHA1_Update(&sha, buf, 40); >+ SHA1_Update(&sha, session_id, 16); >+ SHA1_Final(shabuf, &sha); >+ >+ /* Verify that the response is the original challenge */ >+ if (memcmp(response, shabuf, 20) != 0) { >+ /* Wrong answer */ >+ #ifdef OPENSSL_FIPS >+ if (fips_mode) { >+ return(0); >+ } >+ #endif >+ } >+ #ifdef OPENSSL_FIPS >+ if (fips_mode) { >+ return(1); >+ } >+ #endif >+ > if (len <= 0 || len > 32) > fatal("auth_rsa_verify_response: bad challenge length %d", len); >+ /* The response is MD5 of decrypted challenge pluss session is. */ > memset(buf, 0, 32); > BN_bn2bin(challenge, buf + 32 - len); > MD5_Init(&md); >@@ -131,7 +163,7 @@ > auth_rsa_challenge_dialog(Key *key) > { > BIGNUM *challenge, *encrypted_challenge; >- u_char response[16]; >+ u_char response[20]; > int i, success; > > if ((encrypted_challenge = BN_new()) == NULL) >@@ -153,6 +185,10 @@ > packet_read_expect(SSH_CMSG_AUTH_RSA_RESPONSE); > for (i = 0; i < 16; i++) > response[i] = (u_char)packet_get_char(); >+ #ifdef OPENSSL_FIPS >+ for (i = 16; i < 20; i++) >+ response[i] = (u_char)packet_get_char(); >+ #endif > packet_check_eom(); > > success = PRIVSEP(auth_rsa_verify_response(key, challenge, response)); >@@ -285,6 +321,12 @@ > Key *key; > char *fp; > struct passwd *pw = authctxt->pw; >+ enum fp_type dgst_type = SSH_FP_MD5 >+ #ifdef OPENSSL_FIPS >+ if (fips_mode) { >+ dgst_type = SSH_FP_SHA1; >+ } >+ #endif > > /* no user given */ > if (!authctxt->valid) >@@ -313,7 +355,7 @@ > * options; this will be reset if the options cause the > * authentication to be rejected. > */ >- fp = key_fingerprint(key, SSH_FP_MD5, SSH_FP_HEX); >+ fp = key_fingerprint(key, dgst_type, SSH_FP_HEX); > verbose("Found matching %s key: %s", > key_type(key), fp); > xfree(fp); >diff -Naur openssh-5.3p1/buffer.c openssh-5.4p1/buffer.c >--- openssh-5.3p1/buffer.c 2006-08-04 22:39:39.000000000 -0400 >+++ openssh-5.4p1/buffer.c 2010-01-28 19:22:02.000000000 -0500 >@@ -175,6 +175,7 @@ > len, buffer->end - buffer->offset); > return (-1); > } >+ if (len > 0) > memcpy(buf, buffer->buf + buffer->offset, len); > buffer->offset += len; > return (0); >diff -Naur openssh-5.3p1/buildpkg.sh.in openssh-5.4p1/buildpkg.sh.in >--- openssh-5.3p1/buildpkg.sh.in 2007-07-25 00:40:59.000000000 -0400 >+++ openssh-5.4p1/buildpkg.sh.in 2010-01-28 19:22:03.000000000 -0500 >@@ -126,7 +126,7 @@ > FAKE_ROOT=$START/pkg > > ## Fill in some details, like prefix and sysconfdir >-for confvar in prefix exec_prefix bindir sbindir libexecdir datadir mandir sysconfdir piddir srcdir >+for confvar in prefix exec_prefix bindir sbindir libexecdir datadir mandir sysconfdir piddir srcdir ssldir > do > eval $confvar=`grep "^$confvar=" Makefile | cut -d = -f 2` > done >diff -Naur openssh-5.3p1/cipher.c openssh-5.4p1/cipher.c >--- openssh-5.3p1/cipher.c 2009-01-28 00:38:41.000000000 -0500 >+++ openssh-5.4p1/cipher.c 2010-01-28 19:22:02.000000000 -0500 >@@ -47,6 +47,8 @@ > #include "xmalloc.h" > #include "log.h" > #include "cipher.h" >+#include "fips.h" >+#include <openssl/sha.h> > > /* compatibility with old or broken OpenSSL versions */ > #include "openbsd-compat/openssl-compat.h" >@@ -65,30 +67,31 @@ > u_int discard_len; > u_int cbc_mode; > const EVP_CIPHER *(*evptype)(void); >+ u_int fips_allowed; > } ciphers[] = { >- { "none", SSH_CIPHER_NONE, 8, 0, 0, 0, EVP_enc_null }, >- { "des", SSH_CIPHER_DES, 8, 8, 0, 1, EVP_des_cbc }, >- { "3des", SSH_CIPHER_3DES, 8, 16, 0, 1, evp_ssh1_3des }, >- { "blowfish", SSH_CIPHER_BLOWFISH, 8, 32, 0, 1, evp_ssh1_bf }, >- >- { "3des-cbc", SSH_CIPHER_SSH2, 8, 24, 0, 1, EVP_des_ede3_cbc }, >- { "blowfish-cbc", SSH_CIPHER_SSH2, 8, 16, 0, 1, EVP_bf_cbc }, >- { "cast128-cbc", SSH_CIPHER_SSH2, 8, 16, 0, 1, EVP_cast5_cbc }, >- { "arcfour", SSH_CIPHER_SSH2, 8, 16, 0, 0, EVP_rc4 }, >- { "arcfour128", SSH_CIPHER_SSH2, 8, 16, 1536, 0, EVP_rc4 }, >- { "arcfour256", SSH_CIPHER_SSH2, 8, 32, 1536, 0, EVP_rc4 }, >- { "aes128-cbc", SSH_CIPHER_SSH2, 16, 16, 0, 1, EVP_aes_128_cbc }, >- { "aes192-cbc", SSH_CIPHER_SSH2, 16, 24, 0, 1, EVP_aes_192_cbc }, >- { "aes256-cbc", SSH_CIPHER_SSH2, 16, 32, 0, 1, EVP_aes_256_cbc }, >+ { "none", SSH_CIPHER_NONE, 8, 0, 0, 0, EVP_enc_null, 0 }, >+ { "des", SSH_CIPHER_DES, 8, 8, 0, 1, EVP_des_cbc, 0 }, >+ { "3des", SSH_CIPHER_3DES, 8, 16, 0, 1, evp_ssh1_3des, 0 }, >+ { "blowfish", SSH_CIPHER_BLOWFISH, 8, 32, 0, 1, evp_ssh1_bf, 0 }, >+ >+ { "3des-cbc", SSH_CIPHER_SSH2, 8, 24, 0, 1, EVP_des_ede3_cbc, 1 }, >+ { "blowfish-cbc", SSH_CIPHER_SSH2, 8, 16, 0, 1, EVP_bf_cbc, 0 }, >+ { "cast128-cbc", SSH_CIPHER_SSH2, 8, 16, 0, 1, EVP_cast5_cbc, 0 }, >+ { "arcfour", SSH_CIPHER_SSH2, 8, 16, 0, 0, EVP_rc4, 0 }, >+ { "arcfour128", SSH_CIPHER_SSH2, 8, 16, 1536, 0, EVP_rc4, 0 }, >+ { "arcfour256", SSH_CIPHER_SSH2, 8, 32, 1536, 0, EVP_rc4, 0 }, >+ { "aes128-cbc", SSH_CIPHER_SSH2, 16, 16, 0, 1, EVP_aes_128_cbc, 1 }, >+ { "aes192-cbc", SSH_CIPHER_SSH2, 16, 24, 0, 1, EVP_aes_192_cbc, 1 }, >+ { "aes256-cbc", SSH_CIPHER_SSH2, 16, 32, 0, 1, EVP_aes_256_cbc, 1 }, > { "rijndael-cbc@lysator.liu.se", >- SSH_CIPHER_SSH2, 16, 32, 0, 1, EVP_aes_256_cbc }, >- { "aes128-ctr", SSH_CIPHER_SSH2, 16, 16, 0, 0, evp_aes_128_ctr }, >- { "aes192-ctr", SSH_CIPHER_SSH2, 16, 24, 0, 0, evp_aes_128_ctr }, >- { "aes256-ctr", SSH_CIPHER_SSH2, 16, 32, 0, 0, evp_aes_128_ctr }, >+ SSH_CIPHER_SSH2, 16, 32, 0, 1, EVP_aes_256_cbc, 0 }, >+ { "aes128-ctr", SSH_CIPHER_SSH2, 16, 16, 0, 0, evp_aes_128_ctr, 1 }, >+ { "aes192-ctr", SSH_CIPHER_SSH2, 16, 24, 0, 0, evp_aes_128_ctr, 1 }, >+ { "aes256-ctr", SSH_CIPHER_SSH2, 16, 32, 0, 0, evp_aes_128_ctr, 1 }, > #ifdef USE_CIPHER_ACSS >- { "acss@openssh.org", SSH_CIPHER_SSH2, 16, 5, 0, 0, EVP_acss }, >+ { "acss@openssh.org", SSH_CIPHER_SSH2, 16, 5, 0, 0, EVP_acss, 0 }, > #endif >- { NULL, SSH_CIPHER_INVALID, 0, 0, 0, 0, NULL } >+ { NULL, SSH_CIPHER_INVALID, 0, 0, 0, 0, NULL, 0 } > }; > > /*--*/ >@@ -163,6 +166,13 @@ > for ((p = strsep(&cp, CIPHER_SEP)); p && *p != '\0'; > (p = strsep(&cp, CIPHER_SEP))) { > c = cipher_by_name(p); >+ #ifdef OPENSSL_FIPS >+ if (fips_mode && !(c->fips_allowed)) { >+ debug("cipher %s disallowed in FIPS mode [%s]", p, names); >+ xfree(cipher_list); >+ return 0; >+ } >+ #endif > if (c == NULL || c->number != SSH_CIPHER_SSH2) { > debug("bad cipher %s [%s]", p, names); > xfree(cipher_list); >@@ -298,9 +308,25 @@ > cipher_set_key_string(CipherContext *cc, Cipher *cipher, > const char *passphrase, int do_encrypt) > { >+ #ifdef OPENSSL_FIPS >+ SHA_CTX sha; >+ #endif > MD5_CTX md; >- u_char digest[16]; >+ u_char digest[20]; > >+ #ifdef OPENSSL_FIPS >+ if (fips_mode) { >+ SHA1_Init(&sha); >+ SHA1_Update(&sha, (const u_char *)passphrase, strlen(passphrase)); >+ SHA1_Final(digest, &sha); >+ >+ cipher_init(cc, cipher, digest, 20, NULL, 0, do_encrypt); >+ >+ memset(digest, 0, sizeof(digest)); >+ memset(&sha, 0, sizeof(sha)); >+ return; >+ } >+ #endif > MD5_Init(&md); > MD5_Update(&md, (const u_char *)passphrase, strlen(passphrase)); > MD5_Final(digest, &md); >diff -Naur openssh-5.3p1/configure.ac openssh-5.4p1/configure.ac >--- openssh-5.3p1/configure.ac 2009-09-11 00:56:08.000000000 -0400 >+++ openssh-5.4p1/configure.ac 2010-01-28 19:22:04.000000000 -0500 >@@ -510,6 +510,7 @@ > if test -z "$GCC"; then > CFLAGS="$CFLAGS -Ae" > fi >+ HPUX=1 > ;; > *-*-hpux11*) > AC_DEFINE(PAM_SUN_CODEBASE, 1, >@@ -521,6 +522,7 @@ > AC_DEFINE(USE_BTMP, 1, [Use btmp to log bad logins]) > check_for_hpux_broken_getaddrinfo=1 > check_for_conflicting_getspnam=1 >+ HPUX=1 > ;; > esac > >@@ -532,6 +534,7 @@ > protected password database]) > disable_ptmx_check=yes > LIBS="$LIBS -lsecpw" >+ HPU > ;; > esac > ;; >@@ -1864,6 +1867,8 @@ > # Relative paths > ./*|../*) withval="`pwd`/$withval" > esac >+ ssldir=$withval >+ AC_SUBST(ssldir) > if test -d "$withval/lib"; then > if test -n "${need_dash_r}"; then > LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}" >@@ -2216,6 +2221,33 @@ > ) > fi > >+#Check for OpenSSL FIPS mode >+AC_ARG_WITH(fips, >+ [ --with-fips Enable OpenSSL FIPS mode ], >+ [ >+ if test "x$withval" != "xno" ; then >+ AC_CACHE_CHECK([for FIPS mode], ac_cv_fips, [ >+ AC_TRY_COMPILE( >+ [ #include <openssl/fips.h> ], >+ [ FIPS_mode_set(1); ], >+ [ ac_cv_fips="yes" ], >+ [ ac_cv_fips"no" ] >+ ) >+ ]) >+ fi >+ ] >+) >+if test "x$ac_cv_fips" = "xyes" ; then >+ CPPFLAGS="$CPPFLAGS -DOPENSLL_FIPS" >+ if test "x$HPUX" = "x" ; then >+ LIBS=`echo $LIBS | sed 's/-lcrypto /-wl,-Bstatic -lcrypto -wl,-Bdynamic /'` >+ else >+ LIBS=`echo $LIBS | sed 's/-lcrypto /-wl,-aarchive -lcrypto -wl,-adefault /'` >+ fi >+ FIPS_MODE=yes >+ AC_SUBST(FIPS_MODE) >+fi >+ > # Do we want to force the use of the rand helper? > AC_ARG_WITH(rand-helper, > [ --with-rand-helper Use subprocess to gather strong randomness ], >diff -Naur openssh-5.3p1/contrib/redhat/sshd.init openssh-5.4p1/contrib/redhat/sshd.init >--- openssh-5.3p1/contrib/redhat/sshd.init 2006-04-22 07:26:08.000000000 -0400 >+++ openssh-5.4p1/contrib/redhat/sshd.init 2010-01-28 19:22:02.000000000 -0500 >@@ -24,7 +24,11 @@ > # Some functions to make the below more readable > KEYGEN=/usr/bin/ssh-keygen > SSHD=/usr/sbin/sshd >-RSA1_KEY=/etc/ssh/ssh_host_key >+if [ "$OPENSSH_FIPS" ] ; then >+ EXTRA_SSH_KEYGEN_RSA_FLAGS="-b 2048" >+else >+ RSA1_KEY=/etc/ssh/ssh_host_key >+fi > RSA_KEY=/etc/ssh/ssh_host_rsa_key > DSA_KEY=/etc/ssh/ssh_host_dsa_key > PID_FILE=/var/run/sshd.pid >@@ -32,7 +36,7 @@ > do_rsa1_keygen() { > if [ ! -s $RSA1_KEY ]; then > echo -n $"Generating SSH1 RSA host key: " >- if $KEYGEN -q -t rsa1 -f $RSA1_KEY -C '' -N '' >&/dev/null; then >+ if $KEYGEN -q -t rsa1 -f $RSA1_KEY -C '' -N '' $EXTRA_SSH_KEYGEN_RSA_FLAGS >&/dev/null; then > chmod 600 $RSA1_KEY > chmod 644 $RSA1_KEY.pub > if [ -x /sbin/restorecon ]; then >@@ -51,7 +55,7 @@ > do_rsa_keygen() { > if [ ! -s $RSA_KEY ]; then > echo -n $"Generating SSH2 RSA host key: " >- if $KEYGEN -q -t rsa -f $RSA_KEY -C '' -N '' >&/dev/null; then >+ if $KEYGEN -q -t rsa -f $RSA_KEY -C '' -N "" $EXTRA_SSH_KEYGEN_RSA_FLAGS >&/dev/null; then > chmod 600 $RSA_KEY > chmod 644 $RSA_KEY.pub > if [ -x /sbin/restorecon ]; then >@@ -70,7 +74,7 @@ > do_dsa_keygen() { > if [ ! -s $DSA_KEY ]; then > echo -n $"Generating SSH2 DSA host key: " >- if $KEYGEN -q -t dsa -f $DSA_KEY -C '' -N '' >&/dev/null; then >+ if $KEYGEN -q -t dsa -f $DSA_KEY -C '' -N '' $EXTRA_SSH_KEYGEN_DSA_FLAGS >&/dev/null; then > chmod 600 $DSA_KEY > chmod 644 $DSA_KEY.pub > if [ -x /sbin/restorecon ]; then >diff -Naur openssh-5.3p1/fips.h openssh-5.4p1/fips.h >--- openssh-5.3p1/fips.h 1969-12-31 19:00:00.000000000 -0500 >+++ openssh-5.4p1/fips.h 2010-01-28 19:22:02.000000000 -0500 >@@ -0,0 +1 @@ >+extern int fips_mode; >diff -Naur openssh-5.3p1/mac.c openssh-5.4p1/mac.c >--- openssh-5.3p1/mac.c 2008-06-12 20:58:50.000000000 -0400 >+++ openssh-5.4p1/mac.c 2010-01-28 19:22:02.000000000 -0500 >@@ -41,6 +41,7 @@ > #include "kex.h" > #include "mac.h" > #include "misc.h" >+#include "fips.h" > > #include "umac.h" > >@@ -54,15 +55,16 @@ > int truncatebits; /* truncate digest if != 0 */ > int key_len; /* just for UMAC */ > int len; /* just for UMAC */ >+ int fips_allowed; > } macs[] = { >- { "hmac-sha1", SSH_EVP, EVP_sha1, 0, -1, -1 }, >- { "hmac-sha1-96", SSH_EVP, EVP_sha1, 96, -1, -1 }, >- { "hmac-md5", SSH_EVP, EVP_md5, 0, -1, -1 }, >- { "hmac-md5-96", SSH_EVP, EVP_md5, 96, -1, -1 }, >- { "hmac-ripemd160", SSH_EVP, EVP_ripemd160, 0, -1, -1 }, >- { "hmac-ripemd160@openssh.com", SSH_EVP, EVP_ripemd160, 0, -1, -1 }, >- { "umac-64@openssh.com", SSH_UMAC, NULL, 0, 128, 64 }, >- { NULL, 0, NULL, 0, -1, -1 } >+ { "hmac-sha1", SSH_EVP, EVP_sha1, 0, -1, -1, 1 }, >+ { "hmac-sha1-96", SSH_EVP, EVP_sha1, 96, -1, -1, 1 }, >+ { "hmac-md5", SSH_EVP, EVP_md5, 0, -1, -1, 0 }, >+ { "hmac-md5-96", SSH_EVP, EVP_md5, 96, -1, -1, 0 }, >+ { "hmac-ripemd160", SSH_EVP, EVP_ripemd160, 0, -1, -1, 0 }, >+ { "hmac-ripemd160@openssh.com", SSH_EVP, EVP_ripemd160, 0, -1, -1, 0 }, >+ { "umac-64@openssh.com", SSH_UMAC, NULL, 0, 128, 64, 0 }, >+ { NULL, 0, NULL, 0, -1, -1, 0 } > }; > > static void >@@ -91,6 +93,12 @@ > > for (i = 0; macs[i].name; i++) { > if (strcmp(name, macs[i].name) == 0) { >+ #ifdef OPENSSL_FIPS >+ if (fips_mode && !macs[i].fips_allowed) { >+ debug2("mac_init: %s disallowed in fips mode", name); >+ return (-1); >+ } >+ #endif > if (mac != NULL) > mac_setup_by_id(mac, i); > debug2("mac_setup: found %s", name); >diff -Naur openssh-5.3p1/Makefile.in openssh-5.4p1/Makefile.in >--- openssh-5.3p1/Makefile.in 2009-08-27 20:47:38.000000000 -0400 >+++ openssh-5.4p1/Makefile.in 2010-01-28 19:22:04.000000000 -0500 >@@ -18,6 +18,7 @@ > piddir=@piddir@ > srcdir=@srcdir@ > top_srcdir=@top_srcdir@ >+ssldir=@ssldir@ > > DESTDIR= > VPATH=@srcdir@ >@@ -29,6 +30,7 @@ > PRIVSEP_PATH=@PRIVSEP_PATH@ > SSH_PRIVSEP_USER=@SSH_PRIVSEP_USER@ > STRIP_OPT=@STRIP_OPT@ >+FIPS_MODE=@FIPS_MODE@ > > PATHS= -DSSHDIR=\"$(sysconfdir)\" \ > -D_PATH_SSH_PROGRAM=\"$(SSH_PROGRAM)\" \ >@@ -255,12 +257,18 @@ > $(srcdir)/mkinstalldirs $(DESTDIR)$(libexecdir) > (umask 022 ; $(srcdir)/mkinstalldirs $(DESTDIR)$(PRIVSEP_PATH)) > $(INSTALL) -m 0755 $(STRIP_OPT) ssh $(DESTDIR)$(bindir)/ssh >+ if [ ! -z "FIPS_MODE" ]; then \ >+ $(INSTALL) -m 0755 $(STRIP_OPT) ssh $(DESTDIR)$(bindir)/ssh.sha1; \ >+ fi > $(INSTALL) -m 0755 $(STRIP_OPT) scp $(DESTDIR)$(bindir)/scp > $(INSTALL) -m 0755 $(STRIP_OPT) ssh-add $(DESTDIR)$(bindir)/ssh-add > $(INSTALL) -m 0755 $(STRIP_OPT) ssh-agent $(DESTDIR)$(bindir)/ssh-agent > $(INSTALL) -m 0755 $(STRIP_OPT) ssh-keygen $(DESTDIR)$(bindir)/ssh-keygen > $(INSTALL) -m 0755 $(STRIP_OPT) ssh-keyscan $(DESTDIR)$(bindir)/ssh-keyscan > $(INSTALL) -m 0755 $(STRIP_OPT) sshd $(DESTDIR)$(sbindir)/sshd >+ if [ ! -z "FIPS_MODE" ]; then \ >+ $(INSTALL) -m 0755 $(STRIP_OPT) sshd $(DESTDIR)$(bindir)/sshd.sha1; >+ fi > if test ! -z "$(INSTALL_SSH_RAND_HELPER)" ; then \ > $(INSTALL) -m 0755 $(STRIP_OPT) ssh-rand-helper $(DESTDIR)$(libexecdir)/ssh-rand-helper ; \ > fi >diff -Naur openssh-5.3p1/myproposal.h openssh-5.4p1/myproposal.h >--- openssh-5.3p1/myproposal.h 2009-01-28 00:33:31.000000000 -0500 >+++ openssh-5.4p1/myproposal.h 2010-01-28 19:22:04.000000000 -0500 >@@ -41,6 +41,7 @@ > #endif > > #define KEX_DEFAULT_PK_ALG "ssh-rsa,ssh-dss" >+#ifndef OPENSSL_FIPS > > #define KEX_DEFAULT_ENCRYPT \ > "aes128-ctr,aes192-ctr,aes256-ctr," \ >@@ -51,6 +52,15 @@ > "hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160," \ > "hmac-ripemd160@openssh.com," \ > "hmac-sha1-96,hmac-md5-96" >+#else >+#define KEX_DEFAULT_ENCRYPT \ >+ "aes128-cbc,3des-cbc," \ >+ "aes128192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se," \ >+ "aes128-ctr,aes192-ctr,aes256-ctr" >+#define KEX_DEFAULT_MAC \ >+ "hmac_sha1," \ >+ "hmac-sha1-96" >+#endif > #define KEX_DEFAULT_COMP "none,zlib@openssh.com,zlib" > #define KEX_DEFAULT_LANG "" > >diff -Naur openssh-5.3p1/openbsd-compat/bsd-arc4random.c openssh-5.4p1/openbsd-compat/bsd-arc4random.c >--- openssh-5.3p1/openbsd-compat/bsd-arc4random.c 2008-06-03 20:54:00.000000000 -0400 >+++ openssh-5.4p1/openbsd-compat/bsd-arc4random.c 2010-01-28 19:22:04.000000000 -0500 >@@ -30,6 +30,10 @@ > #include <openssl/rc4.h> > #include <openssl/err.h> > >+#ifdef OPENSSL_FIPS >+#inclulde "fips.h" >+#endif >+ > /* Size of key to use */ > #define SEED_SIZE 20 > >@@ -46,12 +50,26 @@ > static int first_time = 1; > > if (rc4_ready <= 0) { >+#ifndef OPENSSL_FIPS > if (first_time) > seed_rng(); >+#endif > first_time = 0; > arc4random_stir(); > } > >+#ifdef OPENSSL_FIPS >+ if (fips_mode) { >+ if (RAND_bytes(&r,sizeof(r)) <= 0) { >+ ERR_load_crypto_strings(); >+ ERR_print_errors_fp(stderr); >+ return 1/0; >+ } >+ rc4_ready -= sizeof(r); >+ >+ return(r); >+ } >+#endif > RC4(&rc4, sizeof(r), (unsigned char *)&r, (unsigned char *)&r); > > rc4_ready -= sizeof(r); >@@ -65,6 +83,14 @@ > unsigned char rand_buf[SEED_SIZE]; > int i; > >+#ifdef OPENSSL_FIPS >+ if (fips_mode) { >+ rc4_ready = REKEY_BYTES; >+ return; >+ } >+#endif >+ >+ > memset(&rc4, 0, sizeof(rc4)); > if (RAND_bytes(rand_buf, sizeof(rand_buf)) <= 0) > fatal("Couldn't obtain random bytes (error %ld)", >diff -Naur openssh-5.3p1/readconf.c openssh-5.4p1/readconf.c >--- openssh-5.3p1/readconf.c 2009-07-05 17:12:27.000000000 -0400 >+++ openssh-5.4p1/readconf.c 2010-01-28 19:22:02.000000000 -0500 >@@ -131,6 +131,7 @@ > oSendEnv, oControlPath, oControlMaster, oHashKnownHosts, > oTunnel, oTunnelDevice, oLocalCommand, oPermitLocalCommand, > oVisualHostKey, oUseRoaming, oZeroKnowledgePasswordAuthentication, >+ oFipsMode, > oDeprecated, oUnsupported > } OpCodes; > >@@ -227,6 +228,7 @@ > { "tunneldevice", oTunnelDevice }, > { "localcommand", oLocalCommand }, > { "permitlocalcommand", oPermitLocalCommand }, >+ { "fipsmode", oFipsMode}; > { "visualhostkey", oVisualHostKey }, > { "useroaming", oUseRoaming }, > #ifdef JPAKE >@@ -911,6 +913,10 @@ > intptr = &options->permit_local_command; > goto parse_flag; > >+ case oFipsMode; >+ intptr = &options->fips_mode >+ goto parse_flag; >+ > case oVisualHostKey: > intptr = &options->visual_host_key; > goto parse_flag; >@@ -1068,6 +1074,7 @@ > options->tun_remote = -1; > options->local_command = NULL; > options->permit_local_command = -1; >+ options->fips_mode = -1; > options->use_roaming = -1; > options->visual_host_key = -1; > options->zero_knowledge_password_authentication = -1; >@@ -1138,9 +1145,9 @@ > /* Selected in ssh_login(). */ > if (options->cipher == -1) > options->cipher = SSH_CIPHER_NOT_SET; >- /* options->ciphers, default set in myproposals.h */ >- /* options->macs, default set in myproposals.h */ >- /* options->hostkeyalgorithms, default set in myproposals.h */ >+ /* options->ciphers, default set in myproposal.h */ >+ /* options->macs, default set in myproposal.h */ >+ /* options->hostkeyalgorithms, default set in myproposal.h */ > if (options->protocol == SSH_PROTO_UNKNOWN) > options->protocol = SSH_PROTO_1|SSH_PROTO_2; > if (options->num_identity_files == 0) { >@@ -1205,6 +1212,10 @@ > options->tun_remote = SSH_TUNID_ANY; > if (options->permit_local_command == -1) > options->permit_local_command = 0; >+ if (options->fips_mode == -1) >+ options->fips_mode = 0; >+ if (options->fips_mode && options->macs == NULL) >+ options->macs = "hmac-sha,hmac-sha1-96"; > if (options->use_roaming == -1) > options->use_roaming = 1; > if (options->visual_host_key == -1) >diff -Naur openssh-5.3p1/readconf.h openssh-5.4p1/readconf.h >--- openssh-5.3p1/readconf.h 2009-07-05 17:12:27.000000000 -0400 >+++ openssh-5.4p1/readconf.h 2010-01-28 19:22:03.000000000 -0500 >@@ -121,6 +121,7 @@ > > char *local_command; > int permit_local_command; >+ int fips_mode; > int visual_host_key; > > int use_roaming; >diff -Naur openssh-5.3p1/servconf.c openssh-5.4p1/servconf.c >--- openssh-5.3p1/servconf.c 2009-06-21 06:26:17.000000000 -0400 >+++ openssh-5.4p1/servconf.c 2010-01-28 19:22:02.000000000 -0500 >@@ -107,6 +107,11 @@ > options->num_allow_groups = 0; > options->num_deny_groups = 0; > options->ciphers = NULL; >+ #ifdef OPENSSL_FIPS >+ options->macs = "hmac-sha1,hmac-sha1-96"; >+ #else >+ options->macs = NULL; >+ #endif > options->macs = NULL; > options->protocol = SSH_PROTO_UNKNOWN; > options->gateway_ports = -1; >@@ -126,6 +131,7 @@ > options->permit_tun = -1; > options->num_permitted_opens = -1; > options->adm_forced_command = NULL; >+ options->fips_mode = -1; > options->chroot_directory = NULL; > options->zero_knowledge_password_authentication = -1; > } >@@ -259,6 +265,8 @@ > options->authorized_keys_file = _PATH_SSH_USER_PERMITTED_KEYS; > if (options->permit_tun == -1) > options->permit_tun = SSH_TUNMODE_NO; >+ if (options->fips_mode == -1) >+ options->fips_mode = 0; > if (options->zero_knowledge_password_authentication == -1) > options->zero_knowledge_password_authentication = 0; > >@@ -305,6 +313,7 @@ > sGssAuthentication, sGssCleanupCreds, sAcceptEnv, sPermitTunnel, > sMatch, sPermitOpen, sForceCommand, sChrootDirectory, > sUsePrivilegeSeparation, sAllowAgentForwarding, >+ sFipsMode, > sZeroKnowledgePasswordAuthentication, > sDeprecated, sUnsupported > } ServerOpCodes; >@@ -423,6 +432,7 @@ > { "match", sMatch, SSHCFG_ALL }, > { "permitopen", sPermitOpen, SSHCFG_ALL }, > { "forcecommand", sForceCommand, SSHCFG_ALL }, >+ { "fipsmode", sFipsMode, SSHCFG_GLOBAL }, > { "chrootdirectory", sChrootDirectory, SSHCFG_ALL }, > { NULL, sBadOption, 0 } > }; >@@ -1294,6 +1304,10 @@ > *charptr = xstrdup(arg); > break; > >+ case sFipsMode: >+ intptr = &options->fips_mode; >+ goto parse_flag; >+ > case sDeprecated: > logit("%s line %d: Deprecated option %s", > filename, linenum, arg); >diff -Naur openssh-5.3p1/servconf.h openssh-5.4p1/servconf.h >--- openssh-5.3p1/servconf.h 2009-01-28 00:31:23.000000000 -0500 >+++ openssh-5.4p1/servconf.h 2010-01-28 19:22:03.000000000 -0500 >@@ -150,6 +150,8 @@ > > int num_permitted_opens; > >+ int fips_mode; >+ > char *chroot_directory; > } ServerOptions; > >diff -Naur openssh-5.3p1/ssh-add.c openssh-5.4p1/ssh-add.c >--- openssh-5.3p1/ssh-add.c 2008-02-28 03:13:52.000000000 -0500 >+++ openssh-5.4p1/ssh-add.c 2010-01-28 19:22:03.000000000 -0500 >@@ -62,10 +62,17 @@ > #include "authfile.h" > #include "pathnames.h" > #include "misc.h" >+#include "fips.h" > > /* argv0 */ > extern char *__progname; > >+/* >+ * FIPS mode operation >+*/ >+#ifdef OPENSSL_FIPS >+ int fips_mode = 0; >+#endif > /* Default files to add */ > static char *default_files[] = { > _PATH_SSH_CLIENT_ID_RSA, >@@ -338,6 +345,10 @@ > /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */ > sanitise_stdfd(); > >+ #ifdef OPENSSL_FIPS >+ if (getenv("OPENSSH_FIPS")) fips_mode=1; >+ #endif >+ > __progname = ssh_get_progname(argv[0]); > init_rng(); > seed_rng(); >diff -Naur openssh-5.3p1/ssh-agent.c openssh-5.4p1/ssh-agent.c >--- openssh-5.3p1/ssh-agent.c 2009-06-21 03:50:15.000000000 -0400 >+++ openssh-5.4p1/ssh-agent.c 2010-01-28 19:22:02.000000000 -0500 >@@ -75,6 +75,14 @@ > #include "compat.h" > #include "log.h" > #include "misc.h" >+#include "fips.h" >+ >+/* >+ * FIPS operational mode >+*/ >+#ifdef OPENSSL_FIPS >+ int fips_mode = 0; >+#endif > > #ifdef SMARTCARD > #include "scard.h" >@@ -1063,6 +1071,10 @@ > struct timeval *tvp = NULL; > size_t len; > >+ #ifdef OPENSSL_FIPS >+ if (getenv("OPENSSH_FIPS")) fips_mode = 1; >+ #endif >+ > /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */ > sanitise_stdfd(); > >diff -Naur openssh-5.3p1/ssh.c openssh-5.4p1/ssh.c >--- openssh-5.3p1/ssh.c 2009-07-05 17:16:56.000000000 -0400 >+++ openssh-5.4p1/ssh.c 2010-01-28 19:22:02.000000000 -0500 >@@ -72,6 +72,11 @@ > > #include <openssl/evp.h> > #include <openssl/err.h> >+#ifdef OPENSSL_FIPS >+ #include <openssl/fips.h> >+ #include <openssl/rand.h> >+ #include <openssl/fips_rand.h> >+#endif > #include "openbsd-compat/openssl-compat.h" > #include "openbsd-compat/sys-queue.h" > >@@ -101,6 +106,16 @@ > #include "msg.h" > #include "uidswap.h" > #include "version.h" >+#include "fips.h" >+ >+/* >+ * FIPS Mode operation >+*/ >+#ifdef OPENSSL_FIPS >+ int fips_mode = 1; //refined later >+#else >+ int fips_mode = 0; >+#endif > > #ifdef SMARTCARD > #include "scard.h" >@@ -175,12 +190,17 @@ > extern u_int muxclient_command; > > /* Prints a help message to the user. This function never returns. */ >+#ifdef OPENSSL_FIPS >+ #define FIPS_OPTS "Z" >+#else >+ #define FIPS_OPTS >+#endif > > static void > usage(void) > { > fprintf(stderr, >-"usage: ssh [-1246AaCfgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]\n" >+"usage: ssh [-1246AaCfgKkMNnqsTtVvXxYy" FIPS_OPTS"] [-b bind_address] [-c cipher_spec]\n" > " [-D [bind_address:]port] [-e escape_char] [-F configfile]\n" > " [-i identity_file] [-L [bind_address:]port:host:hostport]\n" > " [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]\n" >@@ -275,8 +295,13 @@ > > again: > while ((opt = getopt(ac, av, "1246ab:c:e:fgi:kl:m:no:p:qstvx" >- "ACD:F:I:KL:MNO:PR:S:TVw:XYy")) != -1) { >+ "ACD:F:I:KL:MNO:PR:S:TVw:XYy" FIPS_OPTS "")) != -1) { > switch (opt) { >+ #ifdef OPENSSL_FIPS >+ case 'Z': >+ fips_mode = 0; >+ break; >+ #endif > case '1': > options.protocol = SSH_PROTO_1; > break; >@@ -634,6 +659,36 @@ > log_init(argv0, options.log_level, SYSLOG_FACILITY_USER, !use_syslog); > > seed_rng(); >+ #ifdef OPENSSL_FIPS >+ /* >+ Priority Setting: >+ !command line >+ env OPENSSH_FIPS >+ !env OPENSSH_NO_FIPS >+ ssh_config options (default: false) >+ */ >+ if (fips_mode) { /* !command line */ >+ if (getenv("OPENSSH_FIPS")) { /* env OPENSSH_FIPS */ >+ } >+ else if (getenv("OPENSSH_NO_FIPS")) { /* !env OPENSSH_NO_FIPS */ >+ fips_mode = 0; >+ } >+ else if (options.fips_mode == 0) {[ /* ssh_config options */ >+ fips_mode = 0; >+ } >+ } >+ if(fips_mode) >+ { >+ if(!FIPS_mode_set(1)) >+ { >+ ERR_load_crypto_strings(); >+ ERR_print_errors_fp(stderr); >+ exit(1); >+ } >+ else >+ fprintf(stderr,:*** IN FIPS MODE ***\n:); >+ } >+ #endif > > if (options.user == NULL) > options.user = xstrdup(pw->pw_name); >diff -Naur openssh-5.3p1/sshconnect2.c openssh-5.4p1/sshconnect2.c >--- openssh-5.3p1/sshconnect2.c 2009-03-05 08:58:22.000000000 -0500 >+++ openssh-5.4p1/sshconnect2.c 2010-01-28 19:22:04.000000000 -0500 >@@ -70,6 +70,7 @@ > #include "uidswap.h" > #include "schnorr.h" > #include "jpake.h" >+#include "fips.h" > > #ifdef GSSAPI > #include "ssh-gss.h" >@@ -475,6 +476,13 @@ > char *pkalg, *fp; > u_char *pkblob; > >+ enum fp_type dgst_type = SSH_FP_MD5; >+ #ifdef OPENSSL_FIPS >+ if (fips_mode) { >+ dgst_type = SSH_FP_SHA1; >+ } >+ #endif >+ > if (authctxt == NULL) > fatal("input_userauth_pk_ok: no authentication context"); > if (datafellows & SSH_BUG_PKOK) { >@@ -507,7 +515,7 @@ > key->type, pktype); > goto done; > } >- fp = key_fingerprint(key, SSH_FP_MD5, SSH_FP_HEX); >+ fp = key_fingerprint(key, dgst_type, SSH_FP_HEX); > debug2("input_userauth_pk_ok: fp %s", fp); > xfree(fp); > >diff -Naur openssh-5.3p1/sshconnect.c openssh-5.4p1/sshconnect.c >--- openssh-5.3p1/sshconnect.c 2009-06-21 04:53:53.000000000 -0400 >+++ openssh-5.4p1/sshconnect.c 2010-01-28 19:22:04.000000000 -0500 >@@ -58,6 +58,7 @@ > #include "dns.h" > #include "roaming.h" > #include "version.h" >+#include "fips.h" > > char *client_version_string = NULL; > char *server_version_string = NULL; >@@ -596,6 +597,12 @@ > char msg[1024]; > int len, host_line, ip_line, cancelled_forwarding = 0; > const char *host_file = NULL, *ip_file = NULL; >+ enum fp_type dgst_type = SSH_FP_MD5; >+ #ifdef OPENSSL_FIPS >+ if (fips_mode) { >+ dgst_type = SSH_FP_SHA1; >+ } >+ #endif > > /* > * Force accepting of the host key for loopback/localhost. The >@@ -767,8 +774,8 @@ > else > snprintf(msg1, sizeof(msg1), "."); > /* The default */ >- fp = key_fingerprint(host_key, SSH_FP_MD5, SSH_FP_HEX); >- ra = key_fingerprint(host_key, SSH_FP_MD5, >+ fp = key_fingerprint(host_key, dgst_type, SSH_FP_HEX); >+ ra = key_fingerprint(host_key, dgst_type, > SSH_FP_RANDOMART); > msg2[0] = '\0'; > if (options.verify_host_key_dns) { >@@ -1076,11 +1083,18 @@ > char *fp, *ra; > int line, ret; > >+ enum_fp_type dgst_type = SSH_FP_MD5; >+ #ifdef OPENSSL_FIPS >+ if (fips_mode) { >+ dgst_type = SSH_FP_SHA1; >+ } >+ #endif >+ > found = key_new(keytype); > if ((ret = lookup_key_in_hostfile_by_type(file, host, > keytype, found, &line))) { >- fp = key_fingerprint(found, SSH_FP_MD5, SSH_FP_HEX); >- ra = key_fingerprint(found, SSH_FP_MD5, SSH_FP_RANDOMART); >+ fp = key_fingerprint(found, dgst_type, SSH_FP_HEX); >+ ra = key_fingerprint(found, dgst_type, SSH_FP_RANDOMART); > logit("WARNING: %s key found for host %s\n" > "in %s:%d\n" > "%s key fingerprint %s.\n%s\n", >@@ -1132,7 +1146,14 @@ > char *fp; > const char *type = key_type(host_key); > >- fp = key_fingerprint(host_key, SSH_FP_MD5, SSH_FP_HEX); >+ enum fp_type dgst_type = SSH_FP_MD5; >+ #ifdef OPENSSL_FIPS >+ if (fips_mode) { >+ dgst_type = SSH_FP_SHA1; >+ } >+ #endif >+ >+ fp = key_fingerprint(host_key, dgst_type, SSH_FP_HEX); > > error("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"); > error("@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @"); >diff -Naur openssh-5.3p1/sshd.c openssh-5.4p1/sshd.c >--- openssh-5.3p1/sshd.c 2009-06-21 06:26:17.000000000 -0400 >+++ openssh-5.4p1/sshd.c 2010-01-28 19:22:03.000000000 -0500 >@@ -76,6 +76,11 @@ > #include <openssl/bn.h> > #include <openssl/md5.h> > #include <openssl/rand.h> >+#ifdef OPENSSL_FIPS >+ #include <fips.h> >+ #include <openssl/fips.h> >+ #include <openssl/fips_rand.h> >+#endif > #include "openbsd-compat/openssl-compat.h" > > #ifdef HAVE_SECUREWARE >@@ -139,6 +144,13 @@ > > extern char *__progname; > >+/* FIPS mode operation indicator */ >+#ifdef OPENSSL_FIPS >+ int fips_MODE = 1; //refined later >+#else >+ int fips_mode = 0; >+#endif >+ > /* Server configuration options. */ > ServerOptions options; > >@@ -415,8 +427,12 @@ > major = PROTOCOL_MAJOR_1; > minor = PROTOCOL_MINOR_1; > } >+ #ifndef OPENSSL_FIPS > snprintf(buf, sizeof buf, "SSH-%d.%d-%.100s%s", major, minor, > SSH_VERSION, newline); >+ #else >+ snprintf(buf, sizeof buf, "SSH-%d.%d-%.100s%s FIPS", major, minor, SSH_VERSION, newline); >+ #endif > server_version_string = xstrdup(buf); > > /* Send our protocol version identification. */ >@@ -579,14 +595,22 @@ > privsep_preauth_child(void) > { > u_int32_t rnd[256]; >+ u_char* buf=(u_char*)rnd; > gid_t gidset[1]; > > /* Enable challenge-response authentication for privilege separation */ > privsep_challenge_enable(); > >+ #ifndef OPENSSL_FIPS > arc4random_stir(); > arc4random_buf(rnd, sizeof(rnd)); > RAND_seed(rnd, sizeof(rnd)); >+ #else >+ arc4random_stir(); >+ FIPS_rand_set_key(buf,buf+8); >+ FIPS_rand_seed(buf+16,8); >+ debug2("FIPS rand reseeded"); >+ #endif > > /* Demote the private keys to public keys. */ > demote_sensitive_data(); >@@ -617,12 +641,23 @@ > { > int status; > pid_t pid; >+ #ifdef OPENSSL_FIPS >+ u_char buf[24]; >+ #endif > > /* Set up unprivileged child process to deal with network data */ > pmonitor = monitor_init(); > /* Store a pointer to the kex for later rekeying */ > pmonitor->m_pkex = &xxx_kex; > >+ #ifdef OPENSSL_FIPS >+ if(RAND_bytes(buf,sizeof buf) <= 0) { >+ ERR_load_crypto_strings(); >+ ERR_print_errors_fp(stderr); >+ fatal("privsep_preauth: RAND_bytes failed"); >+ } >+ #endif >+ > pid = fork(); > if (pid == -1) { > fatal("fork of unprivileged child failed"); >@@ -644,6 +679,13 @@ > return (1); > } else { > /* child */ >+ #ifdef OPENSSL_FIPS >+ FIPS_rand_method()->cleanup(); >+ /* Always automagically seed PRNG */ >+ FIPS_rand_set_key(buf,buf+8); >+ FIPS_rand_seed(buf+16,8); >+ debug2("FIPS rand reseeded"); >+ #endif > > close(pmonitor->m_sendfd); > >@@ -658,6 +700,9 @@ > static void > privsep_postauth(Authctxt *authctxt) > { >+ #ifdef OPENSSL_FIPS >+ u_char buf[24]; >+ #endif > u_int32_t rnd[256]; > > #ifdef DISABLE_FD_PASSING >@@ -673,6 +718,14 @@ > /* New socket pair */ > monitor_reinit(pmonitor); > >+ #ifdef OPENSSL_FIPS >+ if(RAND_bytes(buf,sizeof buf) <= 0) { >+ ERR_load_crypto_strings(); >+ ERR_print_errors_fp(stderr); >+ fatal("privsep_postauth: RAND_bytes failed"); >+ } >+ #endif >+ > pmonitor->m_pid = fork(); > if (pmonitor->m_pid == -1) > fatal("fork of unprivileged child failed"); >@@ -686,6 +739,14 @@ > exit(0); > } > >+ #ifdef OPENSSL_FIPS >+ FIPS_rand_method()->cleanup(); >+ /* Always automagivally seed PRNG */ >+ FIPS_rand_set_key(buf,buf+8); >+ FIPS_rand_seed(buf+16,8); >+ debug2("FIPS rand reseeded"); >+ #endif >+ > close(pmonitor->m_sendfd); > > /* Demote the private keys to public keys. */ >@@ -1028,6 +1089,10 @@ > socklen_t fromlen; > pid_t pid; > >+ #ifdef OPENSSL_FIPS >+ u_char buf[24]; >+ #endif >+ > /* setup fd set for accept */ > fdset = NULL; > maxfd = 0; >@@ -1160,6 +1225,14 @@ > break; > } > >+ #ifdef OPENSSL_FIPS >+ if(RAND_bytes(buf,sizeof buf) <=0) { >+ ERR_load_crypto_strings(); >+ ERR_print_errors_fp(stderr); >+ fatal("server_accept_loop: RAND_bytes failed"); >+ } >+ #endif >+ > /* > * Normal production daemon. Fork, and have > * the child process the connection. The >@@ -1176,6 +1249,13 @@ > * the connection. > */ > platform_post_fork_child(); >+ #ifdef OPENSSL_FIPS >+ FIPS_rand_methods()->cleanup(); >+ /*Always automaticlly seed PRNG */ >+ FIPS_rand_set_key(buf,buf+8); >+ FIPS_rand_seed(buf+16,8); >+ debug2("FIPS rand reseeded"); >+ #endif > startup_pipe = startup_p[1]; > close_startup_pipes(); > close_listen_socks(); >@@ -1471,6 +1551,33 @@ > /* Fill in default values for those options not explicitly set. */ > fill_default_server_options(&options); > >+ #ifdef OPENSSL_FIPS >+ /* >+ Priority Setting: >+ env OPENSSH_FIPS >+ !env OPENSSH_NO_FIPS >+ sshd_config options (default: false) >+ */ >+ if (fips_mode) { >+ if (getenv("OPENSSH_FIPS")) { /* env OPENSSH_FIPS */ >+ } >+ else if (getenv("OPENSSH_NO_FIPS")) { /* !env OPENSSH_NO_FIPS */ >+ fips_mode = 0; >+ } >+ } >+ if(fips_mode) >+ { >+ if(!FIPS_mode_set(1)) >+ { >+ ERR_load_crypto_strings(); >+ ERR_print_errors_fp(stderr); >+ exit(1); >+ } >+ else >+ fprint(stderr,"***IN FIPS MODE***\n"); >+ } >+ #endif >+ > /* challenge-response is implemented via keyboard interactive */ > if (options.challenge_response_authentication) > options.kbd_interactive_authentication = 1; >@@ -1633,8 +1740,23 @@ > #ifdef TIOCNOTTY > int fd; > #endif /* TIOCNOTTY */ >+#ifdef OPENSSL_FIPS >+ u_char buf[24]; >+ if(RAND_bytes(buf,sizeof buf) <= 0) { >+ ERR_load_crypto_strings(); >+ ERR_print_errors_fp(srderr); >+ fatal("privsep_preauth: RAND_bytes failed"); >+ } >+#endif > if (daemon(0, 0) < 0) > fatal("daemon() failed: %.200s", strerror(errno)); >+#ifdef OPENSSL_FIPS >+ FIPS_rand_method()->cleanup(); >+ /* Always automagically seed PRNG */ >+ FIPS_rand_set_key(buf,buf+8); >+ FIPS_rand_seed(buf+16,8); >+ debug2("FIPS rand reseeded"); >+#endif > > /* Disconnect from the controlling tty. */ > #ifdef TIOCNOTTY >diff -Naur openssh-5.3p1/ssh-keygen.c openssh-5.4p1/ssh-keygen.c >--- openssh-5.3p1/ssh-keygen.c 2009-06-22 02:11:07.000000000 -0400 >+++ openssh-5.4p1/ssh-keygen.c 2010-01-28 19:22:03.000000000 -0500 >@@ -48,6 +48,14 @@ > #include "match.h" > #include "hostfile.h" > #include "dns.h" >+#include "fips.h" >+ >+/* >+ * FIPS mode operation >+*/ >+#ifdef OPENSSL_FIPS >+ int fips_mode = 0; >+#endif > > #ifdef SMARTCARD > #include "scard.h" >@@ -1093,6 +1101,13 @@ > extern int optind; > extern char *optarg; > >+ enum fp_type dgst_type = SSH_FP_MD5; >+ #ifdef OPENSSL_FIPS >+ if (getenv("OPENSSH_FIPS")) fips_mode = 1; >+ if (fips_mode) { >+ dgst_type = SSH_FP_SHA1; >+ } >+ #endif > /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */ > sanitise_stdfd(); > >@@ -1465,8 +1480,8 @@ > fclose(f); > > if (!quiet) { >- char *fp = key_fingerprint(public, SSH_FP_MD5, SSH_FP_HEX); >- char *ra = key_fingerprint(public, SSH_FP_MD5, >+ char *fp = key_fingerprint(public, dgst_type, SSH_FP_HEX); >+ char *ra = key_fingerprint(public, dsgt_type, > SSH_FP_RANDOMART); > printf("Your public key has been saved in %s.\n", > identity_file); >diff -Naur openssh-5.3p1/ssh-keyscan.c openssh-5.4p1/ssh-keyscan.c >--- openssh-5.3p1/ssh-keyscan.c 2009-01-28 00:31:23.000000000 -0500 >+++ openssh-5.4p1/ssh-keyscan.c 2010-01-28 19:22:04.000000000 -0500 >@@ -46,6 +46,14 @@ > #include "misc.h" > #include "hostfile.h" > >+#include "fips.h" >+/* >+ * FIPS mode operation >+*/ >+#ifdef OPENSSL_FIPS >+ int fips_mode = 0; >+#endif >+ > /* Flag indicating whether IPv4 or IPv6. This can be set on the command line. > Default value is AF_UNSPEC means both IPv4 and IPv6. */ > int IPv4or6 = AF_UNSPEC; >@@ -730,6 +738,10 @@ > extern int optind; > extern char *optarg; > >+ #ifdef OPENSSL_FIPS >+ if (getenv("OPENSSH_FIPS")) fips_mode = 1; >+ #endif >+ > __progname = ssh_get_progname(argv[0]); > init_rng(); > seed_rng(); >diff -Naur openssh-5.3p1/ssh-keysign.c openssh-5.4p1/ssh-keysign.c >--- openssh-5.3p1/ssh-keysign.c 2006-09-01 01:38:37.000000000 -0400 >+++ openssh-5.4p1/ssh-keysign.c 2010-01-28 19:22:01.000000000 -0500 >@@ -52,6 +52,14 @@ > #include "pathnames.h" > #include "readconf.h" > #include "uidswap.h" >+#include "fips.h" >+ >+/* >+ * FIPS operational mode >+*/ >+#ifdef OPENSSL_FIPS >+ int fips_mode=0; >+#endif > > /* XXX readconf.c needs these */ > uid_t original_real_uid; >@@ -158,6 +166,10 @@ > u_int slen, dlen; > u_int32_t rnd[256]; > >+ #ifdef OPENSSL_FIPS >+ if (getenv("OPENSSH_FIPS")) fips_mode = 1; >+ #endif >+ > /* Ensure that stdin and stdout are connected */ > if ((fd = open(_PATH_DEVNULL, O_RDWR)) < 2) > exit(1); >diff -Naur openssh-5.3p1/ssh-rand-helper.c openssh-5.4p1/ssh-rand-helper.c >--- openssh-5.3p1/ssh-rand-helper.c 2007-03-12 16:35:39.000000000 -0400 >+++ openssh-5.4p1/ssh-rand-helper.c 2010-01-28 19:22:01.000000000 -0500 >@@ -62,6 +62,14 @@ > #include "atomicio.h" > #include "pathnames.h" > #include "log.h" >+#include "fips.h" >+ >+/* >+ * FIPS operational mode >+*/ >+#ifdef OPENSSL_FIPS >+ int fips_mode = 0; >+#endif > > /* Number of bytes we write out */ > #define OUTPUT_SEED_SIZE 48 >@@ -820,6 +828,10 @@ > extern char *optarg; > LogLevel ll; > >+#ifdef OPENSSL_FIPS >+ if (getenv("OPENSSH_FIPS"))) fips_mode = 1; >+#endif >+ > __progname = ssh_get_progname(argv[0]); > log_init(argv[0], SYSLOG_LEVEL_INFO, SYSLOG_FACILITY_USER, 1); >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 1197
:
1783
| 1789