Browse code

Allow gcm ciphers and dh kex algorithms in fips mode

Change-Id: Ib89dad0935abca3b5f138cbf1f8886ed8337b61a
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/4304
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Joao Lima
Reviewed-by: Sharath George

suezzelur authored on 2017/11/15 10:03:56
Showing 2 changed files
... ...
@@ -1,7 +1,7 @@
1
-diff -rup openssh-7.4p1/cipher.c openssh-7.4p1-fips/cipher.c
1
+diff -rup openssh-7.4p1/cipher.c openssh-7.4p1-new/cipher.c
2 2
 --- openssh-7.4p1/cipher.c	2016-12-18 20:59:41.000000000 -0800
3
-+++ openssh-7.4p1-fips/cipher.c	2017-02-02 15:51:07.008913721 -0800
4
-@@ -136,6 +136,20 @@ static const struct sshcipher ciphers[]
3
+@@ -136,6 +136,26 @@ static const struct sshcipher ciphers[]
5 4
  	{ NULL,		SSH_CIPHER_INVALID, 0, 0, 0, 0, 0, 0, NULL }
6 5
  };
7 6
  
... ...
@@ -16,13 +16,19 @@ diff -rup openssh-7.4p1/cipher.c openssh-7.4p1-fips/cipher.c
16 16
 +	{ "aes128-ctr",	SSH_CIPHER_SSH2, 16, 16, 0, 0, 0, 0, EVP_aes_128_ctr },
17 17
 +	{ "aes192-ctr",	SSH_CIPHER_SSH2, 16, 24, 0, 0, 0, 0, EVP_aes_192_ctr },
18 18
 +	{ "aes256-ctr",	SSH_CIPHER_SSH2, 16, 32, 0, 0, 0, 0, EVP_aes_256_ctr },
19
++# ifdef OPENSSL_HAVE_EVPGCM
20
++	{ "aes128-gcm@openssh.com",
21
++			SSH_CIPHER_SSH2, 16, 16, 12, 16, 0, 0, EVP_aes_128_gcm },
22
++	{ "aes256-gcm@openssh.com",
23
++			SSH_CIPHER_SSH2, 16, 32, 12, 16, 0, 0, EVP_aes_256_gcm },
24
++# endif /* OPENSSL_HAVE_EVPGCM */
19 25
 +	{ NULL,		SSH_CIPHER_INVALID, 0, 0, 0, 0, 0, 0, NULL }
20 26
 +};
21 27
 +
22 28
  /*--*/
23 29
  
24 30
  /* Returns a comma-separated list of supported ciphers. */
25
-@@ -146,7 +160,7 @@ cipher_alg_list(char sep, int auth_only)
31
+@@ -146,7 +166,7 @@ cipher_alg_list(char sep, int auth_only)
26 32
  	size_t nlen, rlen = 0;
27 33
  	const struct sshcipher *c;
28 34
  
... ...
@@ -31,7 +37,7 @@ diff -rup openssh-7.4p1/cipher.c openssh-7.4p1-fips/cipher.c
31 31
  		if (c->number != SSH_CIPHER_SSH2)
32 32
  			continue;
33 33
  		if (auth_only && c->auth_len == 0)
34
-@@ -242,7 +256,7 @@ const struct sshcipher *
34
+@@ -242,7 +262,7 @@ const struct sshcipher *
35 35
  cipher_by_name(const char *name)
36 36
  {
37 37
  	const struct sshcipher *c;
... ...
@@ -40,7 +46,7 @@ diff -rup openssh-7.4p1/cipher.c openssh-7.4p1-fips/cipher.c
40 40
  		if (strcmp(c->name, name) == 0)
41 41
  			return c;
42 42
  	return NULL;
43
-@@ -252,7 +266,7 @@ const struct sshcipher *
43
+@@ -252,7 +272,7 @@ const struct sshcipher *
44 44
  cipher_by_number(int id)
45 45
  {
46 46
  	const struct sshcipher *c;
... ...
@@ -49,7 +55,7 @@ diff -rup openssh-7.4p1/cipher.c openssh-7.4p1-fips/cipher.c
49 49
  		if (c->number == id)
50 50
  			return c;
51 51
  	return NULL;
52
-@@ -293,7 +307,7 @@ cipher_number(const char *name)
52
+@@ -293,7 +313,7 @@ cipher_number(const char *name)
53 53
  	const struct sshcipher *c;
54 54
  	if (name == NULL)
55 55
  		return -1;
... ...
@@ -58,9 +64,9 @@ diff -rup openssh-7.4p1/cipher.c openssh-7.4p1-fips/cipher.c
58 58
  		if (strcasecmp(c->name, name) == 0)
59 59
  			return c->number;
60 60
  	return -1;
61
-diff -rup openssh-7.4p1/cipher-ctr.c openssh-7.4p1-fips/cipher-ctr.c
61
+diff -rup openssh-7.4p1/cipher-ctr.c openssh-7.4p1-new/cipher-ctr.c
62 62
 --- openssh-7.4p1/cipher-ctr.c	2016-12-18 20:59:41.000000000 -0800
63
-+++ openssh-7.4p1-fips/cipher-ctr.c	2017-02-02 15:47:44.252918302 -0800
64 63
 @@ -138,7 +138,8 @@ evp_aes_128_ctr(void)
65 64
  	aes_ctr.do_cipher = ssh_aes_ctr;
66 65
  #ifndef SSH_OLD_EVP
... ...
@@ -71,9 +77,9 @@ diff -rup openssh-7.4p1/cipher-ctr.c openssh-7.4p1-fips/cipher-ctr.c
71 71
  #endif
72 72
  	return (&aes_ctr);
73 73
  }
74
-diff -rup openssh-7.4p1/dh.h openssh-7.4p1-fips/dh.h
74
+diff -rup openssh-7.4p1/dh.h openssh-7.4p1-new/dh.h
75 75
 --- openssh-7.4p1/dh.h	2016-12-18 20:59:41.000000000 -0800
76
-+++ openssh-7.4p1-fips/dh.h	2017-02-02 15:52:37.552911676 -0800
77 76
 @@ -51,6 +51,7 @@ u_int	 dh_estimate(int);
78 77
   * Miniumum increased in light of DH precomputation attacks.
79 78
   */
... ...
@@ -82,9 +88,9 @@ diff -rup openssh-7.4p1/dh.h openssh-7.4p1-fips/dh.h
82 82
  #define DH_GRP_MAX	8192
83 83
  
84 84
  /*
85
-diff -rup openssh-7.4p1/entropy.c openssh-7.4p1-fips/entropy.c
85
+diff -rup openssh-7.4p1/entropy.c openssh-7.4p1-new/entropy.c
86 86
 --- openssh-7.4p1/entropy.c	2016-12-18 20:59:41.000000000 -0800
87
-+++ openssh-7.4p1-fips/entropy.c	2017-02-02 15:53:46.088910128 -0800
88 87
 @@ -217,6 +217,9 @@ seed_rng(void)
89 88
  		fatal("OpenSSL version mismatch. Built against %lx, you "
90 89
  		    "have %lx", (u_long)OPENSSL_VERSION_NUMBER, SSLeay());
... ...
@@ -95,14 +101,18 @@ diff -rup openssh-7.4p1/entropy.c openssh-7.4p1-fips/entropy.c
95 95
  #ifndef OPENSSL_PRNG_ONLY
96 96
  	if (RAND_status() == 1) {
97 97
  		debug3("RNG is ready, skipping seeding");
98
-diff -rup openssh-7.4p1/kex.c openssh-7.4p1-fips/kex.c
98
+diff -rup openssh-7.4p1/kex.c openssh-7.4p1-new/kex.c
99 99
 --- openssh-7.4p1/kex.c	2016-12-18 20:59:41.000000000 -0800
100
-+++ openssh-7.4p1-fips/kex.c	2017-02-02 16:06:13.120893252 -0800
101
-@@ -114,6 +114,23 @@ static const struct kexalg kexalgs[] = {
100
+@@ -114,6 +114,27 @@ static const struct kexalg kexalgs[] = {
102 101
  	{ NULL, -1, -1, -1},
103 102
  };
104 103
  
105 104
 +static const struct kexalg kexalgs_fips[] = {
105
++	{ KEX_DH14_SHA1, KEX_DH_GRP14_SHA1, 0, SSH_DIGEST_SHA1 },
106
++	{ KEX_DH14_SHA256, KEX_DH_GRP14_SHA256, 0, SSH_DIGEST_SHA256 },
107
++	{ KEX_DH16_SHA512, KEX_DH_GRP16_SHA512, 0, SSH_DIGEST_SHA512 },
108
++	{ KEX_DH18_SHA512, KEX_DH_GRP18_SHA512, 0, SSH_DIGEST_SHA512 },
106 109
 +#ifdef HAVE_EVP_SHA256
107 110
 +	{ KEX_DHGEX_SHA256, KEX_DH_GEX_SHA256, 0, SSH_DIGEST_SHA256 },
108 111
 +#endif
... ...
@@ -122,7 +132,7 @@ diff -rup openssh-7.4p1/kex.c openssh-7.4p1-fips/kex.c
122 122
  char *
123 123
  kex_alg_list(char sep)
124 124
  {
125
-@@ -121,7 +138,7 @@ kex_alg_list(char sep)
125
+@@ -121,7 +142,7 @@ kex_alg_list(char sep)
126 126
  	size_t nlen, rlen = 0;
127 127
  	const struct kexalg *k;
128 128
  
... ...
@@ -131,7 +141,7 @@ diff -rup openssh-7.4p1/kex.c openssh-7.4p1-fips/kex.c
131 131
  		if (ret != NULL)
132 132
  			ret[rlen++] = sep;
133 133
  		nlen = strlen(k->name);
134
-@@ -141,7 +158,7 @@ kex_alg_by_name(const char *name)
134
+@@ -141,7 +162,7 @@ kex_alg_by_name(const char *name)
135 135
  {
136 136
  	const struct kexalg *k;
137 137
  
... ...
@@ -140,7 +150,7 @@ diff -rup openssh-7.4p1/kex.c openssh-7.4p1-fips/kex.c
140 140
  		if (strcmp(k->name, name) == 0)
141 141
  			return k;
142 142
  	}
143
-@@ -161,7 +178,10 @@ kex_names_valid(const char *names)
143
+@@ -161,7 +182,10 @@ kex_names_valid(const char *names)
144 144
  	for ((p = strsep(&cp, ",")); p && *p != '\0';
145 145
  	    (p = strsep(&cp, ","))) {
146 146
  		if (kex_alg_by_name(p) == NULL) {
... ...
@@ -152,9 +162,9 @@ diff -rup openssh-7.4p1/kex.c openssh-7.4p1-fips/kex.c
152 152
  			free(s);
153 153
  			return 0;
154 154
  		}
155
-diff -rup openssh-7.4p1/kexgexc.c openssh-7.4p1-fips/kexgexc.c
155
+diff -rup openssh-7.4p1/kexgexc.c openssh-7.4p1-new/kexgexc.c
156 156
 --- openssh-7.4p1/kexgexc.c	2016-12-18 20:59:41.000000000 -0800
157
-+++ openssh-7.4p1-fips/kexgexc.c	2017-02-02 16:10:36.604887300 -0800
158 157
 @@ -63,7 +63,7 @@ kexgex_client(struct ssh *ssh)
159 158
  
160 159
  	nbits = dh_estimate(kex->dh_need * 8);
... ...
@@ -164,9 +174,9 @@ diff -rup openssh-7.4p1/kexgexc.c openssh-7.4p1-fips/kexgexc.c
164 164
  	kex->max = DH_GRP_MAX;
165 165
  	kex->nbits = nbits;
166 166
  	if (datafellows & SSH_BUG_DHGEX_LARGE)
167
-diff -rup openssh-7.4p1/kexgexs.c openssh-7.4p1-fips/kexgexs.c
167
+diff -rup openssh-7.4p1/kexgexs.c openssh-7.4p1-new/kexgexs.c
168 168
 --- openssh-7.4p1/kexgexs.c	2016-12-18 20:59:41.000000000 -0800
169
-+++ openssh-7.4p1-fips/kexgexs.c	2017-02-02 16:11:31.404886062 -0800
170 169
 @@ -83,9 +83,9 @@ input_kex_dh_gex_request(int type, u_int
171 170
  	kex->nbits = nbits;
172 171
  	kex->min = min;
... ...
@@ -179,9 +189,9 @@ diff -rup openssh-7.4p1/kexgexs.c openssh-7.4p1-fips/kexgexs.c
179 179
  	nbits = MINIMUM(DH_GRP_MAX, nbits);
180 180
  
181 181
  	if (kex->max < kex->min || kex->nbits < kex->min ||
182
-diff -rup openssh-7.4p1/mac.c openssh-7.4p1-fips/mac.c
182
+diff -rup openssh-7.4p1/mac.c openssh-7.4p1-new/mac.c
183 183
 --- openssh-7.4p1/mac.c	2016-12-18 20:59:41.000000000 -0800
184
-+++ openssh-7.4p1-fips/mac.c	2017-02-02 16:13:56.932882775 -0800
185 184
 @@ -54,7 +54,7 @@ struct macalg {
186 185
  	int		etm;		/* Encrypt-then-MAC */
187 186
  };
... ...
@@ -234,20 +244,23 @@ diff -rup openssh-7.4p1/mac.c openssh-7.4p1-fips/mac.c
234 234
  		if (strcmp(name, m->name) != 0)
235 235
  			continue;
236 236
  		if (mac != NULL)
237
-diff -rup openssh-7.4p1/myproposal.h openssh-7.4p1-fips/myproposal.h
237
+diff -rup openssh-7.4p1/myproposal.h openssh-7.4p1-new/myproposal.h
238 238
 --- openssh-7.4p1/myproposal.h	2016-12-18 20:59:41.000000000 -0800
239
-+++ openssh-7.4p1-fips/myproposal.h	2017-02-02 16:15:40.516880435 -0800
240
-@@ -138,6 +138,26 @@
239
+@@ -138,6 +138,29 @@
241 240
  
242 241
  #define KEX_CLIENT_MAC KEX_SERVER_MAC
243 242
  
244 243
 +#define KEX_DEFAULT_KEX_FIPS		\
245 244
 +	KEX_ECDH_METHODS \
246
-+	KEX_SHA2_METHODS
245
++	KEX_SHA2_METHODS \
246
++	KEX_SHA2_GROUP14 \
247
++	"diffie-hellman-group14-sha1"
247 248
 +#define	KEX_FIPS_ENCRYPT \
248 249
 +	"aes128-ctr,aes192-ctr,aes256-ctr," \
249 250
 +	"aes128-cbc,3des-cbc," \
250
-+	"aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se"
251
++	"aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se" \
252
++	AESGCM_CIPHER_MODES
251 253
 +#ifdef HAVE_EVP_SHA256
252 254
 +#define	KEX_FIPS_MAC \
253 255
 +	"hmac-sha1," \
... ...
@@ -264,9 +277,9 @@ diff -rup openssh-7.4p1/myproposal.h openssh-7.4p1-fips/myproposal.h
264 264
  #else /* WITH_OPENSSL */
265 265
  
266 266
  #define KEX_SERVER_KEX		\
267
-diff -rup openssh-7.4p1/openbsd-compat/openssl-compat.h openssh-7.4p1-fips/openbsd-compat/openssl-compat.h
267
+diff -rup openssh-7.4p1/openbsd-compat/openssl-compat.h openssh-7.4p1-new/openbsd-compat/openssl-compat.h
268 268
 --- openssh-7.4p1/openbsd-compat/openssl-compat.h	2016-12-18 20:59:41.000000000 -0800
269
-+++ openssh-7.4p1-fips/openbsd-compat/openssl-compat.h	2017-02-02 16:17:03.024878571 -0800
270 269
 @@ -24,6 +24,7 @@
271 270
  #include <openssl/evp.h>
272 271
  #include <openssl/rsa.h>
... ...
@@ -275,9 +288,9 @@ diff -rup openssh-7.4p1/openbsd-compat/openssl-compat.h openssh-7.4p1-fips/openb
275 275
  
276 276
  int ssh_compatible_openssl(long, long);
277 277
  
278
-diff -rup openssh-7.4p1/readconf.c openssh-7.4p1-fips/readconf.c
278
+diff -rup openssh-7.4p1/readconf.c openssh-7.4p1-new/readconf.c
279 279
 --- openssh-7.4p1/readconf.c	2016-12-18 20:59:41.000000000 -0800
280
-+++ openssh-7.4p1-fips/readconf.c	2017-02-02 16:19:05.624875801 -0800
281 280
 @@ -2044,9 +2044,12 @@ fill_default_options(Options * options)
282 281
  		options->fingerprint_hash = SSH_FP_HASH_DEFAULT;
283 282
  	if (options->update_hostkeys == -1)
... ...
@@ -294,9 +307,9 @@ diff -rup openssh-7.4p1/readconf.c openssh-7.4p1-fips/readconf.c
294 294
  	    kex_assemble_names(KEX_DEFAULT_PK_ALG,
295 295
  	    &options->hostbased_key_types) != 0 ||
296 296
  	    kex_assemble_names(KEX_DEFAULT_PK_ALG,
297
-diff -rup openssh-7.4p1/sandbox-seccomp-filter.c openssh-7.4p1-fips/sandbox-seccomp-filter.c
297
+diff -rup openssh-7.4p1/sandbox-seccomp-filter.c openssh-7.4p1-new/sandbox-seccomp-filter.c
298 298
 --- openssh-7.4p1/sandbox-seccomp-filter.c	2016-12-18 20:59:41.000000000 -0800
299
-+++ openssh-7.4p1-fips/sandbox-seccomp-filter.c	2017-02-02 16:20:10.104874345 -0800
300 299
 @@ -118,6 +118,9 @@ static const struct sock_filter preauth_
301 300
  #ifdef __NR_open
302 301
  	SC_DENY(open, EACCES),
... ...
@@ -307,9 +320,9 @@ diff -rup openssh-7.4p1/sandbox-seccomp-filter.c openssh-7.4p1-fips/sandbox-secc
307 307
  #ifdef __NR_openat
308 308
  	SC_DENY(openat, EACCES),
309 309
  #endif
310
-diff -rup openssh-7.4p1/servconf.c openssh-7.4p1-fips/servconf.c
310
+diff -rup openssh-7.4p1/servconf.c openssh-7.4p1-new/servconf.c
311 311
 --- openssh-7.4p1/servconf.c	2016-12-18 20:59:41.000000000 -0800
312
-+++ openssh-7.4p1-fips/servconf.c	2017-02-02 16:23:48.132869419 -0800
313 312
 @@ -176,9 +176,12 @@ option_clear_or_none(const char *o)
314 313
  static void
315 314
  assemble_algorithms(ServerOptions *o)
... ...
@@ -350,9 +363,9 @@ diff -rup openssh-7.4p1/servconf.c openssh-7.4p1-fips/servconf.c
350 350
  	dump_cfg_string(sHostbasedAcceptedKeyTypes, o->hostbased_key_types ?
351 351
  	    o->hostbased_key_types : KEX_DEFAULT_PK_ALG);
352 352
  	dump_cfg_string(sHostKeyAlgorithms, o->hostkeyalgorithms ?
353
-diff -rup openssh-7.4p1/ssh.c openssh-7.4p1-fips/ssh.c
353
+diff -rup openssh-7.4p1/ssh.c openssh-7.4p1-new/ssh.c
354 354
 --- openssh-7.4p1/ssh.c	2016-12-18 20:59:41.000000000 -0800
355
-+++ openssh-7.4p1-fips/ssh.c	2017-02-02 16:49:00.060835265 -0800
356 355
 @@ -609,6 +609,9 @@ main(int ac, char **av)
357 356
  	    "ACD:E:F:GI:J:KL:MNO:PQ:R:S:TVw:W:XYy")) != -1) {
358 357
  		switch (opt) {
... ...
@@ -387,9 +400,9 @@ diff -rup openssh-7.4p1/ssh.c openssh-7.4p1-fips/ssh.c
387 387
  	/* Open a connection to the remote host. */
388 388
  	if (ssh_connect(host, addrs, &hostaddr, options.port,
389 389
  	    options.address_family, options.connection_attempts,
390
-diff -rup openssh-7.4p1/sshd.c openssh-7.4p1-fips/sshd.c
390
+diff -rup openssh-7.4p1/sshd.c openssh-7.4p1-new/sshd.c
391 391
 --- openssh-7.4p1/sshd.c	2016-12-18 20:59:41.000000000 -0800
392
-+++ openssh-7.4p1-fips/sshd.c	2017-02-02 16:54:20.952828016 -0800
393 392
 @@ -1827,6 +1827,10 @@ main(int ac, char **av)
394 393
  	/* Reinitialize the log (because of the fork above). */
395 394
  	log_init(__progname, options.log_level, options.log_facility, log_stderr);
... ...
@@ -401,9 +414,9 @@ diff -rup openssh-7.4p1/sshd.c openssh-7.4p1-fips/sshd.c
401 401
  	/* Chdir to the root directory so that the current disk can be
402 402
  	   unmounted if desired. */
403 403
  	if (chdir("/") == -1)
404
-diff -rup openssh-7.4p1/sshkey.c openssh-7.4p1-fips/sshkey.c
404
+diff -rup openssh-7.4p1/sshkey.c openssh-7.4p1-new/sshkey.c
405 405
 --- openssh-7.4p1/sshkey.c	2016-12-18 20:59:41.000000000 -0800
406
-+++ openssh-7.4p1-fips/sshkey.c	2017-02-02 17:17:00.576797301 -0800
407 406
 @@ -56,6 +56,7 @@
408 407
  #include "digest.h"
409 408
  #define SSHKEY_INTERNAL
... ...
@@ -1,7 +1,7 @@
1 1
 Summary:    Free version of the SSH connectivity tools
2 2
 Name:       openssh
3 3
 Version:    7.4p1
4
-Release:    5%{?dist}
4
+Release:    6%{?dist}
5 5
 License:    BSD
6 6
 URL:         https://www.openssh.com/
7 7
 Group:      System Environment/Security
... ...
@@ -142,6 +142,8 @@ rm -rf %{buildroot}/*
142 142
 %{_mandir}/man8/*
143 143
 %attr(700,root,sys)/var/lib/sshd
144 144
 %changelog
145
+*   Tue Nov 14 2017 Anish Swaminathan <anishs@vmware.com> 7.4p1-6
146
+-   Add ciphers aes128-gcm, aes256-gcm and kex dh14/16/18 in fips mode
145 147
 *   Thu Nov 02 2017 Anish Swaminathan <anishs@vmware.com> 7.4p1-5
146 148
 -   Fix service file for sshd
147 149
 *   Fri May 19 2017 Alexey Makhalov <amakhalov@vmware.com> 7.4p1-4