- drop obsolete triggers

- add testing FIPS mode support
- LSBize the initscript (#247014)
This commit is contained in:
Tomáš Mráz 2009-02-12 18:19:52 +00:00
parent ff6d597308
commit d93958db19
3 changed files with 741 additions and 41 deletions

655
openssh-5.1p1-fips.patch Normal file
View File

@ -0,0 +1,655 @@
diff -up openssh-5.1p1/ssh-agent.c.fips openssh-5.1p1/ssh-agent.c
--- openssh-5.1p1/ssh-agent.c.fips 2009-02-11 19:01:26.000000000 +0100
+++ openssh-5.1p1/ssh-agent.c 2009-02-12 13:46:18.000000000 +0100
@@ -51,6 +51,8 @@
#include <openssl/evp.h>
#include <openssl/md5.h>
+#include <openssl/fips.h>
+#include <fipscheck.h>
#include "openbsd-compat/openssl-compat.h"
#include <errno.h>
@@ -200,9 +202,9 @@ confirm_key(Identity *id)
char *p;
int ret = -1;
- p = key_fingerprint(id->key, SSH_FP_MD5, SSH_FP_HEX);
- if (ask_permission("Allow use of key %s?\nKey fingerprint %s.",
- id->comment, p))
+ p = key_fingerprint(id->key, FIPS_mode() ? SSH_FP_SHA1 : SSH_FP_MD5, SSH_FP_HEX);
+ if (ask_permission("Allow use of key %s?\nKey %sfingerprint %s.",
+ id->comment, FIPS_mode() ? "SHA1 " : "", p))
ret = 0;
xfree(p);
@@ -1196,6 +1198,11 @@ main(int ac, char **av)
#endif
SSLeay_add_all_algorithms();
+ if (FIPS_mode() && !FIPSCHECK_verify(NULL, NULL)) {
+ fprintf(stderr,
+ "FIPS integrity verification test failed.\n");
+ exit(3);
+ }
__progname = ssh_get_progname(av[0]);
init_rng();
diff -up openssh-5.1p1/auth2-pubkey.c.fips openssh-5.1p1/auth2-pubkey.c
--- openssh-5.1p1/auth2-pubkey.c.fips 2009-02-11 19:01:25.000000000 +0100
+++ openssh-5.1p1/auth2-pubkey.c 2009-02-11 19:01:26.000000000 +0100
@@ -33,6 +33,7 @@
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
+#include <openssl/fips.h>
#include "xmalloc.h"
#include "ssh.h"
@@ -243,7 +244,7 @@ user_key_allowed2(struct passwd *pw, Key
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, FIPS_mode() ? SSH_FP_SHA1 : SSH_FP_MD5, SSH_FP_HEX);
verbose("Found matching %s key: %s",
key_type(found), fp);
xfree(fp);
diff -up openssh-5.1p1/ssh.c.fips openssh-5.1p1/ssh.c
--- openssh-5.1p1/ssh.c.fips 2009-02-11 19:01:26.000000000 +0100
+++ openssh-5.1p1/ssh.c 2009-02-12 13:48:43.000000000 +0100
@@ -71,6 +71,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"
@@ -220,6 +222,10 @@ main(int ac, char **av)
sanitise_stdfd();
__progname = ssh_get_progname(av[0]);
+ SSLeay_add_all_algorithms();
+ if (FIPS_mode() && !FIPSCHECK_verify(NULL, NULL)) {
+ fatal("FIPS integrity verification test failed.");
+ }
init_rng();
/*
@@ -562,7 +568,6 @@ main(int ac, char **av)
if (!host)
usage();
- SSLeay_add_all_algorithms();
ERR_load_crypto_strings();
/* Initialize the command to execute on remote host. */
diff -up openssh-5.1p1/sshconnect2.c.fips openssh-5.1p1/sshconnect2.c
--- openssh-5.1p1/sshconnect2.c.fips 2009-02-11 19:01:26.000000000 +0100
+++ openssh-5.1p1/sshconnect2.c 2009-02-11 19:01:26.000000000 +0100
@@ -43,6 +43,8 @@
#include <vis.h>
#endif
+#include <openssl/fips.h>
+
#include "openbsd-compat/sys-queue.h"
#include "xmalloc.h"
@@ -113,6 +115,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]);
@@ -128,7 +134,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;
@@ -478,8 +488,8 @@ input_userauth_pk_ok(int type, u_int32_t
key->type, pktype);
goto done;
}
- fp = key_fingerprint(key, SSH_FP_MD5, SSH_FP_HEX);
- debug2("input_userauth_pk_ok: fp %s", fp);
+ fp = key_fingerprint(key, SSH_FP_SHA1, SSH_FP_HEX);
+ debug2("input_userauth_pk_ok: SHA1 fp %s", fp);
xfree(fp);
/*
diff -up openssh-5.1p1/Makefile.in.fips openssh-5.1p1/Makefile.in
--- openssh-5.1p1/Makefile.in.fips 2009-02-11 19:01:26.000000000 +0100
+++ openssh-5.1p1/Makefile.in 2009-02-12 14:06:25.000000000 +0100
@@ -134,28 +134,28 @@ libssh.a: $(LIBSSH_OBJS)
$(RANLIB) $@
ssh$(EXEEXT): $(LIBCOMPAT) libssh.a $(SSHOBJS)
- $(LD) -o $@ $(SSHOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
+ $(LD) -o $@ $(SSHOBJS) $(LDFLAGS) -lssh -lopenbsd-compat -lfipscheck $(LIBS)
sshd$(EXEEXT): libssh.a $(LIBCOMPAT) $(SSHDOBJS)
- $(LD) -o $@ $(SSHDOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(SSHDLIBS) $(LIBS)
+ $(LD) -o $@ $(SSHDOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(SSHDLIBS) -lfipscheck $(LIBS)
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
- $(LD) -o $@ ssh-agent.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
+ $(LD) -o $@ ssh-agent.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
- $(LD) -o $@ ssh-keysign.o readconf.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
+ $(LD) -o $@ ssh-keysign.o readconf.o $(LDFLAGS) -lssh -lopenbsd-compat -lfipscheck $(LIBS)
ssh-keyscan$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keyscan.o
- $(LD) -o $@ ssh-keyscan.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh $(LIBS)
+ $(LD) -o $@ ssh-keyscan.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-5.1p1/sshd.c.fips openssh-5.1p1/sshd.c
--- openssh-5.1p1/sshd.c.fips 2009-02-11 19:01:25.000000000 +0100
+++ openssh-5.1p1/sshd.c 2009-02-12 13:51:51.000000000 +0100
@@ -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
@@ -1261,6 +1263,12 @@ main(int ac, char **av)
(void)set_auth_parameters(ac, av);
#endif
__progname = ssh_get_progname(av[0]);
+
+ SSLeay_add_all_algorithms();
+ if (FIPS_mode() && !FIPSCHECK_verify(NULL, NULL)) {
+ fatal("FIPS integrity verification test failed.");
+ }
+
init_rng();
/* Save argv. Duplicate so setproctitle emulation doesn't clobber it */
@@ -1413,8 +1421,6 @@ main(int ac, char **av)
else
closefrom(REEXEC_DEVCRYPTO_RESERVED_FD);
- SSLeay_add_all_algorithms();
-
/*
* Force logging to stderr until we have loaded the private host
* key (unless started from inetd)
@@ -2183,6 +2189,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]);
@@ -2192,6 +2201,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] =
diff -up openssh-5.1p1/mac.c.fips openssh-5.1p1/mac.c
--- openssh-5.1p1/mac.c.fips 2008-06-13 02:58:50.000000000 +0200
+++ openssh-5.1p1/mac.c 2009-02-11 19:01:26.000000000 +0100
@@ -28,6 +28,7 @@
#include <sys/types.h>
#include <openssl/hmac.h>
+#include <openssl/fips.h>
#include <stdarg.h>
#include <string.h>
@@ -47,14 +48,14 @@
#define SSH_EVP 1 /* OpenSSL EVP-based MAC */
#define SSH_UMAC 2 /* UMAC (not integrated with OpenSSL) */
-struct {
+struct Macs {
char *name;
int type;
const EVP_MD * (*mdfunc)(void);
int truncatebits; /* truncate digest if != 0 */
int key_len; /* just for UMAC */
int len; /* just for UMAC */
-} macs[] = {
+} all_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 },
@@ -65,9 +66,15 @@ struct {
{ NULL, 0, NULL, 0, -1, -1 }
};
+struct Macs fips_macs[] = {
+ { "hmac-sha1", SSH_EVP, EVP_sha1, 0, -1, -1 },
+ { 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) {
@@ -88,6 +95,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-5.1p1/ssh-keygen.c.fips openssh-5.1p1/ssh-keygen.c
--- openssh-5.1p1/ssh-keygen.c.fips 2009-02-11 19:01:26.000000000 +0100
+++ openssh-5.1p1/ssh-keygen.c 2009-02-12 13:46:00.000000000 +0100
@@ -21,6 +21,8 @@
#include <openssl/evp.h>
#include <openssl/pem.h>
+#include <openssl/fips.h>
+#include <fipscheck.h>
#include "openbsd-compat/openssl-compat.h"
#include <errno.h>
@@ -537,7 +539,7 @@ do_fingerprint(struct passwd *pw)
enum fp_type fptype;
struct stat st;
- fptype = print_bubblebabble ? SSH_FP_SHA1 : SSH_FP_MD5;
+ fptype = print_bubblebabble ? SSH_FP_SHA1 : FIPS_mode() ? SSH_FP_SHA1 : SSH_FP_MD5;
rep = print_bubblebabble ? SSH_FP_BUBBLEBABBLE : SSH_FP_HEX;
if (!have_identity)
@@ -1125,6 +1127,12 @@ main(int argc, char **argv)
__progname = ssh_get_progname(argv[0]);
SSLeay_add_all_algorithms();
+ if (FIPS_mode() && !FIPSCHECK_verify(NULL, NULL)) {
+ fprintf(stderr,
+ "FIPS integrity verification test failed.\n");
+ exit(3);
+ }
+
log_init(argv[0], SYSLOG_LEVEL_INFO, SYSLOG_FACILITY_USER, 1);
init_rng();
@@ -1506,14 +1514,15 @@ passphrase_again:
fclose(f);
if (!quiet) {
- char *fp = key_fingerprint(public, SSH_FP_MD5, SSH_FP_HEX);
- char *ra = key_fingerprint(public, SSH_FP_MD5,
+ int fips_on = FIPS_mode();
+ char *fp = key_fingerprint(public, fips_on ? SSH_FP_SHA1 : SSH_FP_MD5, SSH_FP_HEX);
+ char *ra = key_fingerprint(public, fips_on ? SSH_FP_SHA1 : SSH_FP_MD5,
SSH_FP_RANDOMART);
printf("Your public key has been saved in %s.\n",
identity_file);
- printf("The key fingerprint is:\n");
+ printf("The key %sfingerprint is:\n", fips_on ? "SHA1 " : "");
printf("%s %s\n", fp, comment);
- printf("The key's randomart image is:\n");
+ printf("The key's %srandomart image is:\n", fips_on ? "SHA1 " :"");
printf("%s\n", ra);
xfree(ra);
xfree(fp);
diff -up openssh-5.1p1/nsskeys.c.fips openssh-5.1p1/nsskeys.c
--- openssh-5.1p1/nsskeys.c.fips 2009-02-11 19:01:26.000000000 +0100
+++ openssh-5.1p1/nsskeys.c 2009-02-11 19:01:26.000000000 +0100
@@ -183,8 +183,8 @@ nss_convert_pubkey(Key *k)
break;
}
- p = key_fingerprint(k, SSH_FP_MD5, SSH_FP_HEX);
- debug("fingerprint %u %s", key_size(k), p);
+ p = key_fingerprint(k, SSH_FP_SHA1, SSH_FP_HEX);
+ debug("SHA1 fingerprint %u %s", key_size(k), p);
xfree(p);
return 0;
diff -up openssh-5.1p1/ssh-add.c.fips openssh-5.1p1/ssh-add.c
--- openssh-5.1p1/ssh-add.c.fips 2009-02-11 19:01:26.000000000 +0100
+++ openssh-5.1p1/ssh-add.c 2009-02-12 13:46:31.000000000 +0100
@@ -42,6 +42,8 @@
#include <sys/param.h>
#include <openssl/evp.h>
+#include <openssl/fips.h>
+#include <fipscheck.h>
#include "openbsd-compat/openssl-compat.h"
#ifdef HAVE_LIBNSS
@@ -254,7 +256,7 @@ list_identities(AuthenticationConnection
key = ssh_get_next_identity(ac, &comment, version)) {
had_identities = 1;
if (do_fp) {
- fp = key_fingerprint(key, SSH_FP_MD5,
+ fp = key_fingerprint(key, FIPS_mode() ? SSH_FP_SHA1 : SSH_FP_MD5,
SSH_FP_HEX);
printf("%d %s %s (%s)\n",
key_size(key), fp, comment, key_type(key));
@@ -463,11 +465,16 @@ main(int argc, char **argv)
sanitise_stdfd();
__progname = ssh_get_progname(argv[0]);
+ SSLeay_add_all_algorithms();
+ if (FIPS_mode() && !FIPSCHECK_verify(NULL, NULL)) {
+ fprintf(stderr,
+ "FIPS integrity verification test failed.\n");
+ exit(3);
+ }
+
init_rng();
seed_rng();
- SSLeay_add_all_algorithms();
-
/* At first, get a connection to the authentication agent. */
ac = ssh_get_authentication_connection();
if (ac == NULL) {
diff -up openssh-5.1p1/openbsd-compat/bsd-arc4random.c.fips openssh-5.1p1/openbsd-compat/bsd-arc4random.c
--- openssh-5.1p1/openbsd-compat/bsd-arc4random.c.fips 2008-06-04 02:54:00.000000000 +0200
+++ openssh-5.1p1/openbsd-compat/bsd-arc4random.c 2009-02-11 19:01:26.000000000 +0100
@@ -39,6 +39,7 @@
static int rc4_ready = 0;
static RC4_KEY rc4;
+#if 0
unsigned int
arc4random(void)
{
@@ -82,6 +83,32 @@ arc4random_stir(void)
rc4_ready = REKEY_BYTES;
}
+#else
+unsigned int
+arc4random(void)
+{
+ unsigned int r = 0;
+ void *rp = &r;
+
+ if (!rc4_ready) {
+ arc4random_stir();
+ }
+ RAND_bytes(rp, sizeof(r));
+
+ return(r);
+}
+
+void
+arc4random_stir(void)
+{
+ unsigned char rand_buf[SEED_SIZE];
+
+ if (RAND_bytes(rand_buf, sizeof(rand_buf)) <= 0)
+ fatal("Couldn't obtain random bytes (error %ld)",
+ ERR_get_error());
+ rc4_ready = 1;
+}
+#endif
#endif /* !HAVE_ARC4RANDOM */
#ifndef ARC4RANDOM_BUF
diff -up openssh-5.1p1/myproposal.h.fips openssh-5.1p1/myproposal.h
--- openssh-5.1p1/myproposal.h.fips 2007-06-11 06:01:42.000000000 +0200
+++ openssh-5.1p1/myproposal.h 2009-02-11 19:01:26.000000000 +0100
@@ -52,7 +52,11 @@
"hmac-sha1-96,hmac-md5-96"
#define KEX_DEFAULT_COMP "none,zlib@openssh.com,zlib"
#define KEX_DEFAULT_LANG ""
-
+#define KEX_FIPS_ENCRYPT \
+ "aes128-cbc,3des-cbc," \
+ "aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se"
+#define KEX_FIPS_MAC \
+ "hmac-sha1"
static char *myproposal[PROPOSAL_MAX] = {
KEX_DEFAULT_KEX,
diff -up openssh-5.1p1/ssh-keysign.c.fips openssh-5.1p1/ssh-keysign.c
--- openssh-5.1p1/ssh-keysign.c.fips 2006-09-01 07:38:37.000000000 +0200
+++ openssh-5.1p1/ssh-keysign.c 2009-02-12 13:44:41.000000000 +0100
@@ -38,6 +38,8 @@
#include <openssl/evp.h>
#include <openssl/rand.h>
#include <openssl/rsa.h>
+#include <openssl/fips.h>
+#include <fipscheck.h>
#include "xmalloc.h"
#include "log.h"
@@ -175,6 +177,11 @@ main(int argc, char **argv)
permanently_set_uid(pw);
+ SSLeay_add_all_algorithms();
+ if (FIPS_mode() && !FIPSCHECK_verify(NULL, NULL)) {
+ fatal("FIPS integrity verification test failed");
+ }
+
init_rng();
seed_rng();
arc4random_stir();
@@ -194,7 +201,6 @@ main(int argc, char **argv)
if (key_fd[0] == -1 && key_fd[1] == -1)
fatal("could not open any host key");
- SSLeay_add_all_algorithms();
for (i = 0; i < 256; i++)
rnd[i] = arc4random();
RAND_seed(rnd, sizeof(rnd));
diff -up openssh-5.1p1/cipher.c.fips openssh-5.1p1/cipher.c
--- openssh-5.1p1/cipher.c.fips 2008-07-23 14:03:19.000000000 +0200
+++ openssh-5.1p1/cipher.c 2009-02-11 19:01:26.000000000 +0100
@@ -40,6 +40,7 @@
#include <sys/types.h>
#include <openssl/md5.h>
+#include <openssl/fips.h>
#include <string.h>
#include <stdarg.h>
@@ -92,6 +93,22 @@ struct Cipher {
{ NULL, SSH_CIPHER_INVALID, 0, 0, 0, NULL }
};
+struct Cipher fips_ciphers[] = {
+ { "none", SSH_CIPHER_NONE, 8, 0, 0, EVP_enc_null },
+ { "3des", SSH_CIPHER_3DES, 8, 16, 0, evp_ssh1_3des },
+
+ { "3des-cbc", SSH_CIPHER_SSH2, 8, 24, 0, EVP_des_ede3_cbc },
+ { "aes128-cbc", SSH_CIPHER_SSH2, 16, 16, 0, EVP_aes_128_cbc },
+ { "aes192-cbc", SSH_CIPHER_SSH2, 16, 24, 0, EVP_aes_192_cbc },
+ { "aes256-cbc", SSH_CIPHER_SSH2, 16, 32, 0, EVP_aes_256_cbc },
+ { "rijndael-cbc@lysator.liu.se",
+ SSH_CIPHER_SSH2, 16, 32, 0, EVP_aes_256_cbc },
+ { "aes128-ctr", SSH_CIPHER_SSH2, 16, 16, 0, evp_aes_128_ctr },
+ { "aes192-ctr", SSH_CIPHER_SSH2, 16, 24, 0, evp_aes_128_ctr },
+ { "aes256-ctr", SSH_CIPHER_SSH2, 16, 32, 0, evp_aes_128_ctr },
+ { NULL, SSH_CIPHER_INVALID, 0, 0, 0, NULL }
+};
+
/*--*/
u_int
@@ -128,7 +145,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;
@@ -138,7 +155,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;
@@ -182,7 +199,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;
diff -up openssh-5.1p1/ssh-keyscan.c.fips openssh-5.1p1/ssh-keyscan.c
--- openssh-5.1p1/ssh-keyscan.c.fips 2008-07-04 15:10:49.000000000 +0200
+++ openssh-5.1p1/ssh-keyscan.c 2009-02-12 13:44:21.000000000 +0100
@@ -19,6 +19,8 @@
#include <arpa/inet.h>
#include <openssl/bn.h>
+#include <openssl/fips.h>
+#include <fipscheck.h>
#include <netdb.h>
#include <errno.h>
@@ -730,6 +732,13 @@ main(int argc, char **argv)
extern char *optarg;
__progname = ssh_get_progname(argv[0]);
+ SSLeay_add_all_algorithms();
+ if (FIPS_mode() && !FIPSCHECK_verify(NULL, NULL)) {
+ fprintf(stderr,
+ "FIPS integrity verification test failed.\n");
+ exit(3);
+ }
+
init_rng();
seed_rng();
TAILQ_INIT(&tq);
diff -up openssh-5.1p1/sshconnect.c.fips openssh-5.1p1/sshconnect.c
--- openssh-5.1p1/sshconnect.c.fips 2009-02-11 19:01:26.000000000 +0100
+++ openssh-5.1p1/sshconnect.c 2009-02-11 19:01:26.000000000 +0100
@@ -40,6 +40,8 @@
#include <unistd.h>
#include <fcntl.h>
+#include <openssl/fips.h>
+
#include "xmalloc.h"
#include "key.h"
#include "hostfile.h"
@@ -765,6 +767,7 @@ check_host_key(char *hostname, struct so
goto fail;
} else if (options.strict_host_key_checking == 2) {
char msg1[1024], msg2[1024];
+ int fips_on = FIPS_mode();
if (show_other_keys(host, host_key))
snprintf(msg1, sizeof(msg1),
@@ -773,8 +776,8 @@ check_host_key(char *hostname, struct so
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, fips_on ? SSH_FP_SHA1 : SSH_FP_MD5, SSH_FP_HEX);
+ ra = key_fingerprint(host_key, fips_on ? SSH_FP_SHA1 : SSH_FP_MD5,
SSH_FP_RANDOMART);
msg2[0] = '\0';
if (options.verify_host_key_dns) {
@@ -790,10 +793,10 @@ check_host_key(char *hostname, struct so
snprintf(msg, sizeof(msg),
"The authenticity of host '%.200s (%s)' can't be "
"established%s\n"
- "%s key fingerprint is %s.%s%s\n%s"
+ "%s key %sfingerprint is %s.%s%s\n%s"
"Are you sure you want to continue connecting "
"(yes/no)? ",
- host, ip, msg1, type, fp,
+ host, ip, msg1, type, fips_on ? "SHA1 " : "", fp,
options.visual_host_key ? "\n" : "",
options.visual_host_key ? ra : "",
msg2);
@@ -1081,17 +1084,18 @@ show_key_from_file(const char *file, con
Key *found;
char *fp, *ra;
int line, ret;
+ int fips_on = FIPS_mode();
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, fips_on ? SSH_FP_SHA1 : SSH_FP_MD5, SSH_FP_HEX);
+ ra = key_fingerprint(found, fips_on ? SSH_FP_SHA1 : SSH_FP_MD5, SSH_FP_RANDOMART);
logit("WARNING: %s key found for host %s\n"
"in %s:%d\n"
- "%s key fingerprint %s.\n%s\n",
+ "%s key %sfingerprint %s.\n%s\n",
key_type(found), host, file, line,
- key_type(found), fp, ra);
+ key_type(found), fips_on ? "SHA1 ":"", fp, ra);
xfree(ra);
xfree(fp);
}
@@ -1137,8 +1141,9 @@ warn_changed_key(Key *host_key)
{
char *fp;
const char *type = key_type(host_key);
+ int fips_on = FIPS_mode();
- fp = key_fingerprint(host_key, SSH_FP_MD5, SSH_FP_HEX);
+ fp = key_fingerprint(host_key, fips_on ? SSH_FP_SHA1 : SSH_FP_MD5, SSH_FP_HEX);
error("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
error("@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @");
@@ -1146,8 +1151,8 @@ warn_changed_key(Key *host_key)
error("IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!");
error("Someone could be eavesdropping on you right now (man-in-the-middle attack)!");
error("It is also possible that the %s host key has just been changed.", type);
- error("The fingerprint for the %s key sent by the remote host is\n%s.",
- type, fp);
+ error("The %sfingerprint for the %s key sent by the remote host is\n%s.",
+ fips_on ? "SHA1 ":"", type, fp);
error("Please contact your system administrator.");
xfree(fp);

View File

@ -63,7 +63,7 @@
Summary: An open source implementation of SSH protocol versions 1 and 2 Summary: An open source implementation of SSH protocol versions 1 and 2
Name: openssh Name: openssh
Version: 5.1p1 Version: 5.1p1
Release: 6%{?dist}%{?rescue_rel} Release: 7%{?dist}%{?rescue_rel}
URL: http://www.openssh.com/portable.html URL: http://www.openssh.com/portable.html
#Source0: ftp://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-%{version}.tar.gz #Source0: ftp://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-%{version}.tar.gz
#Source1: ftp://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-%{version}.tar.gz.asc #Source1: ftp://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-%{version}.tar.gz.asc
@ -98,6 +98,7 @@ Patch55: openssh-5.1p1-cloexec.patch
Patch62: openssh-5.1p1-scp-manpage.patch Patch62: openssh-5.1p1-scp-manpage.patch
Patch63: openssh-5.1p1-bannerlen.patch Patch63: openssh-5.1p1-bannerlen.patch
Patch64: openssh-5.1p1-compat-sessions.patch Patch64: openssh-5.1p1-compat-sessions.patch
Patch65: openssh-5.1p1-fips.patch
License: BSD License: BSD
Group: Applications/Internet Group: Applications/Internet
@ -120,11 +121,13 @@ BuildRequires: gnome-libs-devel
%if %{scard} %if %{scard}
BuildRequires: sharutils BuildRequires: sharutils
%endif %endif
BuildRequires: autoconf, automake, openssl-devel, perl, zlib-devel BuildRequires: autoconf, automake, perl, zlib-devel
BuildRequires: audit-libs-devel BuildRequires: audit-libs-devel
BuildRequires: util-linux, groff, man BuildRequires: util-linux, groff, man
BuildRequires: pam-devel BuildRequires: pam-devel
BuildRequires: tcp_wrappers-devel BuildRequires: tcp_wrappers-devel
BuildRequires: fipscheck-devel
BuildRequires: openssl-devel >= 0.9.8j
%if %{kerberos5} %if %{kerberos5}
BuildRequires: krb5-devel BuildRequires: krb5-devel
@ -228,6 +231,7 @@ an X11 passphrase dialog for OpenSSH.
%patch62 -p1 -b .manpage %patch62 -p1 -b .manpage
%patch63 -p1 -b .bannerlen %patch63 -p1 -b .bannerlen
%patch64 -p1 -b .compat-sessions %patch64 -p1 -b .compat-sessions
%patch65 -p1 -b .fips
autoreconf autoreconf
@ -322,6 +326,20 @@ fi
popd popd
%endif %endif
# Add generation of HMAC checksums of the final stripped binaries
%define __spec_install_post \
%{?__debug_package:%{__debug_install_post}} \
%{__arch_install_post} \
%{__os_install_post} \
fipshmac $RPM_BUILD_ROOT%{_bindir}/ssh-keygen \
fipshmac $RPM_BUILD_ROOT%{_libexecdir}/openssh/ssh-keysign \
fipshmac $RPM_BUILD_ROOT%{_bindir}/ssh \
fipshmac $RPM_BUILD_ROOT%{_bindir}/ssh-agent \
fipshmac $RPM_BUILD_ROOT%{_bindir}/ssh-add \
fipshmac $RPM_BUILD_ROOT%{_bindir}/ssh-keyscan \
fipshmac $RPM_BUILD_ROOT%{_sbindir}/sshd \
%{nil}
%install %install
rm -rf $RPM_BUILD_ROOT rm -rf $RPM_BUILD_ROOT
mkdir -p -m755 $RPM_BUILD_ROOT%{_sysconfdir}/ssh mkdir -p -m755 $RPM_BUILD_ROOT%{_sysconfdir}/ssh
@ -365,34 +383,6 @@ rm -f README.nss
%clean %clean
rm -rf $RPM_BUILD_ROOT rm -rf $RPM_BUILD_ROOT
%triggerun server -- ssh-server
if [ "$1" != 0 -a -r /var/run/sshd.pid ] ; then
touch /var/run/sshd.restart
fi
%triggerun server -- openssh-server < 2.5.0p1
# Count the number of HostKey and HostDsaKey statements we have.
gawk 'BEGIN {IGNORECASE=1}
/^hostkey/ || /^hostdsakey/ {sawhostkey = sawhostkey + 1}
END {exit sawhostkey}' /etc/ssh/sshd_config
# And if we only found one, we know the client was relying on the old default
# behavior, which loaded the the SSH2 DSA host key when HostDsaKey wasn't
# specified. Now that HostKey is used for both SSH1 and SSH2 keys, specifying
# one nullifies the default, which would have loaded both.
if [ $? -eq 1 ] ; then
echo HostKey /etc/ssh/ssh_host_rsa_key >> /etc/ssh/sshd_config
echo HostKey /etc/ssh/ssh_host_dsa_key >> /etc/ssh/sshd_config
fi
%triggerpostun server -- ssh-server
if [ "$1" != 0 ] ; then
/sbin/chkconfig --add sshd
if test -f /var/run/sshd.restart ; then
rm -f /var/run/sshd.restart
/sbin/service sshd start > /dev/null 2>&1 || :
fi
fi
%pre server %pre server
%if %{nologin} %if %{nologin}
/usr/sbin/useradd -c "Privilege-separated SSH" -u %{sshd_uid} \ /usr/sbin/useradd -c "Privilege-separated SSH" -u %{sshd_uid} \
@ -422,9 +412,11 @@ fi
%attr(0600,root,root) %config(noreplace) %{_sysconfdir}/ssh/moduli %attr(0600,root,root) %config(noreplace) %{_sysconfdir}/ssh/moduli
%if ! %{rescue} %if ! %{rescue}
%attr(0755,root,root) %{_bindir}/ssh-keygen %attr(0755,root,root) %{_bindir}/ssh-keygen
%attr(0644,root,root) %{_bindir}/.ssh-keygen.hmac
%attr(0644,root,root) %{_mandir}/man1/ssh-keygen.1* %attr(0644,root,root) %{_mandir}/man1/ssh-keygen.1*
%attr(0755,root,root) %dir %{_libexecdir}/openssh %attr(0755,root,root) %dir %{_libexecdir}/openssh
%attr(4755,root,root) %{_libexecdir}/openssh/ssh-keysign %attr(4755,root,root) %{_libexecdir}/openssh/ssh-keysign
%attr(0644,root,root) %{_libexecdir}/openssh/.ssh-keysign.hmac
%attr(0644,root,root) %{_mandir}/man8/ssh-keysign.8* %attr(0644,root,root) %{_mandir}/man8/ssh-keysign.8*
%endif %endif
%if %{scard} %if %{scard}
@ -435,6 +427,7 @@ fi
%files clients %files clients
%defattr(-,root,root) %defattr(-,root,root)
%attr(0755,root,root) %{_bindir}/ssh %attr(0755,root,root) %{_bindir}/ssh
%attr(0644,root,root) %{_bindir}/.ssh.hmac
%attr(0644,root,root) %{_mandir}/man1/ssh.1* %attr(0644,root,root) %{_mandir}/man1/ssh.1*
%attr(0755,root,root) %{_bindir}/scp %attr(0755,root,root) %{_bindir}/scp
%attr(0644,root,root) %{_mandir}/man1/scp.1* %attr(0644,root,root) %{_mandir}/man1/scp.1*
@ -444,8 +437,11 @@ fi
%attr(0644,root,root) %{_mandir}/man5/ssh_config.5* %attr(0644,root,root) %{_mandir}/man5/ssh_config.5*
%if ! %{rescue} %if ! %{rescue}
%attr(2755,root,nobody) %{_bindir}/ssh-agent %attr(2755,root,nobody) %{_bindir}/ssh-agent
%attr(0644,root,nobody) %{_bindir}/.ssh-agent.hmac
%attr(0755,root,root) %{_bindir}/ssh-add %attr(0755,root,root) %{_bindir}/ssh-add
%attr(0644,root,root) %{_bindir}/.ssh-add.hmac
%attr(0755,root,root) %{_bindir}/ssh-keyscan %attr(0755,root,root) %{_bindir}/ssh-keyscan
%attr(0644,root,root) %{_bindir}/.ssh-keyscan.hmac
%attr(0755,root,root) %{_bindir}/sftp %attr(0755,root,root) %{_bindir}/sftp
%attr(0755,root,root) %{_bindir}/ssh-copy-id %attr(0755,root,root) %{_bindir}/ssh-copy-id
%attr(0644,root,root) %{_mandir}/man1/ssh-agent.1* %attr(0644,root,root) %{_mandir}/man1/ssh-agent.1*
@ -460,6 +456,7 @@ fi
%defattr(-,root,root) %defattr(-,root,root)
%dir %attr(0711,root,root) %{_var}/empty/sshd %dir %attr(0711,root,root) %{_var}/empty/sshd
%attr(0755,root,root) %{_sbindir}/sshd %attr(0755,root,root) %{_sbindir}/sshd
%attr(0644,root,root) %{_sbindir}/.sshd.hmac
%attr(0755,root,root) %{_libexecdir}/openssh/sftp-server %attr(0755,root,root) %{_libexecdir}/openssh/sftp-server
%attr(0644,root,root) %{_mandir}/man5/sshd_config.5* %attr(0644,root,root) %{_mandir}/man5/sshd_config.5*
%attr(0644,root,root) %{_mandir}/man5/moduli.5* %attr(0644,root,root) %{_mandir}/man5/moduli.5*
@ -479,6 +476,11 @@ fi
%endif %endif
%changelog %changelog
* Thu Feb 12 2009 Tomas Mraz <tmraz@redhat.com> - 5.1p1-7
- drop obsolete triggers
- add testing FIPS mode support
- LSBize the initscript (#247014)
* Fri Jan 30 2009 Tomas Mraz <tmraz@redhat.com> - 5.1p1-6 * Fri Jan 30 2009 Tomas Mraz <tmraz@redhat.com> - 5.1p1-6
- enable use of ssl engines (#481100) - enable use of ssl engines (#481100)

View File

@ -1,9 +1,10 @@
#!/bin/bash #!/bin/bash
# #
# Init file for OpenSSH server daemon # sshd Start up the OpenSSH server daemon
# #
# chkconfig: 2345 55 25 # chkconfig: 2345 55 25
# description: OpenSSH server daemon # description: SSH is a protocol for secure remote shell access. \
# This service starts up the OpenSSH server daemon.
# #
# processname: sshd # processname: sshd
# config: /etc/ssh/ssh_host_key # config: /etc/ssh/ssh_host_key
@ -12,6 +13,19 @@
# config: /etc/ssh/sshd_config # config: /etc/ssh/sshd_config
# pidfile: /var/run/sshd.pid # pidfile: /var/run/sshd.pid
### BEGIN INIT INFO
# Provides: sshd
# Required-Start: $local_fs $network $syslog
# Required-Stop: $local_fs $syslog
# Should-Start: $syslog
# Should-Stop: $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start up the OpenSSH server daemon
# Description: SSH is a protocol for secure remote shell access.
# This service starts up the OpenSSH server daemon.
### END INIT INFO
# source function library # source function library
. /etc/rc.d/init.d/functions . /etc/rc.d/init.d/functions
@ -20,6 +34,7 @@
RETVAL=0 RETVAL=0
prog="sshd" prog="sshd"
lockfile=/var/lock/subsys/$prog
# Some functions to make the below more readable # Some functions to make the below more readable
KEYGEN=/usr/bin/ssh-keygen KEYGEN=/usr/bin/ssh-keygen
@ -100,6 +115,8 @@ do_restart_sanity_check()
start() start()
{ {
[ -x $SSHD ] || exit 5
[ -f /etc/ssh/sshd_config ] || exit 6
# Create keys if necessary # Create keys if necessary
if [ "x${AUTOCREATE_SERVER_KEYS}" != xNO ]; then if [ "x${AUTOCREATE_SERVER_KEYS}" != xNO ]; then
do_rsa1_keygen do_rsa1_keygen
@ -110,8 +127,9 @@ start()
echo -n $"Starting $prog: " echo -n $"Starting $prog: "
$SSHD $OPTIONS && success || failure $SSHD $OPTIONS && success || failure
RETVAL=$? RETVAL=$?
[ "$RETVAL" = 0 ] && touch /var/lock/subsys/sshd [ "$RETVAL" = 0 ] && touch $lockfile
echo echo
return $RETVAL
} }
stop() stop()
@ -130,7 +148,7 @@ stop()
killall $prog 2>/dev/null killall $prog 2>/dev/null
trap TERM trap TERM
fi fi
[ "$RETVAL" = 0 ] && rm -f /var/lock/subsys/sshd [ "$RETVAL" = 0 ] && rm -f $lockfile
echo echo
} }
@ -146,37 +164,62 @@ reload()
echo echo
} }
restart() {
stop
start
}
force_reload() {
restart
}
rh_status() {
status -p $PID_FILE openssh-daemon
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in case "$1" in
start) start)
rh_status_q && exit 0
start start
;; ;;
stop) stop)
rh_status_q || exit 0
stop stop
;; ;;
restart) restart)
stop restart
start
;; ;;
reload) reload)
rh_status_q || exit 7
reload reload
;; ;;
condrestart) force-reload)
if [ -f /var/lock/subsys/sshd ] ; then force_reload
;;
condrestart|try-restart)
rh_status_q || exit 0
if [ -f $lockfile ] ; then
do_restart_sanity_check do_restart_sanity_check
if [ "$RETVAL" = 0 ] ; then if [ "$RETVAL" = 0 ] ; then
stop stop
# avoid race # avoid race
sleep 3 sleep 3
start start
else
RETVAL=6
fi fi
fi fi
;; ;;
status) status)
status -p $PID_FILE openssh-daemon rh_status
RETVAL=$? RETVAL=$?
;; ;;
*) *)
echo $"Usage: $0 {start|stop|restart|reload|condrestart|status}" echo $"Usage: $0 {start|stop|restart|reload|force-reload|condrestart|try-restart|status}"
RETVAL=1 RETVAL=2
esac esac
exit $RETVAL exit $RETVAL