|
Dmitry Belyavskiy |
f32b84 |
diff -up openssh-8.6p1/dh.c.fips openssh-8.6p1/dh.c
|
|
Dmitry Belyavskiy |
f32b84 |
--- openssh-8.6p1/dh.c.fips 2021-04-16 05:55:25.000000000 +0200
|
|
Dmitry Belyavskiy |
c9904c |
+++ openssh-8.6p1/dh.c 2021-05-06 12:12:10.107634472 +0200
|
|
Dmitry Belyavskiy |
c9904c |
@@ -36,6 +36,7 @@
|
|
Dmitry Belyavskiy |
c9904c |
|
|
Dmitry Belyavskiy |
c9904c |
#include <openssl/bn.h>
|
|
Dmitry Belyavskiy |
c9904c |
#include <openssl/dh.h>
|
|
Dmitry Belyavskiy |
c9904c |
+#include <openssl/fips.h>
|
|
Dmitry Belyavskiy |
c9904c |
|
|
Dmitry Belyavskiy |
c9904c |
#include "dh.h"
|
|
Dmitry Belyavskiy |
c9904c |
#include "pathnames.h"
|
|
Dmitry Belyavskiy |
f32b84 |
@@ -164,6 +164,12 @@ choose_dh(int min, int wantbits, int max
|
|
Jakub Jelen |
81a703 |
int best, bestcount, which, linenum;
|
|
Jakub Jelen |
81a703 |
struct dhgroup dhg;
|
|
Jakub Jelen |
81a703 |
|
|
Jakub Jelen |
81a703 |
+ if (FIPS_mode()) {
|
|
Dmitry Belyavskiy |
9fd698 |
+ verbose("Using arbitrary primes is not allowed in FIPS mode."
|
|
Jakub Jelen |
81a703 |
+ " Falling back to known groups.");
|
|
Jakub Jelen |
81a703 |
+ return (dh_new_group_fallback(max));
|
|
Jakub Jelen |
81a703 |
+ }
|
|
Jakub Jelen |
81a703 |
+
|
|
Dmitry Belyavskiy |
f32b84 |
if ((f = fopen(get_moduli_filename(), "r")) == NULL) {
|
|
Jakub Jelen |
81a703 |
logit("WARNING: could not open %s (%s), using fixed modulus",
|
|
Dmitry Belyavskiy |
f32b84 |
get_moduli_filename(), strerror(errno));
|
|
Dmitry Belyavskiy |
f32b84 |
@@ -502,4 +508,38 @@ dh_estimate(int bits)
|
|
Jakub Jelen |
81a703 |
return 8192;
|
|
Jakub Jelen |
81a703 |
}
|
|
Jakub Jelen |
81a703 |
|
|
Jakub Jelen |
81a703 |
+/*
|
|
Jakub Jelen |
81a703 |
+ * Compares the received DH parameters with known-good groups,
|
|
Jakub Jelen |
81a703 |
+ * which might be either from group14, group16 or group18.
|
|
Jakub Jelen |
81a703 |
+ */
|
|
Jakub Jelen |
81a703 |
+int
|
|
Jakub Jelen |
81a703 |
+dh_is_known_group(const DH *dh)
|
|
Jakub Jelen |
81a703 |
+{
|
|
Jakub Jelen |
81a703 |
+ const BIGNUM *p, *g;
|
|
Jakub Jelen |
81a703 |
+ const BIGNUM *known_p, *known_g;
|
|
Jakub Jelen |
81a703 |
+ DH *known = NULL;
|
|
Jakub Jelen |
81a703 |
+ int bits = 0, rv = 0;
|
|
Jakub Jelen |
81a703 |
+
|
|
Jakub Jelen |
81a703 |
+ DH_get0_pqg(dh, &p, NULL, &g);
|
|
Jakub Jelen |
81a703 |
+ bits = BN_num_bits(p);
|
|
Jakub Jelen |
81a703 |
+
|
|
Jakub Jelen |
81a703 |
+ if (bits <= 3072) {
|
|
Jakub Jelen |
81a703 |
+ known = dh_new_group14();
|
|
Jakub Jelen |
81a703 |
+ } else if (bits <= 6144) {
|
|
Jakub Jelen |
81a703 |
+ known = dh_new_group16();
|
|
Jakub Jelen |
81a703 |
+ } else {
|
|
Jakub Jelen |
81a703 |
+ known = dh_new_group18();
|
|
Jakub Jelen |
81a703 |
+ }
|
|
Jakub Jelen |
81a703 |
+
|
|
Jakub Jelen |
81a703 |
+ DH_get0_pqg(known, &known_p, NULL, &known_g);
|
|
Jakub Jelen |
81a703 |
+
|
|
Jakub Jelen |
81a703 |
+ if (BN_cmp(g, known_g) == 0 &&
|
|
Jakub Jelen |
81a703 |
+ BN_cmp(p, known_p) == 0) {
|
|
Jakub Jelen |
81a703 |
+ rv = 1;
|
|
Jakub Jelen |
81a703 |
+ }
|
|
Jakub Jelen |
81a703 |
+
|
|
Jakub Jelen |
81a703 |
+ DH_free(known);
|
|
Jakub Jelen |
81a703 |
+ return rv;
|
|
Jakub Jelen |
81a703 |
+}
|
|
Jakub Jelen |
81a703 |
+
|
|
Jakub Jelen |
81a703 |
#endif /* WITH_OPENSSL */
|
|
Dmitry Belyavskiy |
f32b84 |
diff -up openssh-8.6p1/dh.h.fips openssh-8.6p1/dh.h
|
|
Dmitry Belyavskiy |
c9904c |
--- openssh-8.6p1/dh.h.fips 2021-05-06 12:08:36.498926877 +0200
|
|
Dmitry Belyavskiy |
c9904c |
+++ openssh-8.6p1/dh.h 2021-05-06 12:11:28.393298005 +0200
|
|
Dmitry Belyavskiy |
f32b84 |
@@ -45,6 +45,7 @@ DH *dh_new_group_fallback(int);
|
|
Jakub Jelen |
81a703 |
|
|
Jakub Jelen |
81a703 |
int dh_gen_key(DH *, int);
|
|
Jakub Jelen |
81a703 |
int dh_pub_is_valid(const DH *, const BIGNUM *);
|
|
Jakub Jelen |
81a703 |
+int dh_is_known_group(const DH *);
|
|
Jakub Jelen |
81a703 |
|
|
Jakub Jelen |
81a703 |
u_int dh_estimate(int);
|
|
Dmitry Belyavskiy |
f32b84 |
void dh_set_moduli_file(const char *);
|
|
Dmitry Belyavskiy |
089d79 |
diff -up openssh-8.6p1/kex-names.c.fips openssh-8.6p1/kex-names.c
|
|
Dmitry Belyavskiy |
089d79 |
--- openssh-8.6p1/kex-names.c.fips 2021-05-06 12:08:36.489926807 +0200
|
|
Dmitry Belyavskiy |
089d79 |
+++ openssh-8.6p1/kex-names.c 2021-05-06 12:08:36.498926877 +0200
|
|
Dmitry Belyavskiy |
c9904c |
@@ -39,6 +39,7 @@
|
|
Dmitry Belyavskiy |
c9904c |
|
|
Dmitry Belyavskiy |
c9904c |
#ifdef WITH_OPENSSL
|
|
Dmitry Belyavskiy |
c9904c |
#include <openssl/crypto.h>
|
|
Dmitry Belyavskiy |
c9904c |
+#include <openssl/fips.h>
|
|
Dmitry Belyavskiy |
089d79 |
#include <openssl/evp.h>
|
|
Dmitry Belyavskiy |
089d79 |
#endif
|
|
Dmitry Belyavskiy |
089d79 |
|
|
Dmitry Belyavskiy |
f32b84 |
@@ -203,7 +203,10 @@ kex_names_valid(const char *names)
|
|
Petr Lautrbach |
802815 |
for ((p = strsep(&cp, ",")); p && *p != '\0';
|
|
Petr Lautrbach |
802815 |
(p = strsep(&cp, ","))) {
|
|
Petr Lautrbach |
802815 |
if (kex_alg_by_name(p) == NULL) {
|
|
Petr Lautrbach |
802815 |
- error("Unsupported KEX algorithm \"%.100s\"", p);
|
|
Petr Lautrbach |
802815 |
+ if (FIPS_mode())
|
|
Petr Lautrbach |
802815 |
+ error("\"%.100s\" is not allowed in FIPS mode", p);
|
|
Petr Lautrbach |
802815 |
+ else
|
|
Petr Lautrbach |
802815 |
+ error("Unsupported KEX algorithm \"%.100s\"", p);
|
|
Petr Lautrbach |
802815 |
free(s);
|
|
Petr Lautrbach |
802815 |
return 0;
|
|
Petr Lautrbach |
802815 |
}
|
|
Dmitry Belyavskiy |
f32b84 |
diff -up openssh-8.6p1/kexgexc.c.fips openssh-8.6p1/kexgexc.c
|
|
Dmitry Belyavskiy |
f32b84 |
--- openssh-8.6p1/kexgexc.c.fips 2021-04-16 05:55:25.000000000 +0200
|
|
Dmitry Belyavskiy |
c9904c |
+++ openssh-8.6p1/kexgexc.c 2021-05-06 12:08:36.498926877 +0200
|
|
Jakub Jelen |
535d34 |
@@ -28,6 +28,7 @@
|
|
Petr Lautrbach |
802815 |
|
|
Jakub Jelen |
132f8f |
#ifdef WITH_OPENSSL
|
|
Petr Lautrbach |
802815 |
|
|
Dmitry Belyavskiy |
c9904c |
+#include <openssl/fips.h>
|
|
Petr Lautrbach |
802815 |
#include <sys/types.h>
|
|
Petr Lautrbach |
802815 |
|
|
Jakub Jelen |
6cf9b8 |
#include <openssl/dh.h>
|
|
Dmitry Belyavskiy |
f32b84 |
@@ -115,6 +116,10 @@ input_kex_dh_gex_group(int type, u_int32
|
|
Jakub Jelen |
81a703 |
r = SSH_ERR_ALLOC_FAIL;
|
|
Jakub Jelen |
81a703 |
goto out;
|
|
Jakub Jelen |
81a703 |
}
|
|
Jakub Jelen |
81a703 |
+ if (FIPS_mode() && dh_is_known_group(kex->dh) == 0) {
|
|
Jakub Jelen |
81a703 |
+ r = SSH_ERR_INVALID_ARGUMENT;
|
|
Jakub Jelen |
81a703 |
+ goto out;
|
|
Jakub Jelen |
81a703 |
+ }
|
|
Jakub Jelen |
81a703 |
p = g = NULL; /* belong to kex->dh now */
|
|
Jakub Jelen |
81a703 |
|
|
Jakub Jelen |
81a703 |
/* generate and send 'e', client DH public key */
|
|
Dmitry Belyavskiy |
f32b84 |
diff -up openssh-8.6p1/myproposal.h.fips openssh-8.6p1/myproposal.h
|
|
Dmitry Belyavskiy |
f32b84 |
--- openssh-8.6p1/myproposal.h.fips 2021-04-16 05:55:25.000000000 +0200
|
|
Dmitry Belyavskiy |
9fd698 |
+++ openssh-8.6p1/myproposal.h 2021-05-06 12:08:36.498926877 +0200
|
|
Dmitry Belyavskiy |
9fd698 |
@@ -57,6 +57,18 @@
|
|
Dmitry Belyavskiy |
7b76af |
"rsa-sha2-512," \
|
|
Dmitry Belyavskiy |
7b76af |
"rsa-sha2-256"
|
|
Jakub Jelen |
9dbec7 |
|
|
Jakub Jelen |
9dbec7 |
+#define KEX_FIPS_PK_ALG \
|
|
Jakub Jelen |
51f5c1 |
+ "ecdsa-sha2-nistp256-cert-v01@openssh.com," \
|
|
Jakub Jelen |
51f5c1 |
+ "ecdsa-sha2-nistp384-cert-v01@openssh.com," \
|
|
Jakub Jelen |
51f5c1 |
+ "ecdsa-sha2-nistp521-cert-v01@openssh.com," \
|
|
Jakub Jelen |
5eb2d5 |
+ "rsa-sha2-512-cert-v01@openssh.com," \
|
|
Jakub Jelen |
5eb2d5 |
+ "rsa-sha2-256-cert-v01@openssh.com," \
|
|
Jakub Jelen |
51f5c1 |
+ "ecdsa-sha2-nistp256," \
|
|
Jakub Jelen |
51f5c1 |
+ "ecdsa-sha2-nistp384," \
|
|
Jakub Jelen |
51f5c1 |
+ "ecdsa-sha2-nistp521," \
|
|
Jakub Jelen |
9dbec7 |
+ "rsa-sha2-512," \
|
|
Dmitry Belyavskiy |
9fd698 |
+ "rsa-sha2-256"
|
|
Jakub Jelen |
9dbec7 |
+
|
|
Jakub Jelen |
51f5c1 |
#define KEX_SERVER_ENCRYPT \
|
|
Jakub Jelen |
51f5c1 |
"chacha20-poly1305@openssh.com," \
|
|
Jakub Jelen |
51f5c1 |
"aes128-ctr,aes192-ctr,aes256-ctr," \
|
|
Dmitry Belyavskiy |
f32b84 |
@@ -78,6 +92,27 @@
|
|
Jakub Jelen |
13bf5b |
|
|
Jakub Jelen |
13bf5b |
#define KEX_CLIENT_MAC KEX_SERVER_MAC
|
|
Petr Lautrbach |
802815 |
|
|
Petr Lautrbach |
802815 |
+#define KEX_FIPS_ENCRYPT \
|
|
Petr Lautrbach |
802815 |
+ "aes128-ctr,aes192-ctr,aes256-ctr," \
|
|
Petr Lautrbach |
802815 |
+ "aes128-cbc,3des-cbc," \
|
|
Jakub Jelen |
51f5c1 |
+ "aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se," \
|
|
Jakub Jelen |
51f5c1 |
+ "aes128-gcm@openssh.com,aes256-gcm@openssh.com"
|
|
Jakub Jelen |
51f5c1 |
+#define KEX_DEFAULT_KEX_FIPS \
|
|
Jakub Jelen |
51f5c1 |
+ "ecdh-sha2-nistp256," \
|
|
Jakub Jelen |
51f5c1 |
+ "ecdh-sha2-nistp384," \
|
|
Jakub Jelen |
51f5c1 |
+ "ecdh-sha2-nistp521," \
|
|
Jakub Jelen |
51f5c1 |
+ "diffie-hellman-group-exchange-sha256," \
|
|
Jakub Jelen |
51f5c1 |
+ "diffie-hellman-group16-sha512," \
|
|
Jakub Jelen |
51f5c1 |
+ "diffie-hellman-group18-sha512," \
|
|
Jakub Jelen |
eb751f |
+ "diffie-hellman-group14-sha256"
|
|
Jakub Jelen |
51f5c1 |
+#define KEX_FIPS_MAC \
|
|
Petr Lautrbach |
802815 |
+ "hmac-sha1," \
|
|
Petr Lautrbach |
802815 |
+ "hmac-sha2-256," \
|
|
Petr Lautrbach |
802815 |
+ "hmac-sha2-512," \
|
|
Petr Lautrbach |
802815 |
+ "hmac-sha1-etm@openssh.com," \
|
|
Petr Lautrbach |
802815 |
+ "hmac-sha2-256-etm@openssh.com," \
|
|
Petr Lautrbach |
802815 |
+ "hmac-sha2-512-etm@openssh.com"
|
|
Petr Lautrbach |
190035 |
+
|
|
Jakub Jelen |
eaa7af |
/* Not a KEX value, but here so all the algorithm defaults are together */
|
|
Jakub Jelen |
eaa7af |
#define SSH_ALLOWED_CA_SIGALGS \
|
|
Jakub Jelen |
25c16c |
"ssh-ed25519," \
|
|
Dmitry Belyavskiy |
f32b84 |
diff -up openssh-8.6p1/readconf.c.fips openssh-8.6p1/readconf.c
|
|
Dmitry Belyavskiy |
c9904c |
--- openssh-8.6p1/readconf.c.fips 2021-05-06 12:08:36.428926336 +0200
|
|
Dmitry Belyavskiy |
c9904c |
+++ openssh-8.6p1/readconf.c 2021-05-06 12:08:36.499926885 +0200
|
|
Dmitry Belyavskiy |
c9904c |
@@ -39,6 +39,7 @@
|
|
Dmitry Belyavskiy |
c9904c |
#include <string.h>
|
|
Dmitry Belyavskiy |
c9904c |
#include <stdarg.h>
|
|
Dmitry Belyavskiy |
c9904c |
#include <unistd.h>
|
|
Dmitry Belyavskiy |
c9904c |
+#include <openssl/fips.h>
|
|
Dmitry Belyavskiy |
c9904c |
#ifdef USE_SYSTEM_GLOB
|
|
Dmitry Belyavskiy |
c9904c |
# include <glob.h>
|
|
Dmitry Belyavskiy |
c9904c |
#else
|
|
Dmitry Belyavskiy |
f32b84 |
@@ -2538,11 +2538,16 @@ fill_default_options(Options * options)
|
|
Jakub Jelen |
bbf61d |
all_key = sshkey_alg_list(0, 0, 1, ',');
|
|
Jakub Jelen |
eaa7af |
all_sig = sshkey_alg_list(0, 1, 1, ',');
|
|
Jakub Jelen |
51f5c1 |
/* remove unsupported algos from default lists */
|
|
Jakub Jelen |
bd3516 |
- def_cipher = match_filter_allowlist(KEX_CLIENT_ENCRYPT, all_cipher);
|
|
Jakub Jelen |
bd3516 |
- def_mac = match_filter_allowlist(KEX_CLIENT_MAC, all_mac);
|
|
Jakub Jelen |
bd3516 |
- def_kex = match_filter_allowlist(KEX_CLIENT_KEX, all_kex);
|
|
Jakub Jelen |
bd3516 |
- def_key = match_filter_allowlist(KEX_DEFAULT_PK_ALG, all_key);
|
|
Jakub Jelen |
bd3516 |
- def_sig = match_filter_allowlist(SSH_ALLOWED_CA_SIGALGS, all_sig);
|
|
Jakub Jelen |
bd3516 |
+ def_cipher = match_filter_allowlist((FIPS_mode() ?
|
|
Jakub Jelen |
51f5c1 |
+ KEX_FIPS_ENCRYPT : KEX_CLIENT_ENCRYPT), all_cipher);
|
|
Jakub Jelen |
bd3516 |
+ def_mac = match_filter_allowlist((FIPS_mode() ?
|
|
Jakub Jelen |
51f5c1 |
+ KEX_FIPS_MAC : KEX_CLIENT_MAC), all_mac);
|
|
Jakub Jelen |
bd3516 |
+ def_kex = match_filter_allowlist((FIPS_mode() ?
|
|
Jakub Jelen |
51f5c1 |
+ KEX_DEFAULT_KEX_FIPS : KEX_CLIENT_KEX), all_kex);
|
|
Jakub Jelen |
bd3516 |
+ def_key = match_filter_allowlist((FIPS_mode() ?
|
|
Jakub Jelen |
51f5c1 |
+ KEX_FIPS_PK_ALG : KEX_DEFAULT_PK_ALG), all_key);
|
|
Jakub Jelen |
bd3516 |
+ def_sig = match_filter_allowlist((FIPS_mode() ?
|
|
Jakub Jelen |
51f5c1 |
+ KEX_FIPS_PK_ALG : SSH_ALLOWED_CA_SIGALGS), all_sig);
|
|
Jakub Jelen |
51f5c1 |
#define ASSEMBLE(what, defaults, all) \
|
|
Jakub Jelen |
bbf61d |
do { \
|
|
Jakub Jelen |
bbf61d |
if ((r = kex_assemble_names(&options->what, \
|
|
Dmitry Belyavskiy |
f32b84 |
diff -up openssh-8.6p1/sandbox-seccomp-filter.c.fips openssh-8.6p1/sandbox-seccomp-filter.c
|
|
Dmitry Belyavskiy |
c9904c |
--- openssh-8.6p1/sandbox-seccomp-filter.c.fips 2021-05-06 12:08:36.463926606 +0200
|
|
Dmitry Belyavskiy |
c9904c |
+++ openssh-8.6p1/sandbox-seccomp-filter.c 2021-05-06 12:08:36.499926885 +0200
|
|
Dmitry Belyavskiy |
f32b84 |
@@ -160,6 +160,9 @@ static const struct sock_filter preauth_
|
|
Jakub Jelen |
6cf9b8 |
#ifdef __NR_open
|
|
Jakub Jelen |
17b491 |
SC_DENY(__NR_open, EACCES),
|
|
Jakub Jelen |
6cf9b8 |
#endif
|
|
Jakub Jelen |
6cf9b8 |
+#ifdef __NR_socket
|
|
Jakub Jelen |
17b491 |
+ SC_DENY(__NR_socket, EACCES),
|
|
Jakub Jelen |
6cf9b8 |
+#endif
|
|
Jakub Jelen |
6cf9b8 |
#ifdef __NR_openat
|
|
Jakub Jelen |
17b491 |
SC_DENY(__NR_openat, EACCES),
|
|
Jakub Jelen |
6cf9b8 |
#endif
|
|
Dmitry Belyavskiy |
f32b84 |
diff -up openssh-8.6p1/servconf.c.fips openssh-8.6p1/servconf.c
|
|
Dmitry Belyavskiy |
c9904c |
--- openssh-8.6p1/servconf.c.fips 2021-05-06 12:08:36.455926545 +0200
|
|
Dmitry Belyavskiy |
c9904c |
+++ openssh-8.6p1/servconf.c 2021-05-06 12:08:36.500926893 +0200
|
|
Dmitry Belyavskiy |
c9904c |
@@ -38,6 +38,7 @@
|
|
Dmitry Belyavskiy |
c9904c |
#include <limits.h>
|
|
Dmitry Belyavskiy |
c9904c |
#include <stdarg.h>
|
|
Dmitry Belyavskiy |
c9904c |
#include <errno.h>
|
|
Dmitry Belyavskiy |
c9904c |
+#include <openssl/fips.h>
|
|
Dmitry Belyavskiy |
c9904c |
#ifdef HAVE_UTIL_H
|
|
Dmitry Belyavskiy |
c9904c |
#include <util.h>
|
|
Dmitry Belyavskiy |
c9904c |
#endif
|
|
Dmitry Belyavskiy |
f32b84 |
@@ -226,11 +226,16 @@ assemble_algorithms(ServerOptions *o)
|
|
Jakub Jelen |
bbf61d |
all_key = sshkey_alg_list(0, 0, 1, ',');
|
|
Jakub Jelen |
eaa7af |
all_sig = sshkey_alg_list(0, 1, 1, ',');
|
|
Jakub Jelen |
51f5c1 |
/* remove unsupported algos from default lists */
|
|
Jakub Jelen |
bd3516 |
- def_cipher = match_filter_allowlist(KEX_SERVER_ENCRYPT, all_cipher);
|
|
Jakub Jelen |
bd3516 |
- def_mac = match_filter_allowlist(KEX_SERVER_MAC, all_mac);
|
|
Jakub Jelen |
bd3516 |
- def_kex = match_filter_allowlist(KEX_SERVER_KEX, all_kex);
|
|
Jakub Jelen |
bd3516 |
- def_key = match_filter_allowlist(KEX_DEFAULT_PK_ALG, all_key);
|
|
Jakub Jelen |
bd3516 |
- def_sig = match_filter_allowlist(SSH_ALLOWED_CA_SIGALGS, all_sig);
|
|
Jakub Jelen |
bd3516 |
+ def_cipher = match_filter_allowlist((FIPS_mode() ?
|
|
Jakub Jelen |
51f5c1 |
+ KEX_FIPS_ENCRYPT : KEX_SERVER_ENCRYPT), all_cipher);
|
|
Jakub Jelen |
bd3516 |
+ def_mac = match_filter_allowlist((FIPS_mode() ?
|
|
Jakub Jelen |
51f5c1 |
+ KEX_FIPS_MAC : KEX_SERVER_MAC), all_mac);
|
|
Jakub Jelen |
bd3516 |
+ def_kex = match_filter_allowlist((FIPS_mode() ?
|
|
Jakub Jelen |
51f5c1 |
+ KEX_DEFAULT_KEX_FIPS : KEX_SERVER_KEX), all_kex);
|
|
Jakub Jelen |
bd3516 |
+ def_key = match_filter_allowlist((FIPS_mode() ?
|
|
Jakub Jelen |
51f5c1 |
+ KEX_FIPS_PK_ALG : KEX_DEFAULT_PK_ALG), all_key);
|
|
Jakub Jelen |
bd3516 |
+ def_sig = match_filter_allowlist((FIPS_mode() ?
|
|
Jakub Jelen |
51f5c1 |
+ KEX_FIPS_PK_ALG : SSH_ALLOWED_CA_SIGALGS), all_sig);
|
|
Jakub Jelen |
51f5c1 |
#define ASSEMBLE(what, defaults, all) \
|
|
Jakub Jelen |
bbf61d |
do { \
|
|
Jakub Jelen |
51f5c1 |
if ((r = kex_assemble_names(&o->what, defaults, all)) != 0) \
|
|
Dmitry Belyavskiy |
f32b84 |
diff -up openssh-8.6p1/ssh.c.fips openssh-8.6p1/ssh.c
|
|
Dmitry Belyavskiy |
c9904c |
--- openssh-8.6p1/ssh.c.fips 2021-05-06 12:08:36.467926637 +0200
|
|
Dmitry Belyavskiy |
c9904c |
+++ openssh-8.6p1/ssh.c 2021-05-06 12:08:36.500926893 +0200
|
|
Dmitry Belyavskiy |
f32b84 |
@@ -77,6 +77,7 @@
|
|
Petr Lautrbach |
802815 |
#include <openssl/evp.h>
|
|
Petr Lautrbach |
802815 |
#include <openssl/err.h>
|
|
Petr Lautrbach |
190035 |
#endif
|
|
Dmitry Belyavskiy |
c9904c |
+#include <openssl/fips.h>
|
|
Petr Lautrbach |
802815 |
#include "openbsd-compat/openssl-compat.h"
|
|
Petr Lautrbach |
802815 |
#include "openbsd-compat/sys-queue.h"
|
|
Petr Lautrbach |
802815 |
|
|
Dmitry Belyavskiy |
f32b84 |
@@ -1516,6 +1517,10 @@ main(int ac, char **av)
|
|
Jakub Jelen |
fbd5f1 |
exit(0);
|
|
Jakub Jelen |
fbd5f1 |
}
|
|
Dmitry Belyavskiy |
f32b84 |
|
|
Petr Lautrbach |
802815 |
+ if (FIPS_mode()) {
|
|
Jakub Jelen |
ee9cb0 |
+ debug("FIPS mode initialized");
|
|
Petr Lautrbach |
802815 |
+ }
|
|
Dmitry Belyavskiy |
f32b84 |
+
|
|
Jakub Jelen |
fbd5f1 |
/* Expand SecurityKeyProvider if it refers to an environment variable */
|
|
Jakub Jelen |
fbd5f1 |
if (options.sk_provider != NULL && *options.sk_provider == '$' &&
|
|
Dmitry Belyavskiy |
f32b84 |
strlen(options.sk_provider) > 1) {
|
|
Dmitry Belyavskiy |
f32b84 |
diff -up openssh-8.6p1/sshconnect2.c.fips openssh-8.6p1/sshconnect2.c
|
|
Dmitry Belyavskiy |
c9904c |
--- openssh-8.6p1/sshconnect2.c.fips 2021-05-06 12:08:36.485926777 +0200
|
|
Dmitry Belyavskiy |
c9904c |
+++ openssh-8.6p1/sshconnect2.c 2021-05-06 12:08:36.501926900 +0200
|
|
Dmitry Belyavskiy |
f32b84 |
@@ -45,6 +45,8 @@
|
|
Petr Lautrbach |
802815 |
#include <vis.h>
|
|
Petr Lautrbach |
802815 |
#endif
|
|
Petr Lautrbach |
802815 |
|
|
Dmitry Belyavskiy |
c9904c |
+#include <openssl/fips.h>
|
|
Petr Lautrbach |
802815 |
+
|
|
Petr Lautrbach |
802815 |
#include "openbsd-compat/sys-queue.h"
|
|
Petr Lautrbach |
802815 |
|
|
Petr Lautrbach |
802815 |
#include "xmalloc.h"
|
|
Dmitry Belyavskiy |
f32b84 |
@@ -269,36 +271,41 @@ ssh_kex2(struct ssh *ssh, char *host, st
|
|
Petr Lautrbach |
802815 |
|
|
Jakub Jelen |
def1de |
#if defined(GSSAPI) && defined(WITH_OPENSSL)
|
|
Petr Lautrbach |
802815 |
if (options.gss_keyex) {
|
|
Jakub Jelen |
def1de |
- /* Add the GSSAPI mechanisms currently supported on this
|
|
Petr Lautrbach |
802815 |
- * client to the key exchange algorithm proposal */
|
|
Jakub Jelen |
def1de |
- orig = myproposal[PROPOSAL_KEX_ALGS];
|
|
Jakub Jelen |
132f8f |
-
|
|
Jakub Jelen |
57ba1b |
- if (options.gss_server_identity) {
|
|
Jakub Jelen |
def1de |
- gss_host = xstrdup(options.gss_server_identity);
|
|
Jakub Jelen |
57ba1b |
- } else if (options.gss_trust_dns) {
|
|
Jakub Jelen |
def1de |
- gss_host = remote_hostname(ssh);
|
|
Jakub Jelen |
57ba1b |
- /* Fall back to specified host if we are using proxy command
|
|
Jakub Jelen |
57ba1b |
- * and can not use DNS on that socket */
|
|
Jakub Jelen |
57ba1b |
- if (strcmp(gss_host, "UNKNOWN") == 0) {
|
|
Jakub Jelen |
57ba1b |
- free(gss_host);
|
|
Petr Lautrbach |
802815 |
+ if (FIPS_mode()) {
|
|
Petr Lautrbach |
802815 |
+ logit("Disabling GSSAPIKeyExchange. Not usable in FIPS mode");
|
|
Petr Lautrbach |
802815 |
+ options.gss_keyex = 0;
|
|
Petr Lautrbach |
802815 |
+ } else {
|
|
Petr Lautrbach |
802815 |
+ /* Add the GSSAPI mechanisms currently supported on this
|
|
Petr Lautrbach |
802815 |
+ * client to the key exchange algorithm proposal */
|
|
Jakub Jelen |
def1de |
+ orig = myproposal[PROPOSAL_KEX_ALGS];
|
|
Jakub Jelen |
132f8f |
+
|
|
Jakub Jelen |
57ba1b |
+ if (options.gss_server_identity) {
|
|
Jakub Jelen |
def1de |
+ gss_host = xstrdup(options.gss_server_identity);
|
|
Jakub Jelen |
57ba1b |
+ } else if (options.gss_trust_dns) {
|
|
Jakub Jelen |
def1de |
+ gss_host = remote_hostname(ssh);
|
|
Jakub Jelen |
57ba1b |
+ /* Fall back to specified host if we are using proxy command
|
|
Jakub Jelen |
57ba1b |
+ * and can not use DNS on that socket */
|
|
Jakub Jelen |
57ba1b |
+ if (strcmp(gss_host, "UNKNOWN") == 0) {
|
|
Jakub Jelen |
57ba1b |
+ free(gss_host);
|
|
Jakub Jelen |
57ba1b |
+ gss_host = xstrdup(host);
|
|
Jakub Jelen |
57ba1b |
+ }
|
|
Jakub Jelen |
57ba1b |
+ } else {
|
|
Dmitry Belyavskiy |
f32b84 |
gss_host = xstrdup(host);
|
|
Dmitry Belyavskiy |
f32b84 |
}
|
|
Dmitry Belyavskiy |
f32b84 |
- } else {
|
|
Dmitry Belyavskiy |
f32b84 |
- gss_host = xstrdup(host);
|
|
Dmitry Belyavskiy |
f32b84 |
- }
|
|
Dmitry Belyavskiy |
f32b84 |
|
|
Dmitry Belyavskiy |
f32b84 |
- gss = ssh_gssapi_client_mechanisms(gss_host,
|
|
Dmitry Belyavskiy |
f32b84 |
- options.gss_client_identity, options.gss_kex_algorithms);
|
|
Dmitry Belyavskiy |
f32b84 |
- if (gss) {
|
|
Dmitry Belyavskiy |
f32b84 |
- debug("Offering GSSAPI proposal: %s", gss);
|
|
Dmitry Belyavskiy |
f32b84 |
- xasprintf(&myproposal[PROPOSAL_KEX_ALGS],
|
|
Dmitry Belyavskiy |
f32b84 |
- "%s,%s", gss, orig);
|
|
Dmitry Belyavskiy |
f32b84 |
-
|
|
Dmitry Belyavskiy |
f32b84 |
- /* If we've got GSSAPI algorithms, then we also support the
|
|
Dmitry Belyavskiy |
f32b84 |
- * 'null' hostkey, as a last resort */
|
|
Dmitry Belyavskiy |
f32b84 |
- orig = myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS];
|
|
Dmitry Belyavskiy |
f32b84 |
- xasprintf(&myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS],
|
|
Dmitry Belyavskiy |
f32b84 |
- "%s,null", orig);
|
|
Jakub Jelen |
bc4ef0 |
+ gss = ssh_gssapi_client_mechanisms(gss_host,
|
|
Jakub Jelen |
bc4ef0 |
+ options.gss_client_identity, options.gss_kex_algorithms);
|
|
Petr Lautrbach |
802815 |
+ if (gss) {
|
|
Petr Lautrbach |
802815 |
+ debug("Offering GSSAPI proposal: %s", gss);
|
|
Jakub Jelen |
def1de |
+ xasprintf(&myproposal[PROPOSAL_KEX_ALGS],
|
|
Petr Lautrbach |
802815 |
+ "%s,%s", gss, orig);
|
|
Jakub Jelen |
def1de |
+
|
|
Jakub Jelen |
def1de |
+ /* If we've got GSSAPI algorithms, then we also support the
|
|
Jakub Jelen |
def1de |
+ * 'null' hostkey, as a last resort */
|
|
Jakub Jelen |
def1de |
+ orig = myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS];
|
|
Jakub Jelen |
def1de |
+ xasprintf(&myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS],
|
|
Jakub Jelen |
def1de |
+ "%s,null", orig);
|
|
Petr Lautrbach |
802815 |
+ }
|
|
Petr Lautrbach |
802815 |
}
|
|
Petr Lautrbach |
802815 |
}
|
|
Petr Lautrbach |
802815 |
#endif
|
|
Dmitry Belyavskiy |
f32b84 |
diff -up openssh-8.6p1/sshd.c.fips openssh-8.6p1/sshd.c
|
|
Dmitry Belyavskiy |
c9904c |
--- openssh-8.6p1/sshd.c.fips 2021-05-06 12:08:36.493926838 +0200
|
|
Dmitry Belyavskiy |
c9904c |
+++ openssh-8.6p1/sshd.c 2021-05-06 12:13:56.501492639 +0200
|
|
Petr Lautrbach |
190035 |
@@ -66,6 +66,7 @@
|
|
Dmitry Belyavskiy |
03150f |
#endif
|
|
Petr Lautrbach |
190035 |
#include <pwd.h>
|
|
Petr Lautrbach |
190035 |
#include <signal.h>
|
|
Petr Lautrbach |
190035 |
+#include <syslog.h>
|
|
Petr Lautrbach |
190035 |
#include <stdarg.h>
|
|
Petr Lautrbach |
190035 |
#include <stdio.h>
|
|
Petr Lautrbach |
190035 |
#include <stdlib.h>
|
|
Jakub Jelen |
eb546e |
@@ -77,6 +78,7 @@
|
|
Dmitry Belyavskiy |
089d79 |
#ifdef WITH_OPENSSL
|
|
Dmitry Belyavskiy |
089d79 |
#include <openssl/evp.h>
|
|
Petr Lautrbach |
802815 |
#include <openssl/rand.h>
|
|
Dmitry Belyavskiy |
c9904c |
+#include <openssl/fips.h>
|
|
Petr Lautrbach |
802815 |
#include "openbsd-compat/openssl-compat.h"
|
|
Petr Lautrbach |
190035 |
#endif
|
|
Petr Lautrbach |
802815 |
|
|
Dmitry Belyavskiy |
9fd698 |
@@ -1931,6 +1931,13 @@ main(int ac, char **av)
|
|
Dmitry Belyavskiy |
9fd698 |
&key, NULL)) != 0 && r != SSH_ERR_SYSTEM_ERROR)
|
|
Dmitry Belyavskiy |
9fd698 |
do_log2_r(r, ll, "Unable to load host key \"%s\"",
|
|
Dmitry Belyavskiy |
9fd698 |
options.host_key_files[i]);
|
|
Dmitry Belyavskiy |
9fd698 |
+ if (FIPS_mode() && key != NULL && (sshkey_type_plain(key->type) == KEY_ED25519_SK
|
|
Dmitry Belyavskiy |
9fd698 |
+ || sshkey_type_plain(key->type) == KEY_ED25519)) {
|
|
Dmitry Belyavskiy |
9fd698 |
+ logit_f("sshd: Ed25519 keys are not allowed in FIPS mode, skipping %s", options.host_key_files[i]);
|
|
Dmitry Belyavskiy |
9fd698 |
+ sshkey_free(key);
|
|
Dmitry Belyavskiy |
9fd698 |
+ key = NULL;
|
|
Dmitry Belyavskiy |
9fd698 |
+ continue;
|
|
Dmitry Belyavskiy |
9fd698 |
+ }
|
|
Dmitry Belyavskiy |
9fd698 |
if (sshkey_is_sk(key) &&
|
|
Dmitry Belyavskiy |
9fd698 |
key->sk_flags & SSH_SK_USER_PRESENCE_REQD) {
|
|
Dmitry Belyavskiy |
9fd698 |
debug("host key %s requires user presence, ignoring",
|
|
Dmitry Belyavskiy |
f32b84 |
@@ -2110,6 +2113,10 @@ main(int ac, char **av)
|
|
Petr Lautrbach |
802815 |
/* Reinitialize the log (because of the fork above). */
|
|
Petr Lautrbach |
802815 |
log_init(__progname, options.log_level, options.log_facility, log_stderr);
|
|
Petr Lautrbach |
802815 |
|
|
Petr Lautrbach |
802815 |
+ if (FIPS_mode()) {
|
|
Jakub Jelen |
ee9cb0 |
+ debug("FIPS mode initialized");
|
|
Petr Lautrbach |
802815 |
+ }
|
|
Petr Lautrbach |
802815 |
+
|
|
Dmitry Belyavskiy |
f32b84 |
/*
|
|
Dmitry Belyavskiy |
f32b84 |
* Chdir to the root directory so that the current disk can be
|
|
Dmitry Belyavskiy |
f32b84 |
* unmounted if desired.
|
|
Dmitry Belyavskiy |
089d79 |
diff -up openssh-8.6p1/sshd-session.c.fips openssh-8.6p1/sshd-session.c
|
|
Dmitry Belyavskiy |
089d79 |
--- a/sshd-session.c.fips 2021-05-06 12:08:36.493926838 +0200
|
|
Dmitry Belyavskiy |
089d79 |
+++ b/sshd-session.c 2021-05-06 12:13:56.501492639 +0200
|
|
Dmitry Belyavskiy |
089d79 |
@@ -78,6 +79,7 @@
|
|
Dmitry Belyavskiy |
089d79 |
#include <openssl/bn.h>
|
|
Dmitry Belyavskiy |
089d79 |
#include <openssl/evp.h>
|
|
Dmitry Belyavskiy |
089d79 |
#include <openssl/rand.h>
|
|
Dmitry Belyavskiy |
089d79 |
+#include <openssl/fips.h>
|
|
Dmitry Belyavskiy |
089d79 |
#include "openbsd-compat/openssl-compat.h"
|
|
Dmitry Belyavskiy |
089d79 |
#endif
|
|
Dmitry Belyavskiy |
089d79 |
|
|
Dmitry Belyavskiy |
089d79 |
@@ -2506,10 +2513,14 @@ do_ssh2_kex(struct ssh *ssh)
|
|
Petr Lautrbach |
802815 |
if (strlen(myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS]) == 0)
|
|
Petr Lautrbach |
802815 |
orig = NULL;
|
|
Petr Lautrbach |
802815 |
|
|
Petr Lautrbach |
802815 |
- if (options.gss_keyex)
|
|
Petr Lautrbach |
802815 |
- gss = ssh_gssapi_server_mechanisms();
|
|
Petr Lautrbach |
802815 |
- else
|
|
Petr Lautrbach |
802815 |
- gss = NULL;
|
|
Petr Lautrbach |
802815 |
+ if (options.gss_keyex) {
|
|
Petr Lautrbach |
802815 |
+ if (FIPS_mode()) {
|
|
Petr Lautrbach |
802815 |
+ logit("Disabling GSSAPIKeyExchange. Not usable in FIPS mode");
|
|
Petr Lautrbach |
802815 |
+ options.gss_keyex = 0;
|
|
Petr Lautrbach |
802815 |
+ } else {
|
|
Petr Lautrbach |
802815 |
+ gss = ssh_gssapi_server_mechanisms();
|
|
Petr Lautrbach |
802815 |
+ }
|
|
Petr Lautrbach |
802815 |
+ }
|
|
Petr Lautrbach |
802815 |
|
|
Petr Lautrbach |
802815 |
if (gss && orig)
|
|
Petr Lautrbach |
802815 |
xasprintf(&newstr, "%s,%s", gss, orig);
|
|
Dmitry Belyavskiy |
f32b84 |
diff -up openssh-8.6p1/sshkey.c.fips openssh-8.6p1/sshkey.c
|
|
Dmitry Belyavskiy |
c9904c |
--- openssh-8.6p1/sshkey.c.fips 2021-05-06 12:08:36.493926838 +0200
|
|
Dmitry Belyavskiy |
c9904c |
+++ openssh-8.6p1/sshkey.c 2021-05-06 12:08:36.502926908 +0200
|
|
Norbert Pocs |
fb40f0 |
@@ -36,6 +36,7 @@
|
|
Petr Lautrbach |
190035 |
#include <openssl/pem.h>
|
|
Norbert Pocs |
fb40f0 |
#include <openssl/core_names.h>
|
|
Norbert Pocs |
fb40f0 |
#include <openssl/param_build.h>
|
|
Dmitry Belyavskiy |
c9904c |
+#include <openssl/fips.h>
|
|
Jakub Jelen |
132f8f |
#endif
|
|
Petr Lautrbach |
190035 |
|
|
Petr Lautrbach |
190035 |
#include "crypto_api.h"
|
|
Jakub Jelen |
44e203 |
@@ -57,6 +58,7 @@
|
|
Jakub Jelen |
36fef5 |
#define SSHKEY_INTERNAL
|
|
Jakub Jelen |
84d398 |
#include "sshkey.h"
|
|
Jakub Jelen |
84d398 |
#include "match.h"
|
|
Jakub Jelen |
9dbec7 |
+#include "log.h"
|
|
Jakub Jelen |
51f5c1 |
#include "ssh-sk.h"
|
|
Jakub Jelen |
84d398 |
|
|
Jakub Jelen |
36fef5 |
#ifdef WITH_XMSS
|
|
Dmitry Belyavskiy |
9fd698 |
@@ -285,6 +285,18 @@ sshkey_alg_list(int certs_only, int plai
|
|
Dmitry Belyavskiy |
f561c6 |
impl = keyimpls[i];
|
|
Dmitry Belyavskiy |
f561c6 |
if (impl->name == NULL || impl->type == KEY_NULL)
|
|
Dmitry Belyavskiy |
9fd698 |
continue;
|
|
Dmitry Belyavskiy |
9fd698 |
+ if (FIPS_mode()) {
|
|
Dmitry Belyavskiy |
f561c6 |
+ switch (impl->type) {
|
|
Dmitry Belyavskiy |
9fd698 |
+ case KEY_ED25519:
|
|
Dmitry Belyavskiy |
9fd698 |
+ case KEY_ED25519_SK:
|
|
Dmitry Belyavskiy |
9fd698 |
+ case KEY_ED25519_CERT:
|
|
Dmitry Belyavskiy |
9fd698 |
+ case KEY_ED25519_SK_CERT:
|
|
Dmitry Belyavskiy |
9fd698 |
+ continue;
|
|
Dmitry Belyavskiy |
9fd698 |
+ break;
|
|
Dmitry Belyavskiy |
9fd698 |
+ default:
|
|
Dmitry Belyavskiy |
9fd698 |
+ break;
|
|
Dmitry Belyavskiy |
9fd698 |
+ }
|
|
Dmitry Belyavskiy |
9fd698 |
+ }
|
|
Dmitry Belyavskiy |
f561c6 |
if (!include_sigonly && impl->sigonly)
|
|
Dmitry Belyavskiy |
9fd698 |
continue;
|
|
Dmitry Belyavskiy |
f561c6 |
if ((certs_only && !impl->cert) || (plain_only && impl->cert))
|
|
Dmitry Belyavskiy |
9fd698 |
@@ -1503,6 +1503,20 @@ sshkey_read(struct sshkey *ret, char **c
|
|
Dmitry Belyavskiy |
9fd698 |
return SSH_ERR_EC_CURVE_MISMATCH;
|
|
Petr Lautrbach |
190035 |
}
|
|
Dmitry Belyavskiy |
9fd698 |
|
|
Dmitry Belyavskiy |
9fd698 |
+ switch (type) {
|
|
Dmitry Belyavskiy |
9fd698 |
+ case KEY_ED25519:
|
|
Dmitry Belyavskiy |
9fd698 |
+ case KEY_ED25519_SK:
|
|
Dmitry Belyavskiy |
9fd698 |
+ case KEY_ED25519_CERT:
|
|
Dmitry Belyavskiy |
9fd698 |
+ case KEY_ED25519_SK_CERT:
|
|
Dmitry Belyavskiy |
9fd698 |
+ if (FIPS_mode()) {
|
|
Dmitry Belyavskiy |
9fd698 |
+ sshkey_free(k);
|
|
Dmitry Belyavskiy |
9fd698 |
+ logit_f("Ed25519 keys are not allowed in FIPS mode");
|
|
Dmitry Belyavskiy |
9fd698 |
+ return SSH_ERR_INVALID_ARGUMENT;
|
|
Dmitry Belyavskiy |
9fd698 |
+ }
|
|
Dmitry Belyavskiy |
9fd698 |
+ break;
|
|
Dmitry Belyavskiy |
9fd698 |
+ default:
|
|
Dmitry Belyavskiy |
9fd698 |
+ break;
|
|
Dmitry Belyavskiy |
9fd698 |
+ }
|
|
Dmitry Belyavskiy |
9fd698 |
/* Fill in ret from parsed key */
|
|
Dmitry Belyavskiy |
f561c6 |
sshkey_free_contents(ret);
|
|
Dmitry Belyavskiy |
f561c6 |
*ret = *k;
|
|
Dmitry Belyavskiy |
9fd698 |
@@ -2916,6 +2916,11 @@ sshkey_sign(struct sshkey *key,
|
|
Dmitry Belyavskiy |
f561c6 |
*lenp = 0;
|
|
Dmitry Belyavskiy |
f561c6 |
if (datalen > SSH_KEY_MAX_SIGN_DATA_SIZE)
|
|
Dmitry Belyavskiy |
f561c6 |
return SSH_ERR_INVALID_ARGUMENT;
|
|
Dmitry Belyavskiy |
089d79 |
+ if (FIPS_mode() && ((key->type == KEY_ED25519_SK) || (key->type == KEY_ED25519_SK_CERT))) {
|
|
Dmitry Belyavskiy |
089d79 |
+ logit_f("Ed25519 keys are not allowed in FIPS mode");
|
|
Dmitry Belyavskiy |
089d79 |
+ return SSH_ERR_INVALID_ARGUMENT;
|
|
Dmitry Belyavskiy |
089d79 |
+ }
|
|
Dmitry Belyavskiy |
089d79 |
+ /* Fallthrough */
|
|
Dmitry Belyavskiy |
f561c6 |
if ((impl = sshkey_impl_from_key(key)) == NULL)
|
|
Dmitry Belyavskiy |
f561c6 |
return SSH_ERR_KEY_TYPE_UNKNOWN;
|
|
Dmitry Belyavskiy |
f561c6 |
if ((r = sshkey_unshield_private(key)) != 0)
|
|
Dmitry Belyavskiy |
9fd698 |
@@ -2973,6 +2978,10 @@ sshkey_verify(const struct sshkey *key,
|
|
Dmitry Belyavskiy |
f561c6 |
*detailsp = NULL;
|
|
Dmitry Belyavskiy |
f561c6 |
if (siglen == 0 || dlen > SSH_KEY_MAX_SIGN_DATA_SIZE)
|
|
Dmitry Belyavskiy |
f561c6 |
return SSH_ERR_INVALID_ARGUMENT;
|
|
Dmitry Belyavskiy |
089d79 |
+ if (FIPS_mode() && ((key->type == KEY_ED25519_SK) || (key->type == KEY_ED25519_SK_CERT))) {
|
|
Dmitry Belyavskiy |
089d79 |
+ logit_f("Ed25519 keys are not allowed in FIPS mode");
|
|
Dmitry Belyavskiy |
089d79 |
+ return SSH_ERR_INVALID_ARGUMENT;
|
|
Dmitry Belyavskiy |
089d79 |
+ }
|
|
Dmitry Belyavskiy |
f561c6 |
if ((impl = sshkey_impl_from_key(key)) == NULL)
|
|
Dmitry Belyavskiy |
f561c6 |
return SSH_ERR_KEY_TYPE_UNKNOWN;
|
|
Dmitry Belyavskiy |
f561c6 |
return impl->funcs->verify(key, sig, siglen, data, dlen,
|
|
Dmitry Belyavskiy |
f32b84 |
diff -up openssh-8.6p1/ssh-keygen.c.fips openssh-8.6p1/ssh-keygen.c
|
|
Dmitry Belyavskiy |
c9904c |
--- openssh-8.6p1/ssh-keygen.c.fips 2021-05-06 12:08:36.467926637 +0200
|
|
Dmitry Belyavskiy |
c9904c |
+++ openssh-8.6p1/ssh-keygen.c 2021-05-06 12:08:36.503926916 +0200
|
|
Dmitry Belyavskiy |
c9904c |
@@ -20,6 +20,7 @@
|
|
Dmitry Belyavskiy |
c9904c |
|
|
Dmitry Belyavskiy |
c9904c |
#ifdef WITH_OPENSSL
|
|
Dmitry Belyavskiy |
c9904c |
#include <openssl/evp.h>
|
|
Dmitry Belyavskiy |
c9904c |
+#include <openssl/fips.h>
|
|
Dmitry Belyavskiy |
c9904c |
#include <openssl/pem.h>
|
|
Dmitry Belyavskiy |
c9904c |
#include "openbsd-compat/openssl-compat.h"
|
|
Dmitry Belyavskiy |
c9904c |
#endif
|
|
Dmitry Belyavskiy |
1c01ac |
@@ -69,6 +69,7 @@
|
|
Dmitry Belyavskiy |
1c01ac |
#include "cipher.h"
|
|
Dmitry Belyavskiy |
1c01ac |
|
|
Dmitry Belyavskiy |
1c01ac |
#define DEFAULT_KEY_TYPE_NAME "ed25519"
|
|
Dmitry Belyavskiy |
1c01ac |
+#define FIPS_DEFAULT_KEY_TYPE_NAME "rsa"
|
|
Dmitry Belyavskiy |
1c01ac |
|
|
Dmitry Belyavskiy |
1c01ac |
/*
|
|
Dmitry Belyavskiy |
1c01ac |
* Default number of bits in the RSA, DSA and ECDSA keys. These value can be
|
|
Dmitry Belyavskiy |
f32b84 |
@@ -205,6 +205,12 @@ type_bits_valid(int type, const char *na
|
|
Jakub Jelen |
36fef5 |
#endif
|
|
Jakub Jelen |
36fef5 |
}
|
|
Jakub Jelen |
36fef5 |
#ifdef WITH_OPENSSL
|
|
Jakub Jelen |
9dbec7 |
+ if (FIPS_mode()) {
|
|
Jakub Jelen |
9dbec7 |
+ if (type == KEY_DSA)
|
|
Jakub Jelen |
9dbec7 |
+ fatal("DSA keys are not allowed in FIPS mode");
|
|
Dmitry Belyavskiy |
9fd698 |
+ if (type == KEY_ED25519 || type == KEY_ED25519_SK)
|
|
Jakub Jelen |
9dbec7 |
+ fatal("ED25519 keys are not allowed in FIPS mode");
|
|
Jakub Jelen |
9dbec7 |
+ }
|
|
Jakub Jelen |
5b55d0 |
switch (type) {
|
|
Jakub Jelen |
5b55d0 |
case KEY_DSA:
|
|
Jakub Jelen |
5b55d0 |
if (*bitsp != 1024)
|
|
Dmitry Belyavskiy |
1c01ac |
@@ -266,7 +267,7 @@ ask_filename(struct passwd *pw, const ch
|
|
Dmitry Belyavskiy |
1c01ac |
char *name = NULL;
|
|
Dmitry Belyavskiy |
1c01ac |
|
|
Dmitry Belyavskiy |
1c01ac |
if (key_type_name == NULL)
|
|
Dmitry Belyavskiy |
1c01ac |
- name = _PATH_SSH_CLIENT_ID_ED25519;
|
|
Dmitry Belyavskiy |
1c01ac |
+ name = FIPS_mode() ? _PATH_SSH_CLIENT_ID_RSA : _PATH_SSH_CLIENT_ID_ED25519;
|
|
Dmitry Belyavskiy |
1c01ac |
else {
|
|
Dmitry Belyavskiy |
1c01ac |
switch (sshkey_type_from_name(key_type_name)) {
|
|
Dmitry Belyavskiy |
1c01ac |
#ifdef WITH_DSA
|
|
Dmitry Belyavskiy |
f32b84 |
@@ -1098,9 +1104,17 @@ do_gen_all_hostkeys(struct passwd *pw)
|
|
Jakub Jelen |
d19ba9 |
first = 1;
|
|
Jakub Jelen |
d19ba9 |
printf("%s: generating new host keys: ", __progname);
|
|
Jakub Jelen |
d19ba9 |
}
|
|
Jakub Jelen |
d19ba9 |
+ type = sshkey_type_from_name(key_types[i].key_type);
|
|
Jakub Jelen |
d19ba9 |
+
|
|
Jakub Jelen |
d19ba9 |
+ /* Skip the keys that are not supported in FIPS mode */
|
|
Jakub Jelen |
d19ba9 |
+ if (FIPS_mode() && (type == KEY_DSA || type == KEY_ED25519)) {
|
|
Jakub Jelen |
d19ba9 |
+ logit("Skipping %s key in FIPS mode",
|
|
Jakub Jelen |
d19ba9 |
+ key_types[i].key_type_display);
|
|
Jakub Jelen |
d19ba9 |
+ goto next;
|
|
Jakub Jelen |
d19ba9 |
+ }
|
|
Jakub Jelen |
d19ba9 |
+
|
|
Jakub Jelen |
d19ba9 |
printf("%s ", key_types[i].key_type_display);
|
|
Jakub Jelen |
d19ba9 |
fflush(stdout);
|
|
Jakub Jelen |
d19ba9 |
- type = sshkey_type_from_name(key_types[i].key_type);
|
|
Jakub Jelen |
d19ba9 |
if ((fd = mkstemp(prv_tmp)) == -1) {
|
|
Jakub Jelen |
5cd955 |
error("Could not save your private key in %s: %s",
|
|
Dmitry Belyavskiy |
f32b84 |
prv_tmp, strerror(errno));
|
|
Dmitry Belyavskiy |
1c01ac |
@@ -3830,7 +3831,7 @@ main(int argc, char **argv)
|
|
Dmitry Belyavskiy |
1c01ac |
}
|
|
Dmitry Belyavskiy |
1c01ac |
|
|
Dmitry Belyavskiy |
1c01ac |
if (key_type_name == NULL)
|
|
Dmitry Belyavskiy |
1c01ac |
- key_type_name = DEFAULT_KEY_TYPE_NAME;
|
|
Dmitry Belyavskiy |
1c01ac |
+ key_type_name = FIPS_mode() ? FIPS_DEFAULT_KEY_TYPE_NAME : DEFAULT_KEY_TYPE_NAME;
|
|
Dmitry Belyavskiy |
1c01ac |
|
|
Dmitry Belyavskiy |
1c01ac |
type = sshkey_type_from_name(key_type_name);
|
|
Dmitry Belyavskiy |
1c01ac |
type_bits_valid(type, key_type_name, &bits);
|
|
Dmitry Belyavskiy |
f561c6 |
diff -up openssh-9.3p1/ssh-rsa.c.evpgenrsa openssh-9.3p1/ssh-rsa.c
|
|
Dmitry Belyavskiy |
f561c6 |
--- openssh-9.3p1/ssh-rsa.c.evpgenrsa 2022-06-30 15:14:58.200518353 +0200
|
|
Dmitry Belyavskiy |
f561c6 |
+++ openssh-9.3p1/ssh-rsa.c 2022-06-30 15:24:31.499641196 +0200
|
|
Norbert Pocs |
fb40f0 |
@@ -33,6 +33,7 @@
|
|
Dmitry Belyavskiy |
f561c6 |
#include <openssl/err.h>
|
|
Norbert Pocs |
fb40f0 |
#include <openssl/core_names.h>
|
|
Norbert Pocs |
fb40f0 |
#include <openssl/param_build.h>
|
|
Dmitry Belyavskiy |
f561c6 |
+#include <openssl/fips.h>
|
|
Dmitry Belyavskiy |
f561c6 |
|
|
Dmitry Belyavskiy |
f561c6 |
#include <stdarg.h>
|
|
Dmitry Belyavskiy |
f561c6 |
#include <string.h>
|
|
Dmitry Belyavskiy |
f561c6 |
@@ -1705,6 +1707,8 @@ ssh_rsa_generate(u_int bits, RSA
|
|
Dmitry Belyavskiy |
f561c6 |
goto out;
|
|
Dmitry Belyavskiy |
f561c6 |
|
|
Dmitry Belyavskiy |
f561c6 |
if (EVP_PKEY_keygen(ctx, &res) <= 0) {
|
|
Dmitry Belyavskiy |
f561c6 |
+ if (FIPS_mode())
|
|
Dmitry Belyavskiy |
f561c6 |
+ logit_f("the key length might be unsupported by FIPS mode approved key generation method");
|
|
Dmitry Belyavskiy |
f561c6 |
ret = SSH_ERR_LIBCRYPTO_ERROR;
|
|
Dmitry Belyavskiy |
f561c6 |
goto out;
|
|
Dmitry Belyavskiy |
f561c6 |
}
|
|
Dmitry Belyavskiy |
9fd698 |
diff -up openssh-8.7p1/kexgen.c.fips3 openssh-8.7p1/kexgen.c
|
|
Dmitry Belyavskiy |
9fd698 |
--- openssh-8.7p1/kexgen.c.fips3 2022-07-11 16:11:21.973519913 +0200
|
|
Dmitry Belyavskiy |
9fd698 |
+++ openssh-8.7p1/kexgen.c 2022-07-11 16:25:31.172187365 +0200
|
|
Dmitry Belyavskiy |
9fd698 |
@@ -31,6 +31,7 @@
|
|
Dmitry Belyavskiy |
9fd698 |
#include <stdio.h>
|
|
Dmitry Belyavskiy |
9fd698 |
#include <string.h>
|
|
Dmitry Belyavskiy |
9fd698 |
#include <signal.h>
|
|
Dmitry Belyavskiy |
c9904c |
+#include <openssl/fips.h>
|
|
Dmitry Belyavskiy |
9fd698 |
|
|
Dmitry Belyavskiy |
9fd698 |
#include "sshkey.h"
|
|
Dmitry Belyavskiy |
9fd698 |
#include "kex.h"
|
|
Dmitry Belyavskiy |
9fd698 |
@@ -115,10 +116,20 @@ kex_gen_client(struct ssh *ssh)
|
|
Dmitry Belyavskiy |
9fd698 |
break;
|
|
Dmitry Belyavskiy |
9fd698 |
#endif
|
|
Dmitry Belyavskiy |
9fd698 |
case KEX_C25519_SHA256:
|
|
Dmitry Belyavskiy |
9fd698 |
- r = kex_c25519_keypair(kex);
|
|
Dmitry Belyavskiy |
9fd698 |
+ if (FIPS_mode()) {
|
|
Dmitry Belyavskiy |
9fd698 |
+ logit_f("Key exchange type c25519 is not allowed in FIPS mode");
|
|
Dmitry Belyavskiy |
9fd698 |
+ r = SSH_ERR_INVALID_ARGUMENT;
|
|
Dmitry Belyavskiy |
9fd698 |
+ } else {
|
|
Dmitry Belyavskiy |
9fd698 |
+ r = kex_c25519_keypair(kex);
|
|
Dmitry Belyavskiy |
9fd698 |
+ }
|
|
Dmitry Belyavskiy |
9fd698 |
break;
|
|
Dmitry Belyavskiy |
9fd698 |
case KEX_KEM_SNTRUP761X25519_SHA512:
|
|
Dmitry Belyavskiy |
9fd698 |
- r = kex_kem_sntrup761x25519_keypair(kex);
|
|
Dmitry Belyavskiy |
9fd698 |
+ if (FIPS_mode()) {
|
|
Dmitry Belyavskiy |
9fd698 |
+ logit_f("Key exchange type sntrup761 is not allowed in FIPS mode");
|
|
Dmitry Belyavskiy |
9fd698 |
+ r = SSH_ERR_INVALID_ARGUMENT;
|
|
Dmitry Belyavskiy |
9fd698 |
+ } else {
|
|
Dmitry Belyavskiy |
9fd698 |
+ r = kex_kem_sntrup761x25519_keypair(kex);
|
|
Dmitry Belyavskiy |
9fd698 |
+ }
|
|
Dmitry Belyavskiy |
9fd698 |
break;
|
|
Dmitry Belyavskiy |
9fd698 |
default:
|
|
Dmitry Belyavskiy |
9fd698 |
r = SSH_ERR_INVALID_ARGUMENT;
|
|
Dmitry Belyavskiy |
9fd698 |
@@ -186,11 +197,21 @@ input_kex_gen_reply(int type, u_int32_t
|
|
Dmitry Belyavskiy |
9fd698 |
break;
|
|
Dmitry Belyavskiy |
9fd698 |
#endif
|
|
Dmitry Belyavskiy |
9fd698 |
case KEX_C25519_SHA256:
|
|
Dmitry Belyavskiy |
9fd698 |
- r = kex_c25519_dec(kex, server_blob, &shared_secret);
|
|
Dmitry Belyavskiy |
9fd698 |
+ if (FIPS_mode()) {
|
|
Dmitry Belyavskiy |
9fd698 |
+ logit_f("Key exchange type c25519 is not allowed in FIPS mode");
|
|
Dmitry Belyavskiy |
9fd698 |
+ r = SSH_ERR_INVALID_ARGUMENT;
|
|
Dmitry Belyavskiy |
9fd698 |
+ } else {
|
|
Dmitry Belyavskiy |
9fd698 |
+ r = kex_c25519_dec(kex, server_blob, &shared_secret);
|
|
Dmitry Belyavskiy |
9fd698 |
+ }
|
|
Dmitry Belyavskiy |
9fd698 |
break;
|
|
Dmitry Belyavskiy |
9fd698 |
case KEX_KEM_SNTRUP761X25519_SHA512:
|
|
Dmitry Belyavskiy |
9fd698 |
- r = kex_kem_sntrup761x25519_dec(kex, server_blob,
|
|
Dmitry Belyavskiy |
9fd698 |
- &shared_secret);
|
|
Dmitry Belyavskiy |
9fd698 |
+ if (FIPS_mode()) {
|
|
Dmitry Belyavskiy |
9fd698 |
+ logit_f("Key exchange type sntrup761 is not allowed in FIPS mode");
|
|
Dmitry Belyavskiy |
9fd698 |
+ r = SSH_ERR_INVALID_ARGUMENT;
|
|
Dmitry Belyavskiy |
9fd698 |
+ } else {
|
|
Dmitry Belyavskiy |
9fd698 |
+ r = kex_kem_sntrup761x25519_dec(kex, server_blob,
|
|
Dmitry Belyavskiy |
9fd698 |
+ &shared_secret);
|
|
Dmitry Belyavskiy |
9fd698 |
+ }
|
|
Dmitry Belyavskiy |
9fd698 |
break;
|
|
Dmitry Belyavskiy |
9fd698 |
default:
|
|
Dmitry Belyavskiy |
9fd698 |
r = SSH_ERR_INVALID_ARGUMENT;
|
|
Dmitry Belyavskiy |
9fd698 |
@@ -285,12 +306,22 @@ input_kex_gen_init(int type, u_int32_t s
|
|
Dmitry Belyavskiy |
9fd698 |
break;
|
|
Dmitry Belyavskiy |
9fd698 |
#endif
|
|
Dmitry Belyavskiy |
9fd698 |
case KEX_C25519_SHA256:
|
|
Dmitry Belyavskiy |
9fd698 |
- r = kex_c25519_enc(kex, client_pubkey, &server_pubkey,
|
|
Dmitry Belyavskiy |
9fd698 |
- &shared_secret);
|
|
Dmitry Belyavskiy |
9fd698 |
+ if (FIPS_mode()) {
|
|
Dmitry Belyavskiy |
9fd698 |
+ logit_f("Key exchange type c25519 is not allowed in FIPS mode");
|
|
Dmitry Belyavskiy |
9fd698 |
+ r = SSH_ERR_INVALID_ARGUMENT;
|
|
Dmitry Belyavskiy |
9fd698 |
+ } else {
|
|
Dmitry Belyavskiy |
9fd698 |
+ r = kex_c25519_enc(kex, client_pubkey, &server_pubkey,
|
|
Dmitry Belyavskiy |
9fd698 |
+ &shared_secret);
|
|
Dmitry Belyavskiy |
9fd698 |
+ }
|
|
Dmitry Belyavskiy |
9fd698 |
break;
|
|
Dmitry Belyavskiy |
9fd698 |
case KEX_KEM_SNTRUP761X25519_SHA512:
|
|
Dmitry Belyavskiy |
9fd698 |
- r = kex_kem_sntrup761x25519_enc(kex, client_pubkey,
|
|
Dmitry Belyavskiy |
9fd698 |
- &server_pubkey, &shared_secret);
|
|
Dmitry Belyavskiy |
9fd698 |
+ if (FIPS_mode()) {
|
|
Dmitry Belyavskiy |
9fd698 |
+ logit_f("Key exchange type sntrup761 is not allowed in FIPS mode");
|
|
Dmitry Belyavskiy |
9fd698 |
+ r = SSH_ERR_INVALID_ARGUMENT;
|
|
Dmitry Belyavskiy |
9fd698 |
+ } else {
|
|
Dmitry Belyavskiy |
9fd698 |
+ r = kex_kem_sntrup761x25519_enc(kex, client_pubkey,
|
|
Dmitry Belyavskiy |
9fd698 |
+ &server_pubkey, &shared_secret);
|
|
Dmitry Belyavskiy |
9fd698 |
+ }
|
|
Dmitry Belyavskiy |
9fd698 |
break;
|
|
Dmitry Belyavskiy |
9fd698 |
default:
|
|
Dmitry Belyavskiy |
9fd698 |
r = SSH_ERR_INVALID_ARGUMENT;
|
|
Dmitry Belyavskiy |
9fd698 |
diff -up openssh-8.7p1/ssh-ed25519.c.fips3 openssh-8.7p1/ssh-ed25519.c
|
|
Dmitry Belyavskiy |
9fd698 |
--- openssh-8.7p1/ssh-ed25519.c.fips3 2022-07-11 16:53:41.428343304 +0200
|
|
Dmitry Belyavskiy |
9fd698 |
+++ openssh-8.7p1/ssh-ed25519.c 2022-07-11 16:56:09.284663661 +0200
|
|
Dmitry Belyavskiy |
9fd698 |
@@ -24,6 +24,7 @@
|
|
Dmitry Belyavskiy |
9fd698 |
|
|
Dmitry Belyavskiy |
9fd698 |
#include <string.h>
|
|
Dmitry Belyavskiy |
9fd698 |
#include <stdarg.h>
|
|
Dmitry Belyavskiy |
c9904c |
+#include <openssl/fips.h>
|
|
Dmitry Belyavskiy |
9fd698 |
|
|
Dmitry Belyavskiy |
9fd698 |
#include "log.h"
|
|
Dmitry Belyavskiy |
9fd698 |
#include "sshbuf.h"
|
|
Dmitry Belyavskiy |
9fd698 |
@@ -52,6 +53,10 @@ ssh_ed25519_sign(const struct sshkey *ke
|
|
Dmitry Belyavskiy |
9fd698 |
key->ed25519_sk == NULL ||
|
|
Dmitry Belyavskiy |
9fd698 |
datalen >= INT_MAX - crypto_sign_ed25519_BYTES)
|
|
Dmitry Belyavskiy |
9fd698 |
return SSH_ERR_INVALID_ARGUMENT;
|
|
Dmitry Belyavskiy |
9fd698 |
+ if (FIPS_mode()) {
|
|
Dmitry Belyavskiy |
9fd698 |
+ logit_f("Ed25519 keys are not allowed in FIPS mode");
|
|
Dmitry Belyavskiy |
9fd698 |
+ return SSH_ERR_INVALID_ARGUMENT;
|
|
Dmitry Belyavskiy |
9fd698 |
+ }
|
|
Dmitry Belyavskiy |
9fd698 |
smlen = slen = datalen + crypto_sign_ed25519_BYTES;
|
|
Dmitry Belyavskiy |
9fd698 |
if ((sig = malloc(slen)) == NULL)
|
|
Dmitry Belyavskiy |
9fd698 |
return SSH_ERR_ALLOC_FAIL;
|
|
Dmitry Belyavskiy |
9fd698 |
@@ -108,6 +113,10 @@ ssh_ed25519_verify(const struct sshkey *
|
|
Dmitry Belyavskiy |
f561c6 |
dlen >= INT_MAX - crypto_sign_ed25519_BYTES ||
|
|
Dmitry Belyavskiy |
f561c6 |
sig == NULL || siglen == 0)
|
|
Dmitry Belyavskiy |
9fd698 |
return SSH_ERR_INVALID_ARGUMENT;
|
|
Dmitry Belyavskiy |
9fd698 |
+ if (FIPS_mode()) {
|
|
Dmitry Belyavskiy |
9fd698 |
+ logit_f("Ed25519 keys are not allowed in FIPS mode");
|
|
Dmitry Belyavskiy |
9fd698 |
+ return SSH_ERR_INVALID_ARGUMENT;
|
|
Dmitry Belyavskiy |
9fd698 |
+ }
|
|
Dmitry Belyavskiy |
9fd698 |
|
|
Dmitry Belyavskiy |
f561c6 |
if ((b = sshbuf_from(sig, siglen)) == NULL)
|
|
Dmitry Belyavskiy |
9fd698 |
return SSH_ERR_ALLOC_FAIL;
|