547 lines
18 KiB
Diff
547 lines
18 KiB
Diff
diff -up openssh-6.2p1/authfile.c.fips openssh-6.2p1/authfile.c
|
|
--- openssh-6.2p1/authfile.c.fips 2013-03-27 13:14:49.164683482 +0100
|
|
+++ openssh-6.2p1/authfile.c 2013-03-27 13:14:49.177683431 +0100
|
|
@@ -148,8 +148,14 @@ key_private_rsa1_to_blob(Key *key, Buffe
|
|
/* Allocate space for the private part of the key in the buffer. */
|
|
cp = buffer_append_space(&encrypted, buffer_len(&buffer));
|
|
|
|
- cipher_set_key_string(&ciphercontext, cipher, passphrase,
|
|
- CIPHER_ENCRYPT);
|
|
+ if (cipher_set_key_string(&ciphercontext, cipher, passphrase,
|
|
+ CIPHER_ENCRYPT) < 0) {
|
|
+ error("cipher_set_key_string failed.");
|
|
+ buffer_free(&encrypted);
|
|
+ buffer_free(&buffer);
|
|
+ return 0;
|
|
+ }
|
|
+
|
|
cipher_crypt(&ciphercontext, cp,
|
|
buffer_ptr(&buffer), buffer_len(&buffer), 0, 0);
|
|
cipher_cleanup(&ciphercontext);
|
|
@@ -472,8 +478,13 @@ key_parse_private_rsa1(Buffer *blob, con
|
|
cp = buffer_append_space(&decrypted, buffer_len(©));
|
|
|
|
/* Rest of the buffer is encrypted. Decrypt it using the passphrase. */
|
|
- cipher_set_key_string(&ciphercontext, cipher, passphrase,
|
|
- CIPHER_DECRYPT);
|
|
+ if (cipher_set_key_string(&ciphercontext, cipher, passphrase,
|
|
+ CIPHER_DECRYPT) < 0) {
|
|
+ error("cipher_set_key_string failed.");
|
|
+ buffer_free(&decrypted);
|
|
+ goto fail;
|
|
+ }
|
|
+
|
|
cipher_crypt(&ciphercontext, cp,
|
|
buffer_ptr(©), buffer_len(©), 0, 0);
|
|
cipher_cleanup(&ciphercontext);
|
|
diff -up openssh-6.2p1/cipher.c.fips openssh-6.2p1/cipher.c
|
|
--- openssh-6.2p1/cipher.c.fips 2013-03-27 13:14:49.087683788 +0100
|
|
+++ openssh-6.2p1/cipher.c 2013-03-27 13:14:49.177683431 +0100
|
|
@@ -40,6 +40,7 @@
|
|
#include <sys/types.h>
|
|
|
|
#include <openssl/md5.h>
|
|
+#include <openssl/fips.h>
|
|
|
|
#include <string.h>
|
|
#include <stdarg.h>
|
|
@@ -89,6 +90,27 @@ struct Cipher ciphers[] = {
|
|
{ NULL, SSH_CIPHER_INVALID, 0, 0, 0, 0, 0, 0, NULL }
|
|
};
|
|
|
|
+struct Cipher fips_ciphers[] = {
|
|
+ { "none", SSH_CIPHER_NONE, 8, 0, 0, 0, 0, 0, EVP_enc_null },
|
|
+ { "3des", SSH_CIPHER_3DES, 8, 16, 0, 0, 0, 1, evp_ssh1_3des },
|
|
+
|
|
+ { "3des-cbc", SSH_CIPHER_SSH2, 8, 24, 0, 0, 0, 1, EVP_des_ede3_cbc },
|
|
+ { "aes128-cbc", SSH_CIPHER_SSH2, 16, 16, 0, 0, 0, 1, EVP_aes_128_cbc },
|
|
+ { "aes192-cbc", SSH_CIPHER_SSH2, 16, 24, 0, 0, 0, 1, EVP_aes_192_cbc },
|
|
+ { "aes256-cbc", SSH_CIPHER_SSH2, 16, 32, 0, 0, 0, 1, EVP_aes_256_cbc },
|
|
+ { "rijndael-cbc@lysator.liu.se",
|
|
+ SSH_CIPHER_SSH2, 16, 32, 0, 0, 0, 1, EVP_aes_256_cbc },
|
|
+ { "aes128-ctr", SSH_CIPHER_SSH2, 16, 16, 0, 0, 0, 0, EVP_aes_128_ctr },
|
|
+ { "aes192-ctr", SSH_CIPHER_SSH2, 16, 24, 0, 0, 0, 0, EVP_aes_128_ctr },
|
|
+ { "aes256-ctr", SSH_CIPHER_SSH2, 16, 32, 0, 0, 0, 0, EVP_aes_128_ctr },
|
|
+#ifdef OPENSSL_HAVE_EVPGCM
|
|
+ { "aes128-gcm@openssh.com",
|
|
+ SSH_CIPHER_SSH2, 16, 16, 12, 16, 0, 0, EVP_aes_128_gcm },
|
|
+ { "aes256-gcm@openssh.com",
|
|
+ SSH_CIPHER_SSH2, 16, 32, 12, 16, 0, 0, EVP_aes_256_gcm },
|
|
+#endif
|
|
+ { NULL, SSH_CIPHER_INVALID, 0, 0, 0, 0, 0, NULL }
|
|
+};
|
|
/*--*/
|
|
|
|
u_int
|
|
@@ -143,7 +165,7 @@ Cipher *
|
|
cipher_by_name(const char *name)
|
|
{
|
|
Cipher *c;
|
|
- for (c = ciphers; c->name != NULL; c++)
|
|
+ for (c = FIPS_mode() ? fips_ciphers : ciphers; c->name != NULL; c++)
|
|
if (strcmp(c->name, name) == 0)
|
|
return c;
|
|
return NULL;
|
|
@@ -153,7 +175,7 @@ Cipher *
|
|
cipher_by_number(int id)
|
|
{
|
|
Cipher *c;
|
|
- for (c = ciphers; c->name != NULL; c++)
|
|
+ for (c = FIPS_mode() ? fips_ciphers : ciphers; c->name != NULL; c++)
|
|
if (c->number == id)
|
|
return c;
|
|
return NULL;
|
|
@@ -197,7 +219,7 @@ cipher_number(const char *name)
|
|
Cipher *c;
|
|
if (name == NULL)
|
|
return -1;
|
|
- for (c = ciphers; c->name != NULL; c++)
|
|
+ for (c = FIPS_mode() ? fips_ciphers : ciphers; c->name != NULL; c++)
|
|
if (strcasecmp(c->name, name) == 0)
|
|
return c->number;
|
|
return -1;
|
|
@@ -356,14 +378,15 @@ cipher_cleanup(CipherContext *cc)
|
|
* passphrase and using the resulting 16 bytes as the key.
|
|
*/
|
|
|
|
-void
|
|
+int
|
|
cipher_set_key_string(CipherContext *cc, Cipher *cipher,
|
|
const char *passphrase, int do_encrypt)
|
|
{
|
|
MD5_CTX md;
|
|
u_char digest[16];
|
|
|
|
- MD5_Init(&md);
|
|
+ if (MD5_Init(&md) <= 0)
|
|
+ return -1;
|
|
MD5_Update(&md, (const u_char *)passphrase, strlen(passphrase));
|
|
MD5_Final(digest, &md);
|
|
|
|
@@ -371,6 +394,7 @@ cipher_set_key_string(CipherContext *cc,
|
|
|
|
memset(digest, 0, sizeof(digest));
|
|
memset(&md, 0, sizeof(md));
|
|
+ return 0;
|
|
}
|
|
|
|
/*
|
|
diff -up openssh-6.2p1/cipher-ctr.c.fips openssh-6.2p1/cipher-ctr.c
|
|
--- openssh-6.2p1/cipher-ctr.c.fips 2013-01-20 12:31:30.000000000 +0100
|
|
+++ openssh-6.2p1/cipher-ctr.c 2013-03-27 13:14:49.177683431 +0100
|
|
@@ -138,7 +138,8 @@ evp_aes_128_ctr(void)
|
|
aes_ctr.do_cipher = ssh_aes_ctr;
|
|
#ifndef SSH_OLD_EVP
|
|
aes_ctr.flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH |
|
|
- EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CUSTOM_IV;
|
|
+ EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CUSTOM_IV |
|
|
+ EVP_CIPH_FLAG_FIPS;
|
|
#endif
|
|
return (&aes_ctr);
|
|
}
|
|
diff -up openssh-6.2p1/cipher.h.fips openssh-6.2p1/cipher.h
|
|
--- openssh-6.2p1/cipher.h.fips 2013-03-27 13:14:49.088683784 +0100
|
|
+++ openssh-6.2p1/cipher.h 2013-03-27 13:14:49.177683431 +0100
|
|
@@ -91,7 +91,7 @@ void cipher_init(CipherContext *, Ciphe
|
|
void cipher_crypt(CipherContext *, u_char *, const u_char *,
|
|
u_int, u_int, u_int);
|
|
void cipher_cleanup(CipherContext *);
|
|
-void cipher_set_key_string(CipherContext *, Cipher *, const char *, int);
|
|
+int cipher_set_key_string(CipherContext *, Cipher *, const char *, int);
|
|
u_int cipher_blocksize(const Cipher *);
|
|
u_int cipher_keylen(const Cipher *);
|
|
u_int cipher_authlen(const Cipher *);
|
|
diff -up openssh-6.2p1/key.c.fips openssh-6.2p1/key.c
|
|
--- openssh-6.2p1/key.c.fips 2013-03-27 13:14:49.100683736 +0100
|
|
+++ openssh-6.2p1/key.c 2013-03-27 13:14:49.178683427 +0100
|
|
@@ -40,6 +40,7 @@
|
|
#include <sys/types.h>
|
|
|
|
#include <openssl/evp.h>
|
|
+#include <openssl/fips.h>
|
|
#include <openbsd-compat/openssl-compat.h>
|
|
|
|
#include <stdarg.h>
|
|
@@ -607,9 +608,13 @@ key_fingerprint_selection(void)
|
|
char *env;
|
|
|
|
if (!rv_defined) {
|
|
- env = getenv("SSH_FINGERPRINT_TYPE");
|
|
- rv = (env && !strcmp (env, "sha")) ?
|
|
- SSH_FP_SHA1 : SSH_FP_MD5;
|
|
+ if (FIPS_mode())
|
|
+ rv = SSH_FP_SHA1;
|
|
+ else {
|
|
+ env = getenv("SSH_FINGERPRINT_TYPE");
|
|
+ rv = (env && !strcmp (env, "sha")) ?
|
|
+ SSH_FP_SHA1 : SSH_FP_MD5;
|
|
+ }
|
|
rv_defined = 1;
|
|
}
|
|
return rv;
|
|
diff -up openssh-6.2p1/mac.c.fips openssh-6.2p1/mac.c
|
|
--- openssh-6.2p1/mac.c.fips 2013-03-27 13:14:49.093683764 +0100
|
|
+++ openssh-6.2p1/mac.c 2013-03-27 13:16:33.524266158 +0100
|
|
@@ -28,6 +28,7 @@
|
|
#include <sys/types.h>
|
|
|
|
#include <openssl/hmac.h>
|
|
+#include <openssl/fips.h>
|
|
|
|
#include <stdarg.h>
|
|
#include <string.h>
|
|
@@ -50,7 +51,7 @@
|
|
#define SSH_UMAC 2 /* UMAC (not integrated with OpenSSL) */
|
|
#define SSH_UMAC128 3
|
|
|
|
-struct {
|
|
+struct Macs {
|
|
char *name;
|
|
int type;
|
|
const EVP_MD * (*mdfunc)(void);
|
|
@@ -58,7 +59,9 @@ struct {
|
|
int key_len; /* just for UMAC */
|
|
int len; /* just for UMAC */
|
|
int etm; /* Encrypt-then-MAC */
|
|
-} macs[] = {
|
|
+};
|
|
+
|
|
+struct Macs all_macs[] = {
|
|
/* Encrypt-and-MAC (encrypt-and-authenticate) variants */
|
|
{ "hmac-sha1", SSH_EVP, EVP_sha1, 0, 0, 0, 0 },
|
|
{ "hmac-sha1-96", SSH_EVP, EVP_sha1, 96, 0, 0, 0 },
|
|
@@ -89,9 +92,19 @@ struct {
|
|
{ NULL, 0, NULL, 0, 0, 0, 0 }
|
|
};
|
|
|
|
+struct Macs fips_macs[] = {
|
|
+ { "hmac-sha1", SSH_EVP, EVP_sha1, 0, 0, 0, 0 },
|
|
+#ifdef HAVE_EVP_SHA256
|
|
+ { "hmac-sha2-256", SSH_EVP, EVP_sha256, 0, 0, 0, 0 },
|
|
+ { "hmac-sha2-512", SSH_EVP, EVP_sha512, 0, 0, 0, 0 },
|
|
+#endif
|
|
+ { NULL, 0, NULL, 0, -1, -1 }
|
|
+};
|
|
+
|
|
static void
|
|
mac_setup_by_id(Mac *mac, int which)
|
|
{
|
|
+ struct Macs *macs = FIPS_mode() ? fips_macs : all_macs;
|
|
int evp_len;
|
|
mac->type = macs[which].type;
|
|
if (mac->type == SSH_EVP) {
|
|
@@ -113,6 +126,7 @@ int
|
|
mac_setup(Mac *mac, char *name)
|
|
{
|
|
int i;
|
|
+ struct Macs *macs = FIPS_mode() ? fips_macs : all_macs;
|
|
|
|
for (i = 0; macs[i].name; i++) {
|
|
if (strcmp(name, macs[i].name) == 0) {
|
|
diff -up openssh-6.2p1/Makefile.in.fips openssh-6.2p1/Makefile.in
|
|
--- openssh-6.2p1/Makefile.in.fips 2013-03-27 13:14:49.155683518 +0100
|
|
+++ openssh-6.2p1/Makefile.in 2013-03-27 13:14:49.178683427 +0100
|
|
@@ -145,25 +145,25 @@ libssh.a: $(LIBSSH_OBJS)
|
|
$(RANLIB) $@
|
|
|
|
ssh$(EXEEXT): $(LIBCOMPAT) libssh.a $(SSHOBJS)
|
|
- $(LD) -o $@ $(SSHOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(SSHLIBS) $(LIBS) $(GSSLIBS)
|
|
+ $(LD) -o $@ $(SSHOBJS) $(LDFLAGS) -lssh -lopenbsd-compat -lfipscheck $(SSHLIBS) $(LIBS) $(GSSLIBS)
|
|
|
|
sshd$(EXEEXT): libssh.a $(LIBCOMPAT) $(SSHDOBJS)
|
|
- $(LD) -o $@ $(SSHDOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(SSHDLIBS) $(LIBS) $(GSSLIBS) $(K5LIBS)
|
|
+ $(LD) -o $@ $(SSHDOBJS) $(LDFLAGS) -lssh -lopenbsd-compat -lfipscheck $(SSHDLIBS) $(LIBS) $(GSSLIBS) $(K5LIBS)
|
|
|
|
scp$(EXEEXT): $(LIBCOMPAT) libssh.a scp.o progressmeter.o
|
|
$(LD) -o $@ scp.o progressmeter.o bufaux.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
|
|
|
|
ssh-add$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-add.o
|
|
- $(LD) -o $@ ssh-add.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
|
|
+ $(LD) -o $@ ssh-add.o $(LDFLAGS) -lssh -lopenbsd-compat -lfipscheck $(LIBS)
|
|
|
|
ssh-agent$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-agent.o ssh-pkcs11-client.o
|
|
- $(LD) -o $@ ssh-agent.o ssh-pkcs11-client.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
|
|
+ $(LD) -o $@ ssh-agent.o ssh-pkcs11-client.o $(LDFLAGS) -lssh -lopenbsd-compat -lfipscheck $(LIBS)
|
|
|
|
ssh-keygen$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keygen.o
|
|
- $(LD) -o $@ ssh-keygen.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
|
|
+ $(LD) -o $@ ssh-keygen.o $(LDFLAGS) -lssh -lopenbsd-compat -lfipscheck $(LIBS)
|
|
|
|
ssh-keysign$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keysign.o roaming_dummy.o readconf.o
|
|
- $(LD) -o $@ ssh-keysign.o readconf.o roaming_dummy.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
|
|
+ $(LD) -o $@ ssh-keysign.o readconf.o roaming_dummy.o $(LDFLAGS) -lssh -lopenbsd-compat -lfipscheck $(LIBS)
|
|
|
|
ssh-pkcs11-helper$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-pkcs11-helper.o ssh-pkcs11.o
|
|
$(LD) -o $@ ssh-pkcs11-helper.o ssh-pkcs11.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
|
|
@@ -175,7 +175,7 @@ ssh-keycat$(EXEEXT): $(LIBCOMPAT) libssh
|
|
$(LD) -o $@ ssh-keycat.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh -lfipscheck $(SSHDLIBS)
|
|
|
|
ssh-keyscan$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keyscan.o roaming_dummy.o
|
|
- $(LD) -o $@ ssh-keyscan.o roaming_dummy.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh $(LIBS)
|
|
+ $(LD) -o $@ ssh-keyscan.o roaming_dummy.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh -lfipscheck $(LIBS)
|
|
|
|
sftp-server$(EXEEXT): $(LIBCOMPAT) libssh.a sftp.o sftp-common.o sftp-server.o sftp-server-main.o
|
|
$(LD) -o $@ sftp-server.o sftp-common.o sftp-server-main.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
|
|
diff -up openssh-6.2p1/myproposal.h.fips openssh-6.2p1/myproposal.h
|
|
--- openssh-6.2p1/myproposal.h.fips 2013-01-09 06:12:19.000000000 +0100
|
|
+++ openssh-6.2p1/myproposal.h 2013-03-27 13:14:49.178683427 +0100
|
|
@@ -106,6 +106,19 @@
|
|
#define KEX_DEFAULT_COMP "none,zlib@openssh.com,zlib"
|
|
#define KEX_DEFAULT_LANG ""
|
|
|
|
+#define KEX_FIPS_ENCRYPT \
|
|
+ "aes128-ctr,aes192-ctr,aes256-ctr," \
|
|
+ "aes128-cbc,3des-cbc," \
|
|
+ "aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se"
|
|
+#ifdef HAVE_EVP_SHA256
|
|
+#define KEX_FIPS_MAC \
|
|
+ "hmac-sha1," \
|
|
+ "hmac-sha2-256," \
|
|
+ "hmac-sha2-512"
|
|
+#else
|
|
+#define KEX_FIPS_MAC \
|
|
+ "hmac-sha1"
|
|
+#endif
|
|
|
|
static char *myproposal[PROPOSAL_MAX] = {
|
|
KEX_DEFAULT_KEX,
|
|
diff -up openssh-6.2p1/openbsd-compat/bsd-arc4random.c.fips openssh-6.2p1/openbsd-compat/bsd-arc4random.c
|
|
--- openssh-6.2p1/openbsd-compat/bsd-arc4random.c.fips 2010-03-25 22:52:02.000000000 +0100
|
|
+++ openssh-6.2p1/openbsd-compat/bsd-arc4random.c 2013-03-27 13:14:49.179683423 +0100
|
|
@@ -37,25 +37,18 @@
|
|
#define REKEY_BYTES (1 << 24)
|
|
|
|
static int rc4_ready = 0;
|
|
-static RC4_KEY rc4;
|
|
|
|
unsigned int
|
|
arc4random(void)
|
|
{
|
|
unsigned int r = 0;
|
|
- static int first_time = 1;
|
|
+ void *rp = &r;
|
|
|
|
- if (rc4_ready <= 0) {
|
|
- if (first_time)
|
|
- seed_rng();
|
|
- first_time = 0;
|
|
+ if (!rc4_ready) {
|
|
arc4random_stir();
|
|
}
|
|
+ RAND_bytes(rp, sizeof(r));
|
|
|
|
- RC4(&rc4, sizeof(r), (unsigned char *)&r, (unsigned char *)&r);
|
|
-
|
|
- rc4_ready -= sizeof(r);
|
|
-
|
|
return(r);
|
|
}
|
|
|
|
@@ -63,24 +56,11 @@ void
|
|
arc4random_stir(void)
|
|
{
|
|
unsigned char rand_buf[SEED_SIZE];
|
|
- int i;
|
|
|
|
- memset(&rc4, 0, sizeof(rc4));
|
|
if (RAND_bytes(rand_buf, sizeof(rand_buf)) <= 0)
|
|
fatal("Couldn't obtain random bytes (error %ld)",
|
|
ERR_get_error());
|
|
- RC4_set_key(&rc4, sizeof(rand_buf), rand_buf);
|
|
-
|
|
- /*
|
|
- * Discard early keystream, as per recommendations in:
|
|
- * http://www.wisdom.weizmann.ac.il/~itsik/RC4/Papers/Rc4_ksa.ps
|
|
- */
|
|
- for(i = 0; i <= 256; i += sizeof(rand_buf))
|
|
- RC4(&rc4, sizeof(rand_buf), rand_buf, rand_buf);
|
|
-
|
|
- memset(rand_buf, 0, sizeof(rand_buf));
|
|
-
|
|
- rc4_ready = REKEY_BYTES;
|
|
+ rc4_ready = 1;
|
|
}
|
|
#endif /* !HAVE_ARC4RANDOM */
|
|
|
|
diff -up openssh-6.2p2/ssh.c.fips openssh-6.2p2/ssh.c
|
|
--- openssh-6.2p2/ssh.c.fips 2013-04-05 02:22:36.000000000 +0200
|
|
+++ openssh-6.2p2/ssh.c 2013-10-08 17:21:26.894761211 +0200
|
|
@@ -73,6 +73,8 @@
|
|
|
|
#include <openssl/evp.h>
|
|
#include <openssl/err.h>
|
|
+#include <openssl/fips.h>
|
|
+#include <fipscheck.h>
|
|
#include "openbsd-compat/openssl-compat.h"
|
|
#include "openbsd-compat/sys-queue.h"
|
|
|
|
@@ -253,6 +255,13 @@ main(int ac, char **av)
|
|
sanitise_stdfd();
|
|
|
|
__progname = ssh_get_progname(av[0]);
|
|
+ SSLeay_add_all_algorithms();
|
|
+ if (access("/etc/system-fips", F_OK) == 0)
|
|
+ if (! FIPSCHECK_verify(NULL, NULL))
|
|
+ if (FIPS_mode())
|
|
+ fatal("FIPS integrity verification test failed.");
|
|
+ else
|
|
+ logit("FIPS integrity verification test failed.");
|
|
|
|
#ifndef HAVE_SETPROCTITLE
|
|
/* Prepare for later setproctitle emulation */
|
|
@@ -329,6 +338,9 @@ main(int ac, char **av)
|
|
"ACD:F:I:KL:MNO:PR:S:TVw:W:XYy")) != -1) {
|
|
switch (opt) {
|
|
case '1':
|
|
+ if (FIPS_mode()) {
|
|
+ fatal("Protocol 1 not allowed in the FIPS mode.");
|
|
+ }
|
|
options.protocol = SSH_PROTO_1;
|
|
break;
|
|
case '2':
|
|
@@ -628,7 +640,6 @@ main(int ac, char **av)
|
|
if (!host)
|
|
usage();
|
|
|
|
- OpenSSL_add_all_algorithms();
|
|
ERR_load_crypto_strings();
|
|
|
|
/* Initialize the command to execute on remote host. */
|
|
@@ -719,6 +730,10 @@ main(int ac, char **av)
|
|
|
|
seed_rng();
|
|
|
|
+ if (FIPS_mode()) {
|
|
+ logit("FIPS mode initialized");
|
|
+ }
|
|
+
|
|
if (options.user == NULL)
|
|
options.user = xstrdup(pw->pw_name);
|
|
|
|
@@ -787,6 +802,12 @@ main(int ac, char **av)
|
|
|
|
timeout_ms = options.connection_timeout * 1000;
|
|
|
|
+ if (FIPS_mode()) {
|
|
+ options.protocol &= SSH_PROTO_2;
|
|
+ if (options.protocol == 0)
|
|
+ fatal("Protocol 2 disabled by configuration but required in the FIPS mode.");
|
|
+ }
|
|
+
|
|
/* Open a connection to the remote host. */
|
|
if (ssh_connect(host, &hostaddr, options.port,
|
|
options.address_family, options.connection_attempts, &timeout_ms,
|
|
diff -up openssh-6.2p1/sshconnect2.c.fips openssh-6.2p1/sshconnect2.c
|
|
--- openssh-6.2p1/sshconnect2.c.fips 2013-03-27 13:14:49.066683871 +0100
|
|
+++ openssh-6.2p1/sshconnect2.c 2013-03-27 13:14:49.179683423 +0100
|
|
@@ -44,6 +44,8 @@
|
|
#include <vis.h>
|
|
#endif
|
|
|
|
+#include <openssl/fips.h>
|
|
+
|
|
#include "openbsd-compat/sys-queue.h"
|
|
|
|
#include "xmalloc.h"
|
|
@@ -170,6 +172,10 @@ ssh_kex2(char *host, struct sockaddr *ho
|
|
if (options.ciphers != NULL) {
|
|
myproposal[PROPOSAL_ENC_ALGS_CTOS] =
|
|
myproposal[PROPOSAL_ENC_ALGS_STOC] = options.ciphers;
|
|
+ } else if (FIPS_mode()) {
|
|
+ myproposal[PROPOSAL_ENC_ALGS_CTOS] =
|
|
+ myproposal[PROPOSAL_ENC_ALGS_STOC] = KEX_FIPS_ENCRYPT;
|
|
+
|
|
}
|
|
myproposal[PROPOSAL_ENC_ALGS_CTOS] =
|
|
compat_cipher_proposal(myproposal[PROPOSAL_ENC_ALGS_CTOS]);
|
|
@@ -185,7 +191,11 @@ ssh_kex2(char *host, struct sockaddr *ho
|
|
if (options.macs != NULL) {
|
|
myproposal[PROPOSAL_MAC_ALGS_CTOS] =
|
|
myproposal[PROPOSAL_MAC_ALGS_STOC] = options.macs;
|
|
+ } else if (FIPS_mode()) {
|
|
+ myproposal[PROPOSAL_MAC_ALGS_CTOS] =
|
|
+ myproposal[PROPOSAL_MAC_ALGS_STOC] = KEX_FIPS_MAC;
|
|
}
|
|
+
|
|
if (options.hostkeyalgorithms != NULL)
|
|
myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] =
|
|
options.hostkeyalgorithms;
|
|
diff -up openssh-6.2p2/sshd.c.fips openssh-6.2p2/sshd.c
|
|
--- openssh-6.2p2/sshd.c.fips 2013-10-08 17:14:05.455864248 +0200
|
|
+++ openssh-6.2p2/sshd.c 2013-10-08 17:22:15.897527827 +0200
|
|
@@ -76,6 +76,8 @@
|
|
#include <openssl/bn.h>
|
|
#include <openssl/md5.h>
|
|
#include <openssl/rand.h>
|
|
+#include <openssl/fips.h>
|
|
+#include <fipscheck.h>
|
|
#include "openbsd-compat/openssl-compat.h"
|
|
|
|
#ifdef HAVE_SECUREWARE
|
|
@@ -1423,6 +1425,14 @@ main(int ac, char **av)
|
|
#endif
|
|
__progname = ssh_get_progname(av[0]);
|
|
|
|
+ SSLeay_add_all_algorithms();
|
|
+ if (access("/etc/system-fips", F_OK) == 0)
|
|
+ if (! FIPSCHECK_verify(NULL, NULL))
|
|
+ if (FIPS_mode())
|
|
+ fatal("FIPS integrity verification test failed.");
|
|
+ else
|
|
+ logit("FIPS integrity verification test failed.");
|
|
+
|
|
/* Save argv. Duplicate so setproctitle emulation doesn't clobber it */
|
|
saved_argc = ac;
|
|
rexec_argc = ac;
|
|
@@ -1571,8 +1581,6 @@ main(int ac, char **av)
|
|
else
|
|
closefrom(REEXEC_DEVCRYPTO_RESERVED_FD);
|
|
|
|
- OpenSSL_add_all_algorithms();
|
|
-
|
|
/*
|
|
* Force logging to stderr until we have loaded the private host
|
|
* key (unless started from inetd)
|
|
@@ -1715,6 +1723,10 @@ main(int ac, char **av)
|
|
debug("private host key: #%d type %d %s", i, key->type,
|
|
key_type(key));
|
|
}
|
|
+ if ((options.protocol & SSH_PROTO_1) && FIPS_mode()) {
|
|
+ logit("Disabling protocol version 1. Not allowed in the FIPS mode.");
|
|
+ options.protocol &= ~SSH_PROTO_1;
|
|
+ }
|
|
if ((options.protocol & SSH_PROTO_1) && !sensitive_data.have_ssh1_key) {
|
|
logit("Disabling protocol version 1. Could not load host key");
|
|
options.protocol &= ~SSH_PROTO_1;
|
|
@@ -1878,6 +1890,10 @@ main(int ac, char **av)
|
|
/* Initialize the random number generator. */
|
|
arc4random_stir();
|
|
|
|
+ if (FIPS_mode()) {
|
|
+ logit("FIPS mode initialized");
|
|
+ }
|
|
+
|
|
/* Chdir to the root directory so that the current disk can be
|
|
unmounted if desired. */
|
|
(void) chdir("/");
|
|
@@ -2420,6 +2436,9 @@ do_ssh2_kex(void)
|
|
if (options.ciphers != NULL) {
|
|
myproposal[PROPOSAL_ENC_ALGS_CTOS] =
|
|
myproposal[PROPOSAL_ENC_ALGS_STOC] = options.ciphers;
|
|
+ } else if (FIPS_mode()) {
|
|
+ myproposal[PROPOSAL_ENC_ALGS_CTOS] =
|
|
+ myproposal[PROPOSAL_ENC_ALGS_STOC] = KEX_FIPS_ENCRYPT;
|
|
}
|
|
myproposal[PROPOSAL_ENC_ALGS_CTOS] =
|
|
compat_cipher_proposal(myproposal[PROPOSAL_ENC_ALGS_CTOS]);
|
|
@@ -2429,6 +2448,9 @@ do_ssh2_kex(void)
|
|
if (options.macs != NULL) {
|
|
myproposal[PROPOSAL_MAC_ALGS_CTOS] =
|
|
myproposal[PROPOSAL_MAC_ALGS_STOC] = options.macs;
|
|
+ } else if (FIPS_mode()) {
|
|
+ myproposal[PROPOSAL_MAC_ALGS_CTOS] =
|
|
+ myproposal[PROPOSAL_MAC_ALGS_STOC] = KEX_FIPS_MAC;
|
|
}
|
|
if (options.compression == COMP_NONE) {
|
|
myproposal[PROPOSAL_COMP_ALGS_CTOS] =
|