|
Petr Lautrbach |
84822b |
diff -up openssh-6.3p1/Makefile.in.fips openssh-6.3p1/Makefile.in
|
|
Petr Lautrbach |
84822b |
--- openssh-6.3p1/Makefile.in.fips 2013-10-11 22:24:32.850031186 +0200
|
|
Petr Lautrbach |
84822b |
+++ openssh-6.3p1/Makefile.in 2013-10-11 22:24:32.870031092 +0200
|
|
Petr Lautrbach |
84822b |
@@ -147,25 +147,25 @@ libssh.a: $(LIBSSH_OBJS)
|
|
Petr Lautrbach |
84822b |
$(RANLIB) $@
|
|
Petr Lautrbach |
84822b |
|
|
Petr Lautrbach |
84822b |
ssh$(EXEEXT): $(LIBCOMPAT) libssh.a $(SSHOBJS)
|
|
Petr Lautrbach |
84822b |
- $(LD) -o $@ $(SSHOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(SSHLIBS) $(LIBS) $(GSSLIBS)
|
|
Petr Lautrbach |
84822b |
+ $(LD) -o $@ $(SSHOBJS) $(LDFLAGS) -lssh -lopenbsd-compat -lfipscheck $(SSHLIBS) $(LIBS) $(GSSLIBS)
|
|
Petr Lautrbach |
84822b |
|
|
Petr Lautrbach |
84822b |
sshd$(EXEEXT): libssh.a $(LIBCOMPAT) $(SSHDOBJS)
|
|
Petr Lautrbach |
84822b |
- $(LD) -o $@ $(SSHDOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(SSHDLIBS) $(LIBS) $(GSSLIBS) $(K5LIBS)
|
|
Petr Lautrbach |
84822b |
+ $(LD) -o $@ $(SSHDOBJS) $(LDFLAGS) -lssh -lopenbsd-compat -lfipscheck $(SSHDLIBS) $(LIBS) $(GSSLIBS) $(K5LIBS)
|
|
Petr Lautrbach |
84822b |
|
|
Petr Lautrbach |
84822b |
scp$(EXEEXT): $(LIBCOMPAT) libssh.a scp.o progressmeter.o
|
|
Petr Lautrbach |
84822b |
$(LD) -o $@ scp.o progressmeter.o bufaux.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
|
|
Petr Lautrbach |
84822b |
|
|
Petr Lautrbach |
84822b |
ssh-add$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-add.o
|
|
Petr Lautrbach |
84822b |
- $(LD) -o $@ ssh-add.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
|
|
Petr Lautrbach |
84822b |
+ $(LD) -o $@ ssh-add.o $(LDFLAGS) -lssh -lopenbsd-compat -lfipscheck $(LIBS)
|
|
Petr Lautrbach |
84822b |
|
|
Petr Lautrbach |
84822b |
ssh-agent$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-agent.o ssh-pkcs11-client.o
|
|
Petr Lautrbach |
84822b |
- $(LD) -o $@ ssh-agent.o ssh-pkcs11-client.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
|
|
Petr Lautrbach |
84822b |
+ $(LD) -o $@ ssh-agent.o ssh-pkcs11-client.o $(LDFLAGS) -lssh -lopenbsd-compat -lfipscheck $(LIBS)
|
|
Petr Lautrbach |
84822b |
|
|
Petr Lautrbach |
84822b |
ssh-keygen$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keygen.o
|
|
Petr Lautrbach |
84822b |
- $(LD) -o $@ ssh-keygen.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
|
|
Petr Lautrbach |
84822b |
+ $(LD) -o $@ ssh-keygen.o $(LDFLAGS) -lssh -lopenbsd-compat -lfipscheck $(LIBS)
|
|
Petr Lautrbach |
84822b |
|
|
Petr Lautrbach |
84822b |
ssh-keysign$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keysign.o roaming_dummy.o readconf.o
|
|
Petr Lautrbach |
84822b |
- $(LD) -o $@ ssh-keysign.o readconf.o roaming_dummy.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
|
|
Petr Lautrbach |
84822b |
+ $(LD) -o $@ ssh-keysign.o readconf.o roaming_dummy.o $(LDFLAGS) -lssh -lopenbsd-compat -lfipscheck $(LIBS)
|
|
Petr Lautrbach |
84822b |
|
|
Petr Lautrbach |
84822b |
ssh-pkcs11-helper$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-pkcs11-helper.o ssh-pkcs11.o
|
|
Petr Lautrbach |
84822b |
$(LD) -o $@ ssh-pkcs11-helper.o ssh-pkcs11.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
|
|
Petr Lautrbach |
84822b |
@@ -177,7 +177,7 @@ ssh-keycat$(EXEEXT): $(LIBCOMPAT) libssh
|
|
Petr Lautrbach |
84822b |
$(LD) -o $@ ssh-keycat.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh -lfipscheck $(SSHDLIBS)
|
|
Petr Lautrbach |
84822b |
|
|
Petr Lautrbach |
84822b |
ssh-keyscan$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keyscan.o roaming_dummy.o
|
|
Petr Lautrbach |
84822b |
- $(LD) -o $@ ssh-keyscan.o roaming_dummy.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh $(LIBS)
|
|
Petr Lautrbach |
84822b |
+ $(LD) -o $@ ssh-keyscan.o roaming_dummy.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh -lfipscheck $(LIBS)
|
|
Petr Lautrbach |
84822b |
|
|
Petr Lautrbach |
84822b |
sftp-server$(EXEEXT): $(LIBCOMPAT) libssh.a sftp.o sftp-common.o sftp-server.o sftp-server-main.o
|
|
Petr Lautrbach |
84822b |
$(LD) -o $@ sftp-server.o sftp-common.o sftp-server-main.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
|
|
Petr Lautrbach |
84822b |
diff -up openssh-6.3p1/authfile.c.fips openssh-6.3p1/authfile.c
|
|
Petr Lautrbach |
84822b |
--- openssh-6.3p1/authfile.c.fips 2013-10-11 22:24:32.857031153 +0200
|
|
Petr Lautrbach |
84822b |
+++ openssh-6.3p1/authfile.c 2013-10-11 22:24:32.870031092 +0200
|
|
Jan F. Chadima |
69dd72 |
@@ -148,8 +148,14 @@ key_private_rsa1_to_blob(Key *key, Buffe
|
|
Jan F. Chadima |
69dd72 |
/* Allocate space for the private part of the key in the buffer. */
|
|
Jan F. Chadima |
69dd72 |
cp = buffer_append_space(&encrypted, buffer_len(&buffer));
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
- cipher_set_key_string(&ciphercontext, cipher, passphrase,
|
|
Jan F. Chadima |
69dd72 |
- CIPHER_ENCRYPT);
|
|
Jan F. Chadima |
69dd72 |
+ if (cipher_set_key_string(&ciphercontext, cipher, passphrase,
|
|
Jan F. Chadima |
69dd72 |
+ CIPHER_ENCRYPT) < 0) {
|
|
Petr Lautrbach |
8a29de |
+ error("cipher_set_key_string failed.");
|
|
Petr Lautrbach |
8a29de |
+ buffer_free(&encrypted);
|
|
Petr Lautrbach |
8a29de |
+ buffer_free(&buffer);
|
|
Petr Lautrbach |
8a29de |
+ return 0;
|
|
Jan F. Chadima |
69dd72 |
+ }
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
cipher_crypt(&ciphercontext, cp,
|
|
Petr Lautrbach |
8a29de |
buffer_ptr(&buffer), buffer_len(&buffer), 0, 0);
|
|
Jan F. Chadima |
69dd72 |
cipher_cleanup(&ciphercontext);
|
|
Jan F. Chadima |
69dd72 |
@@ -472,8 +478,13 @@ key_parse_private_rsa1(Buffer *blob, con
|
|
Jan F. Chadima |
69dd72 |
cp = buffer_append_space(&decrypted, buffer_len(©);;
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
/* Rest of the buffer is encrypted. Decrypt it using the passphrase. */
|
|
Jan F. Chadima |
69dd72 |
- cipher_set_key_string(&ciphercontext, cipher, passphrase,
|
|
Jan F. Chadima |
69dd72 |
- CIPHER_DECRYPT);
|
|
Jan F. Chadima |
69dd72 |
+ if (cipher_set_key_string(&ciphercontext, cipher, passphrase,
|
|
Jan F. Chadima |
69dd72 |
+ CIPHER_DECRYPT) < 0) {
|
|
Petr Lautrbach |
8a29de |
+ error("cipher_set_key_string failed.");
|
|
Petr Lautrbach |
8a29de |
+ buffer_free(&decrypted);
|
|
Petr Lautrbach |
8a29de |
+ goto fail;
|
|
Jan F. Chadima |
69dd72 |
+ }
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
cipher_crypt(&ciphercontext, cp,
|
|
Petr Lautrbach |
8a29de |
buffer_ptr(©), buffer_len(©), 0, 0);
|
|
Jan F. Chadima |
69dd72 |
cipher_cleanup(&ciphercontext);
|
|
Petr Lautrbach |
84822b |
diff -up openssh-6.3p1/cipher-ctr.c.fips openssh-6.3p1/cipher-ctr.c
|
|
Petr Lautrbach |
84822b |
--- openssh-6.3p1/cipher-ctr.c.fips 2013-06-02 00:07:32.000000000 +0200
|
|
Petr Lautrbach |
84822b |
+++ openssh-6.3p1/cipher-ctr.c 2013-10-11 22:24:32.870031092 +0200
|
|
Petr Lautrbach |
84822b |
@@ -138,7 +138,8 @@ evp_aes_128_ctr(void)
|
|
Petr Lautrbach |
84822b |
aes_ctr.do_cipher = ssh_aes_ctr;
|
|
Petr Lautrbach |
84822b |
#ifndef SSH_OLD_EVP
|
|
Petr Lautrbach |
84822b |
aes_ctr.flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH |
|
|
Petr Lautrbach |
84822b |
- EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CUSTOM_IV;
|
|
Petr Lautrbach |
84822b |
+ EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CUSTOM_IV |
|
|
Petr Lautrbach |
84822b |
+ EVP_CIPH_FLAG_FIPS;
|
|
Petr Lautrbach |
84822b |
#endif
|
|
Petr Lautrbach |
84822b |
return (&aes_ctr);
|
|
Petr Lautrbach |
84822b |
}
|
|
Petr Lautrbach |
84822b |
diff -up openssh-6.3p1/cipher.c.fips openssh-6.3p1/cipher.c
|
|
Petr Lautrbach |
84822b |
--- openssh-6.3p1/cipher.c.fips 2013-10-11 22:24:32.820031327 +0200
|
|
Petr Lautrbach |
84822b |
+++ openssh-6.3p1/cipher.c 2013-10-11 22:24:32.871031087 +0200
|
|
Jan F. Chadima |
69dd72 |
@@ -40,6 +40,7 @@
|
|
Jan F. Chadima |
69dd72 |
#include <sys/types.h>
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
#include <openssl/md5.h>
|
|
Jan F. Chadima |
69dd72 |
+#include <openssl/fips.h>
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
#include <string.h>
|
|
Jan F. Chadima |
69dd72 |
#include <stdarg.h>
|
|
Petr Lautrbach |
84822b |
@@ -86,6 +87,27 @@ static const struct Cipher ciphers[] = {
|
|
Petr Lautrbach |
8a29de |
{ NULL, SSH_CIPHER_INVALID, 0, 0, 0, 0, 0, 0, NULL }
|
|
Jan F. Chadima |
69dd72 |
};
|
|
Jan F. Chadima |
69dd72 |
|
|
Petr Lautrbach |
84822b |
+static const struct Cipher fips_ciphers[] = {
|
|
Petr Lautrbach |
84822b |
+ { "none", SSH_CIPHER_NONE, 8, 0, 0, 0, 0, 0, EVP_enc_null },
|
|
Petr Lautrbach |
84822b |
+ { "des", SSH_CIPHER_DES, 8, 8, 0, 0, 0, 1, EVP_des_cbc },
|
|
Petr Lautrbach |
84822b |
+ { "3des", SSH_CIPHER_3DES, 8, 16, 0, 0, 0, 1, evp_ssh1_3des },
|
|
Petr Lautrbach |
84822b |
+ { "3des-cbc", SSH_CIPHER_SSH2, 8, 24, 0, 0, 0, 1, EVP_des_ede3_cbc },
|
|
Petr Lautrbach |
84822b |
+ { "aes128-cbc", SSH_CIPHER_SSH2, 16, 16, 0, 0, 0, 1, EVP_aes_128_cbc },
|
|
Petr Lautrbach |
84822b |
+ { "aes192-cbc", SSH_CIPHER_SSH2, 16, 24, 0, 0, 0, 1, EVP_aes_192_cbc },
|
|
Petr Lautrbach |
84822b |
+ { "aes256-cbc", SSH_CIPHER_SSH2, 16, 32, 0, 0, 0, 1, EVP_aes_256_cbc },
|
|
Jan F. Chadima |
69dd72 |
+ { "rijndael-cbc@lysator.liu.se",
|
|
Petr Lautrbach |
84822b |
+ SSH_CIPHER_SSH2, 16, 32, 0, 0, 0, 1, EVP_aes_256_cbc },
|
|
Petr Lautrbach |
84822b |
+ { "aes128-ctr", SSH_CIPHER_SSH2, 16, 16, 0, 0, 0, 0, EVP_aes_128_ctr },
|
|
Petr Lautrbach |
84822b |
+ { "aes192-ctr", SSH_CIPHER_SSH2, 16, 24, 0, 0, 0, 0, EVP_aes_192_ctr },
|
|
Petr Lautrbach |
84822b |
+ { "aes256-ctr", SSH_CIPHER_SSH2, 16, 32, 0, 0, 0, 0, EVP_aes_256_ctr },
|
|
Petr Lautrbach |
8a29de |
+#ifdef OPENSSL_HAVE_EVPGCM
|
|
Petr Lautrbach |
8a29de |
+ { "aes128-gcm@openssh.com",
|
|
Petr Lautrbach |
8a29de |
+ SSH_CIPHER_SSH2, 16, 16, 12, 16, 0, 0, EVP_aes_128_gcm },
|
|
Petr Lautrbach |
8a29de |
+ { "aes256-gcm@openssh.com",
|
|
Petr Lautrbach |
8a29de |
+ SSH_CIPHER_SSH2, 16, 32, 12, 16, 0, 0, EVP_aes_256_gcm },
|
|
Petr Lautrbach |
8a29de |
+#endif
|
|
Petr Lautrbach |
84822b |
+ { NULL, SSH_CIPHER_INVALID, 0, 0, 0, 0, 0, 0, NULL }
|
|
Jan F. Chadima |
69dd72 |
+};
|
|
Jan F. Chadima |
69dd72 |
/*--*/
|
|
Jan F. Chadima |
69dd72 |
|
|
Petr Lautrbach |
84822b |
/* Returns a comma-separated list of supported ciphers. */
|
|
Petr Lautrbach |
84822b |
@@ -96,7 +118,7 @@ cipher_alg_list(void)
|
|
Petr Lautrbach |
84822b |
size_t nlen, rlen = 0;
|
|
Petr Lautrbach |
84822b |
const Cipher *c;
|
|
Petr Lautrbach |
84822b |
|
|
Petr Lautrbach |
84822b |
- for (c = ciphers; c->name != NULL; c++) {
|
|
Petr Lautrbach |
84822b |
+ for (c = FIPS_mode() ? fips_ciphers : ciphers; c->name != NULL; c++) {
|
|
Petr Lautrbach |
84822b |
if (c->number != SSH_CIPHER_SSH2)
|
|
Petr Lautrbach |
84822b |
continue;
|
|
Petr Lautrbach |
84822b |
if (ret != NULL)
|
|
Petr Lautrbach |
84822b |
@@ -161,7 +183,7 @@ const Cipher *
|
|
Jan F. Chadima |
69dd72 |
cipher_by_name(const char *name)
|
|
Jan F. Chadima |
69dd72 |
{
|
|
Petr Lautrbach |
84822b |
const Cipher *c;
|
|
Jan F. Chadima |
69dd72 |
- for (c = ciphers; c->name != NULL; c++)
|
|
Jan F. Chadima |
69dd72 |
+ for (c = FIPS_mode() ? fips_ciphers : ciphers; c->name != NULL; c++)
|
|
Jan F. Chadima |
69dd72 |
if (strcmp(c->name, name) == 0)
|
|
Jan F. Chadima |
69dd72 |
return c;
|
|
Jan F. Chadima |
69dd72 |
return NULL;
|
|
Petr Lautrbach |
84822b |
@@ -171,7 +193,7 @@ const Cipher *
|
|
Jan F. Chadima |
69dd72 |
cipher_by_number(int id)
|
|
Jan F. Chadima |
69dd72 |
{
|
|
Petr Lautrbach |
84822b |
const Cipher *c;
|
|
Jan F. Chadima |
69dd72 |
- for (c = ciphers; c->name != NULL; c++)
|
|
Jan F. Chadima |
69dd72 |
+ for (c = FIPS_mode() ? fips_ciphers : ciphers; c->name != NULL; c++)
|
|
Jan F. Chadima |
69dd72 |
if (c->number == id)
|
|
Jan F. Chadima |
69dd72 |
return c;
|
|
Jan F. Chadima |
69dd72 |
return NULL;
|
|
Petr Lautrbach |
84822b |
@@ -215,7 +237,7 @@ cipher_number(const char *name)
|
|
Petr Lautrbach |
84822b |
const Cipher *c;
|
|
Jan F. Chadima |
69dd72 |
if (name == NULL)
|
|
Jan F. Chadima |
69dd72 |
return -1;
|
|
Jan F. Chadima |
69dd72 |
- for (c = ciphers; c->name != NULL; c++)
|
|
Jan F. Chadima |
69dd72 |
+ for (c = FIPS_mode() ? fips_ciphers : ciphers; c->name != NULL; c++)
|
|
Jan F. Chadima |
69dd72 |
if (strcasecmp(c->name, name) == 0)
|
|
Jan F. Chadima |
69dd72 |
return c->number;
|
|
Jan F. Chadima |
69dd72 |
return -1;
|
|
Petr Lautrbach |
84822b |
@@ -374,14 +396,15 @@ cipher_cleanup(CipherContext *cc)
|
|
Jan F. Chadima |
69dd72 |
* passphrase and using the resulting 16 bytes as the key.
|
|
Jan F. Chadima |
69dd72 |
*/
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
-void
|
|
Jan F. Chadima |
69dd72 |
+int
|
|
Petr Lautrbach |
84822b |
cipher_set_key_string(CipherContext *cc, const Cipher *cipher,
|
|
Jan F. Chadima |
69dd72 |
const char *passphrase, int do_encrypt)
|
|
Jan F. Chadima |
69dd72 |
{
|
|
Jan F. Chadima |
69dd72 |
MD5_CTX md;
|
|
Jan F. Chadima |
69dd72 |
u_char digest[16];
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
- MD5_Init(&md);
|
|
Jan F. Chadima |
69dd72 |
+ if (MD5_Init(&md) <= 0)
|
|
Jan F. Chadima |
69dd72 |
+ return -1;
|
|
Jan F. Chadima |
69dd72 |
MD5_Update(&md, (const u_char *)passphrase, strlen(passphrase));
|
|
Jan F. Chadima |
69dd72 |
MD5_Final(digest, &md);
|
|
Jan F. Chadima |
69dd72 |
|
|
Petr Lautrbach |
84822b |
@@ -389,6 +412,7 @@ cipher_set_key_string(CipherContext *cc,
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
memset(digest, 0, sizeof(digest));
|
|
Jan F. Chadima |
69dd72 |
memset(&md, 0, sizeof(md));
|
|
Jan F. Chadima |
69dd72 |
+ return 0;
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
/*
|
|
Petr Lautrbach |
84822b |
diff -up openssh-6.3p1/cipher.h.fips openssh-6.3p1/cipher.h
|
|
Petr Lautrbach |
84822b |
--- openssh-6.3p1/cipher.h.fips 2013-10-11 22:24:32.820031327 +0200
|
|
Petr Lautrbach |
84822b |
+++ openssh-6.3p1/cipher.h 2013-10-11 22:24:32.871031087 +0200
|
|
Petr Lautrbach |
84822b |
@@ -92,7 +92,7 @@ void cipher_init(CipherContext *, const
|
|
Petr Lautrbach |
8a29de |
void cipher_crypt(CipherContext *, u_char *, const u_char *,
|
|
Petr Lautrbach |
8a29de |
u_int, u_int, u_int);
|
|
Jan F. Chadima |
69dd72 |
void cipher_cleanup(CipherContext *);
|
|
Petr Lautrbach |
84822b |
-void cipher_set_key_string(CipherContext *, const Cipher *, const char *, int);
|
|
Petr Lautrbach |
84822b |
+int cipher_set_key_string(CipherContext *, const Cipher *, const char *, int);
|
|
Jan F. Chadima |
69dd72 |
u_int cipher_blocksize(const Cipher *);
|
|
Jan F. Chadima |
69dd72 |
u_int cipher_keylen(const Cipher *);
|
|
Petr Lautrbach |
8a29de |
u_int cipher_authlen(const Cipher *);
|
|
Petr Lautrbach |
84822b |
diff -up openssh-6.3p1/key.c.fips openssh-6.3p1/key.c
|
|
Petr Lautrbach |
84822b |
--- openssh-6.3p1/key.c.fips 2013-10-11 22:24:32.821031322 +0200
|
|
Petr Lautrbach |
84822b |
+++ openssh-6.3p1/key.c 2013-10-11 22:24:32.871031087 +0200
|
|
Jan F. Chadima |
69dd72 |
@@ -40,6 +40,7 @@
|
|
Jan F. Chadima |
69dd72 |
#include <sys/types.h>
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
#include <openssl/evp.h>
|
|
Jan F. Chadima |
69dd72 |
+#include <openssl/fips.h>
|
|
Jan F. Chadima |
69dd72 |
#include <openbsd-compat/openssl-compat.h>
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
#include <stdarg.h>
|
|
Petr Lautrbach |
84822b |
@@ -606,9 +607,13 @@ key_fingerprint_selection(void)
|
|
Jan F. Chadima |
69dd72 |
char *env;
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
if (!rv_defined) {
|
|
Jan F. Chadima |
69dd72 |
- env = getenv("SSH_FINGERPRINT_TYPE");
|
|
Jan F. Chadima |
69dd72 |
- rv = (env && !strcmp (env, "sha")) ?
|
|
Jan F. Chadima |
69dd72 |
- SSH_FP_SHA1 : SSH_FP_MD5;
|
|
Jan F. Chadima |
69dd72 |
+ if (FIPS_mode())
|
|
Jan F. Chadima |
69dd72 |
+ rv = SSH_FP_SHA1;
|
|
Jan F. Chadima |
69dd72 |
+ else {
|
|
Jan F. Chadima |
69dd72 |
+ env = getenv("SSH_FINGERPRINT_TYPE");
|
|
Jan F. Chadima |
69dd72 |
+ rv = (env && !strcmp (env, "sha")) ?
|
|
Jan F. Chadima |
69dd72 |
+ SSH_FP_SHA1 : SSH_FP_MD5;
|
|
Jan F. Chadima |
69dd72 |
+ }
|
|
Jan F. Chadima |
69dd72 |
rv_defined = 1;
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
return rv;
|
|
Petr Lautrbach |
84822b |
diff -up openssh-6.3p1/mac.c.fips openssh-6.3p1/mac.c
|
|
Petr Lautrbach |
84822b |
--- openssh-6.3p1/mac.c.fips 2013-10-11 22:24:32.821031322 +0200
|
|
Petr Lautrbach |
84822b |
+++ openssh-6.3p1/mac.c 2013-10-11 22:25:35.394737186 +0200
|
|
Jan F. Chadima |
69dd72 |
@@ -28,6 +28,7 @@
|
|
Jan F. Chadima |
69dd72 |
#include <sys/types.h>
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
#include <openssl/hmac.h>
|
|
Jan F. Chadima |
69dd72 |
+#include <openssl/fips.h>
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
#include <stdarg.h>
|
|
Jan F. Chadima |
69dd72 |
#include <string.h>
|
|
Petr Lautrbach |
84822b |
@@ -60,7 +61,7 @@ struct macalg {
|
|
Petr Lautrbach |
8a29de |
int etm; /* Encrypt-then-MAC */
|
|
Petr Lautrbach |
84822b |
};
|
|
Petr Lautrbach |
84822b |
|
|
Petr Lautrbach |
84822b |
-static const struct macalg macs[] = {
|
|
Petr Lautrbach |
84822b |
+static const struct macalg all_macs[] = {
|
|
Petr Lautrbach |
8a29de |
/* Encrypt-and-MAC (encrypt-and-authenticate) variants */
|
|
Petr Lautrbach |
8a29de |
{ "hmac-sha1", SSH_EVP, EVP_sha1, 0, 0, 0, 0 },
|
|
Petr Lautrbach |
8a29de |
{ "hmac-sha1-96", SSH_EVP, EVP_sha1, 96, 0, 0, 0 },
|
|
Petr Lautrbach |
84822b |
@@ -91,6 +92,18 @@ static const struct macalg macs[] = {
|
|
Petr Lautrbach |
8a29de |
{ NULL, 0, NULL, 0, 0, 0, 0 }
|
|
Jan F. Chadima |
69dd72 |
};
|
|
Jan F. Chadima |
69dd72 |
|
|
Petr Lautrbach |
84822b |
+static const struct macalg fips_macs[] = {
|
|
Petr Lautrbach |
84822b |
+ { "hmac-sha1", SSH_EVP, EVP_sha1, 0, 0, 0, 0 },
|
|
Petr Lautrbach |
84822b |
+ { "hmac-sha1-etm@openssh.com", SSH_EVP, EVP_sha1, 0, 0, 0, 1 },
|
|
Tomas Mraz |
e96203 |
+#ifdef HAVE_EVP_SHA256
|
|
Petr Lautrbach |
84822b |
+ { "hmac-sha2-256", SSH_EVP, EVP_sha256, 0, 0, 0, 0 },
|
|
Petr Lautrbach |
84822b |
+ { "hmac-sha2-512", SSH_EVP, EVP_sha512, 0, 0, 0, 0 },
|
|
Petr Lautrbach |
84822b |
+ { "hmac-sha2-256-etm@openssh.com", SSH_EVP, EVP_sha256, 0, 0, 0, 1 },
|
|
Petr Lautrbach |
84822b |
+ { "hmac-sha2-512-etm@openssh.com", SSH_EVP, EVP_sha512, 0, 0, 0, 1 },
|
|
Tomas Mraz |
e96203 |
+#endif
|
|
Petr Lautrbach |
84822b |
+ { NULL, 0, NULL, 0, 0, 0, 0 }
|
|
Jan F. Chadima |
69dd72 |
+};
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Petr Lautrbach |
84822b |
/* Returns a comma-separated list of supported MACs. */
|
|
Petr Lautrbach |
84822b |
char *
|
|
Petr Lautrbach |
84822b |
mac_alg_list(void)
|
|
Petr Lautrbach |
84822b |
@@ -99,7 +112,7 @@ mac_alg_list(void)
|
|
Petr Lautrbach |
84822b |
size_t nlen, rlen = 0;
|
|
Petr Lautrbach |
84822b |
const struct macalg *m;
|
|
Petr Lautrbach |
84822b |
|
|
Petr Lautrbach |
84822b |
- for (m = macs; m->name != NULL; m++) {
|
|
Petr Lautrbach |
84822b |
+ for (m = FIPS_mode() ? fips_macs : all_macs; m->name != NULL; m++) {
|
|
Petr Lautrbach |
84822b |
if (ret != NULL)
|
|
Petr Lautrbach |
84822b |
ret[rlen++] = '\n';
|
|
Petr Lautrbach |
84822b |
nlen = strlen(m->name);
|
|
Petr Lautrbach |
84822b |
@@ -136,7 +149,7 @@ mac_setup(Mac *mac, char *name)
|
|
Jan F. Chadima |
69dd72 |
{
|
|
Petr Lautrbach |
84822b |
const struct macalg *m;
|
|
Petr Lautrbach |
84822b |
|
|
Petr Lautrbach |
84822b |
- for (m = macs; m->name != NULL; m++) {
|
|
Petr Lautrbach |
84822b |
+ for (m = FIPS_mode() ? fips_macs : all_macs; m->name != NULL; m++) {
|
|
Petr Lautrbach |
84822b |
if (strcmp(name, m->name) != 0)
|
|
Petr Lautrbach |
84822b |
continue;
|
|
Petr Lautrbach |
84822b |
if (mac != NULL)
|
|
Petr Lautrbach |
84822b |
diff -up openssh-6.3p1/myproposal.h.fips openssh-6.3p1/myproposal.h
|
|
Petr Lautrbach |
84822b |
--- openssh-6.3p1/myproposal.h.fips 2013-06-11 04:10:02.000000000 +0200
|
|
Petr Lautrbach |
84822b |
+++ openssh-6.3p1/myproposal.h 2013-10-11 22:24:32.872031082 +0200
|
|
Petr Lautrbach |
84822b |
@@ -114,6 +114,19 @@
|
|
Jan F. Chadima |
69dd72 |
#define KEX_DEFAULT_COMP "none,zlib@openssh.com,zlib"
|
|
Jan F. Chadima |
69dd72 |
#define KEX_DEFAULT_LANG ""
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
+#define KEX_FIPS_ENCRYPT \
|
|
Jan F. Chadima |
69dd72 |
+ "aes128-ctr,aes192-ctr,aes256-ctr," \
|
|
Jan F. Chadima |
69dd72 |
+ "aes128-cbc,3des-cbc," \
|
|
Jan F. Chadima |
69dd72 |
+ "aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se"
|
|
Tomas Mraz |
e96203 |
+#ifdef HAVE_EVP_SHA256
|
|
Tomas Mraz |
e96203 |
+#define KEX_FIPS_MAC \
|
|
Tomas Mraz |
e96203 |
+ "hmac-sha1," \
|
|
Tomas Mraz |
e96203 |
+ "hmac-sha2-256," \
|
|
Tomas Mraz |
e96203 |
+ "hmac-sha2-512"
|
|
Tomas Mraz |
e96203 |
+#else
|
|
Jan F. Chadima |
69dd72 |
+#define KEX_FIPS_MAC \
|
|
Jan F. Chadima |
69dd72 |
+ "hmac-sha1"
|
|
Tomas Mraz |
e96203 |
+#endif
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
static char *myproposal[PROPOSAL_MAX] = {
|
|
Jan F. Chadima |
69dd72 |
KEX_DEFAULT_KEX,
|
|
Petr Lautrbach |
84822b |
diff -up openssh-6.3p1/openbsd-compat/bsd-arc4random.c.fips openssh-6.3p1/openbsd-compat/bsd-arc4random.c
|
|
Petr Lautrbach |
84822b |
--- openssh-6.3p1/openbsd-compat/bsd-arc4random.c.fips 2010-03-25 22:52:02.000000000 +0100
|
|
Petr Lautrbach |
84822b |
+++ openssh-6.3p1/openbsd-compat/bsd-arc4random.c 2013-10-11 22:24:32.872031082 +0200
|
|
Jan F. Chadima |
69dd72 |
@@ -37,25 +37,18 @@
|
|
Jan F. Chadima |
69dd72 |
#define REKEY_BYTES (1 << 24)
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
static int rc4_ready = 0;
|
|
Jan F. Chadima |
69dd72 |
-static RC4_KEY rc4;
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
unsigned int
|
|
Jan F. Chadima |
69dd72 |
arc4random(void)
|
|
Jan F. Chadima |
69dd72 |
{
|
|
Jan F. Chadima |
69dd72 |
unsigned int r = 0;
|
|
Jan F. Chadima |
69dd72 |
- static int first_time = 1;
|
|
Jan F. Chadima |
69dd72 |
+ void *rp = &r;
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
- if (rc4_ready <= 0) {
|
|
Jan F. Chadima |
69dd72 |
- if (first_time)
|
|
Jan F. Chadima |
69dd72 |
- seed_rng();
|
|
Jan F. Chadima |
69dd72 |
- first_time = 0;
|
|
Jan F. Chadima |
69dd72 |
+ if (!rc4_ready) {
|
|
Jan F. Chadima |
69dd72 |
arc4random_stir();
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
+ RAND_bytes(rp, sizeof(r));
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
- RC4(&rc4, sizeof(r), (unsigned char *)&r, (unsigned char *)&r);
|
|
Jan F. Chadima |
69dd72 |
-
|
|
Jan F. Chadima |
69dd72 |
- rc4_ready -= sizeof(r);
|
|
Jan F. Chadima |
69dd72 |
-
|
|
Jan F. Chadima |
69dd72 |
return(r);
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
@@ -63,24 +56,11 @@ void
|
|
Jan F. Chadima |
69dd72 |
arc4random_stir(void)
|
|
Jan F. Chadima |
69dd72 |
{
|
|
Jan F. Chadima |
69dd72 |
unsigned char rand_buf[SEED_SIZE];
|
|
Jan F. Chadima |
69dd72 |
- int i;
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
- memset(&rc4, 0, sizeof(rc4));
|
|
Jan F. Chadima |
69dd72 |
if (RAND_bytes(rand_buf, sizeof(rand_buf)) <= 0)
|
|
Jan F. Chadima |
69dd72 |
fatal("Couldn't obtain random bytes (error %ld)",
|
|
Jan F. Chadima |
69dd72 |
ERR_get_error());
|
|
Jan F. Chadima |
69dd72 |
- RC4_set_key(&rc4, sizeof(rand_buf), rand_buf);
|
|
Jan F. Chadima |
69dd72 |
-
|
|
Jan F. Chadima |
69dd72 |
- /*
|
|
Jan F. Chadima |
69dd72 |
- * Discard early keystream, as per recommendations in:
|
|
Jan F. Chadima |
69dd72 |
- * http://www.wisdom.weizmann.ac.il/~itsik/RC4/Papers/Rc4_ksa.ps
|
|
Jan F. Chadima |
69dd72 |
- */
|
|
Jan F. Chadima |
69dd72 |
- for(i = 0; i <= 256; i += sizeof(rand_buf))
|
|
Jan F. Chadima |
69dd72 |
- RC4(&rc4, sizeof(rand_buf), rand_buf, rand_buf);
|
|
Jan F. Chadima |
69dd72 |
-
|
|
Jan F. Chadima |
69dd72 |
- memset(rand_buf, 0, sizeof(rand_buf));
|
|
Jan F. Chadima |
69dd72 |
-
|
|
Jan F. Chadima |
69dd72 |
- rc4_ready = REKEY_BYTES;
|
|
Jan F. Chadima |
69dd72 |
+ rc4_ready = 1;
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
#endif /* !HAVE_ARC4RANDOM */
|
|
Jan F. Chadima |
69dd72 |
|
|
Petr Lautrbach |
84822b |
diff -up openssh-6.3p1/ssh.c.fips openssh-6.3p1/ssh.c
|
|
Petr Lautrbach |
84822b |
--- openssh-6.3p1/ssh.c.fips 2013-07-25 03:55:53.000000000 +0200
|
|
Petr Lautrbach |
84822b |
+++ openssh-6.3p1/ssh.c 2013-10-11 22:24:32.872031082 +0200
|
|
Jan F. Chadima |
69dd72 |
@@ -73,6 +73,8 @@
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
#include <openssl/evp.h>
|
|
Jan F. Chadima |
69dd72 |
#include <openssl/err.h>
|
|
Jan F. Chadima |
69dd72 |
+#include <openssl/fips.h>
|
|
Jan F. Chadima |
69dd72 |
+#include <fipscheck.h>
|
|
Jan F. Chadima |
69dd72 |
#include "openbsd-compat/openssl-compat.h"
|
|
Jan F. Chadima |
69dd72 |
#include "openbsd-compat/sys-queue.h"
|
|
Jan F. Chadima |
69dd72 |
|
|
Petr Lautrbach |
f12afd |
@@ -253,6 +255,13 @@ main(int ac, char **av)
|
|
Jan F. Chadima |
69dd72 |
sanitise_stdfd();
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
__progname = ssh_get_progname(av[0]);
|
|
Jan F. Chadima |
69dd72 |
+ SSLeay_add_all_algorithms();
|
|
Petr Lautrbach |
f12afd |
+ if (access("/etc/system-fips", F_OK) == 0)
|
|
Petr Lautrbach |
f12afd |
+ if (! FIPSCHECK_verify(NULL, NULL))
|
|
Petr Lautrbach |
f12afd |
+ if (FIPS_mode())
|
|
Petr Lautrbach |
f12afd |
+ fatal("FIPS integrity verification test failed.");
|
|
Petr Lautrbach |
f12afd |
+ else
|
|
Petr Lautrbach |
f12afd |
+ logit("FIPS integrity verification test failed.");
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
#ifndef HAVE_SETPROCTITLE
|
|
Jan F. Chadima |
69dd72 |
/* Prepare for later setproctitle emulation */
|
|
Petr Lautrbach |
84822b |
@@ -330,6 +339,9 @@ main(int ac, char **av)
|
|
Petr Lautrbach |
84822b |
"ACD:E:F:I:KL:MNO:PQ:R:S:TVw:W:XYy")) != -1) {
|
|
Jan F. Chadima |
69dd72 |
switch (opt) {
|
|
Jan F. Chadima |
69dd72 |
case '1':
|
|
Jan F. Chadima |
69dd72 |
+ if (FIPS_mode()) {
|
|
Jan F. Chadima |
69dd72 |
+ fatal("Protocol 1 not allowed in the FIPS mode.");
|
|
Jan F. Chadima |
69dd72 |
+ }
|
|
Jan F. Chadima |
69dd72 |
options.protocol = SSH_PROTO_1;
|
|
Jan F. Chadima |
69dd72 |
break;
|
|
Jan F. Chadima |
69dd72 |
case '2':
|
|
Petr Lautrbach |
84822b |
@@ -647,7 +659,6 @@ main(int ac, char **av)
|
|
Jan F. Chadima |
69dd72 |
if (!host)
|
|
Jan F. Chadima |
69dd72 |
usage();
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
- OpenSSL_add_all_algorithms();
|
|
Jan F. Chadima |
69dd72 |
ERR_load_crypto_strings();
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
/* Initialize the command to execute on remote host. */
|
|
Petr Lautrbach |
84822b |
@@ -748,6 +759,10 @@ main(int ac, char **av)
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
seed_rng();
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
+ if (FIPS_mode()) {
|
|
Jan F. Chadima |
69dd72 |
+ logit("FIPS mode initialized");
|
|
Jan F. Chadima |
69dd72 |
+ }
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
if (options.user == NULL)
|
|
Jan F. Chadima |
69dd72 |
options.user = xstrdup(pw->pw_name);
|
|
Jan F. Chadima |
69dd72 |
|
|
Petr Lautrbach |
84822b |
@@ -816,6 +831,12 @@ main(int ac, char **av)
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
timeout_ms = options.connection_timeout * 1000;
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
+ if (FIPS_mode()) {
|
|
Jan F. Chadima |
69dd72 |
+ options.protocol &= SSH_PROTO_2;
|
|
Jan F. Chadima |
69dd72 |
+ if (options.protocol == 0)
|
|
Jan F. Chadima |
69dd72 |
+ fatal("Protocol 2 disabled by configuration but required in the FIPS mode.");
|
|
Jan F. Chadima |
69dd72 |
+ }
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
/* Open a connection to the remote host. */
|
|
Jan F. Chadima |
69dd72 |
if (ssh_connect(host, &hostaddr, options.port,
|
|
Jan F. Chadima |
69dd72 |
options.address_family, options.connection_attempts, &timeout_ms,
|
|
Petr Lautrbach |
84822b |
diff -up openssh-6.3p1/sshconnect2.c.fips openssh-6.3p1/sshconnect2.c
|
|
Petr Lautrbach |
84822b |
--- openssh-6.3p1/sshconnect2.c.fips 2013-10-11 22:24:32.810031374 +0200
|
|
Petr Lautrbach |
84822b |
+++ openssh-6.3p1/sshconnect2.c 2013-10-11 22:24:32.873031077 +0200
|
|
Jan F. Chadima |
69dd72 |
@@ -44,6 +44,8 @@
|
|
Jan F. Chadima |
69dd72 |
#include <vis.h>
|
|
Jan F. Chadima |
69dd72 |
#endif
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
+#include <openssl/fips.h>
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
#include "openbsd-compat/sys-queue.h"
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
#include "xmalloc.h"
|
|
Jan F. Chadima |
69dd72 |
@@ -170,6 +172,10 @@ ssh_kex2(char *host, struct sockaddr *ho
|
|
Jan F. Chadima |
69dd72 |
if (options.ciphers != NULL) {
|
|
Jan F. Chadima |
69dd72 |
myproposal[PROPOSAL_ENC_ALGS_CTOS] =
|
|
Jan F. Chadima |
69dd72 |
myproposal[PROPOSAL_ENC_ALGS_STOC] = options.ciphers;
|
|
Jan F. Chadima |
69dd72 |
+ } else if (FIPS_mode()) {
|
|
Jan F. Chadima |
69dd72 |
+ myproposal[PROPOSAL_ENC_ALGS_CTOS] =
|
|
Jan F. Chadima |
69dd72 |
+ myproposal[PROPOSAL_ENC_ALGS_STOC] = KEX_FIPS_ENCRYPT;
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
myproposal[PROPOSAL_ENC_ALGS_CTOS] =
|
|
Jan F. Chadima |
69dd72 |
compat_cipher_proposal(myproposal[PROPOSAL_ENC_ALGS_CTOS]);
|
|
Jan F. Chadima |
69dd72 |
@@ -185,7 +191,11 @@ ssh_kex2(char *host, struct sockaddr *ho
|
|
Jan F. Chadima |
69dd72 |
if (options.macs != NULL) {
|
|
Jan F. Chadima |
69dd72 |
myproposal[PROPOSAL_MAC_ALGS_CTOS] =
|
|
Jan F. Chadima |
69dd72 |
myproposal[PROPOSAL_MAC_ALGS_STOC] = options.macs;
|
|
Jan F. Chadima |
69dd72 |
+ } else if (FIPS_mode()) {
|
|
Jan F. Chadima |
69dd72 |
+ myproposal[PROPOSAL_MAC_ALGS_CTOS] =
|
|
Jan F. Chadima |
69dd72 |
+ myproposal[PROPOSAL_MAC_ALGS_STOC] = KEX_FIPS_MAC;
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
if (options.hostkeyalgorithms != NULL)
|
|
Jan F. Chadima |
69dd72 |
myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] =
|
|
Jan F. Chadima |
69dd72 |
options.hostkeyalgorithms;
|
|
Petr Lautrbach |
84822b |
diff -up openssh-6.3p1/sshd.c.fips openssh-6.3p1/sshd.c
|
|
Petr Lautrbach |
84822b |
--- openssh-6.3p1/sshd.c.fips 2013-10-11 22:24:32.842031223 +0200
|
|
Petr Lautrbach |
84822b |
+++ openssh-6.3p1/sshd.c 2013-10-11 22:24:32.873031077 +0200
|
|
Jan F. Chadima |
69dd72 |
@@ -76,6 +76,8 @@
|
|
Jan F. Chadima |
69dd72 |
#include <openssl/bn.h>
|
|
Jan F. Chadima |
69dd72 |
#include <openssl/md5.h>
|
|
Jan F. Chadima |
69dd72 |
#include <openssl/rand.h>
|
|
Jan F. Chadima |
69dd72 |
+#include <openssl/fips.h>
|
|
Jan F. Chadima |
69dd72 |
+#include <fipscheck.h>
|
|
Jan F. Chadima |
69dd72 |
#include "openbsd-compat/openssl-compat.h"
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
#ifdef HAVE_SECUREWARE
|
|
Petr Lautrbach |
84822b |
@@ -1450,6 +1452,14 @@ main(int ac, char **av)
|
|
Jan F. Chadima |
69dd72 |
#endif
|
|
Jan F. Chadima |
69dd72 |
__progname = ssh_get_progname(av[0]);
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
+ SSLeay_add_all_algorithms();
|
|
Petr Lautrbach |
f12afd |
+ if (access("/etc/system-fips", F_OK) == 0)
|
|
Petr Lautrbach |
f12afd |
+ if (! FIPSCHECK_verify(NULL, NULL))
|
|
Petr Lautrbach |
f12afd |
+ if (FIPS_mode())
|
|
Petr Lautrbach |
f12afd |
+ fatal("FIPS integrity verification test failed.");
|
|
Petr Lautrbach |
f12afd |
+ else
|
|
Petr Lautrbach |
f12afd |
+ logit("FIPS integrity verification test failed.");
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
/* Save argv. Duplicate so setproctitle emulation doesn't clobber it */
|
|
Jan F. Chadima |
69dd72 |
saved_argc = ac;
|
|
Jan F. Chadima |
69dd72 |
rexec_argc = ac;
|
|
Petr Lautrbach |
84822b |
@@ -1601,8 +1611,6 @@ main(int ac, char **av)
|
|
Jan F. Chadima |
69dd72 |
else
|
|
Jan F. Chadima |
69dd72 |
closefrom(REEXEC_DEVCRYPTO_RESERVED_FD);
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
- OpenSSL_add_all_algorithms();
|
|
Jan F. Chadima |
69dd72 |
-
|
|
Petr Lautrbach |
84822b |
/* If requested, redirect the logs to the specified logfile. */
|
|
Petr Lautrbach |
84822b |
if (logfile != NULL) {
|
|
Petr Lautrbach |
84822b |
log_redirect_stderr_to(logfile);
|
|
Petr Lautrbach |
84822b |
@@ -1773,6 +1781,10 @@ main(int ac, char **av)
|
|
Petr Lautrbach |
84822b |
debug("private host key: #%d type %d %s", i, keytype,
|
|
Petr Lautrbach |
84822b |
key_type(key ? key : pubkey));
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
+ if ((options.protocol & SSH_PROTO_1) && FIPS_mode()) {
|
|
Jan F. Chadima |
69dd72 |
+ logit("Disabling protocol version 1. Not allowed in the FIPS mode.");
|
|
Jan F. Chadima |
69dd72 |
+ options.protocol &= ~SSH_PROTO_1;
|
|
Jan F. Chadima |
69dd72 |
+ }
|
|
Jan F. Chadima |
69dd72 |
if ((options.protocol & SSH_PROTO_1) && !sensitive_data.have_ssh1_key) {
|
|
Jan F. Chadima |
69dd72 |
logit("Disabling protocol version 1. Could not load host key");
|
|
Jan F. Chadima |
69dd72 |
options.protocol &= ~SSH_PROTO_1;
|
|
Petr Lautrbach |
84822b |
@@ -1936,6 +1948,10 @@ main(int ac, char **av)
|
|
Jan F. Chadima |
69dd72 |
/* Initialize the random number generator. */
|
|
Jan F. Chadima |
69dd72 |
arc4random_stir();
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
+ if (FIPS_mode()) {
|
|
Jan F. Chadima |
69dd72 |
+ logit("FIPS mode initialized");
|
|
Jan F. Chadima |
69dd72 |
+ }
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
/* Chdir to the root directory so that the current disk can be
|
|
Jan F. Chadima |
69dd72 |
unmounted if desired. */
|
|
Petr Lautrbach |
84822b |
if (chdir("/") == -1)
|
|
Petr Lautrbach |
84822b |
@@ -2498,6 +2514,9 @@ do_ssh2_kex(void)
|
|
Jan F. Chadima |
69dd72 |
if (options.ciphers != NULL) {
|
|
Jan F. Chadima |
69dd72 |
myproposal[PROPOSAL_ENC_ALGS_CTOS] =
|
|
Jan F. Chadima |
69dd72 |
myproposal[PROPOSAL_ENC_ALGS_STOC] = options.ciphers;
|
|
Jan F. Chadima |
69dd72 |
+ } else if (FIPS_mode()) {
|
|
Jan F. Chadima |
69dd72 |
+ myproposal[PROPOSAL_ENC_ALGS_CTOS] =
|
|
Jan F. Chadima |
69dd72 |
+ myproposal[PROPOSAL_ENC_ALGS_STOC] = KEX_FIPS_ENCRYPT;
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
myproposal[PROPOSAL_ENC_ALGS_CTOS] =
|
|
Jan F. Chadima |
69dd72 |
compat_cipher_proposal(myproposal[PROPOSAL_ENC_ALGS_CTOS]);
|
|
Petr Lautrbach |
84822b |
@@ -2507,6 +2526,9 @@ do_ssh2_kex(void)
|
|
Jan F. Chadima |
69dd72 |
if (options.macs != NULL) {
|
|
Jan F. Chadima |
69dd72 |
myproposal[PROPOSAL_MAC_ALGS_CTOS] =
|
|
Jan F. Chadima |
69dd72 |
myproposal[PROPOSAL_MAC_ALGS_STOC] = options.macs;
|
|
Jan F. Chadima |
69dd72 |
+ } else if (FIPS_mode()) {
|
|
Jan F. Chadima |
69dd72 |
+ myproposal[PROPOSAL_MAC_ALGS_CTOS] =
|
|
Jan F. Chadima |
69dd72 |
+ myproposal[PROPOSAL_MAC_ALGS_STOC] = KEX_FIPS_MAC;
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
if (options.compression == COMP_NONE) {
|
|
Jan F. Chadima |
69dd72 |
myproposal[PROPOSAL_COMP_ALGS_CTOS] =
|