Browse code

Add option to disable Diffie Hellman key exchange by setting '--dh none'

As requested on the mailing list and in trac ticket #410, add an option to
disable 'traditional' Diffie Hellman key exchange. People want to be able
to create ecdh-only configurations.

This patch also disables RSA key exchange by default for OpenSSL builds, to
prevent that people who set "--dh none" but have an OpenSSL version that
doesn't support ECDH end up with a less secure connection. Note that users
that specify their own --tls-cipher override these defaults and thus can
still use whatever OpenSSL supports (and might thus end up with less secure
connections).

PolarSSL does not allow to easily disable RSA key exchange during runtime,
but its default compile options do not include RSA key exchange based
cipher suites.

Finally update the manpage to reflect the new behaviour, and while touching
it change the text to motivate users towards a more secure configuration.

v2 - disable RSA key exchange by default

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1420141569-11773-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9376
Signed-off-by: Gert Doering <gert@greenie.muc.de>

Steffan Karger authored on 2015/01/02 04:46:09
Showing 4 changed files
... ...
@@ -4239,13 +4239,18 @@ Not available with PolarSSL.
4239 4239
 File containing Diffie Hellman parameters
4240 4240
 in .pem format (required for
4241 4241
 .B \-\-tls-server
4242
-only). Use
4242
+only).
4243 4243
 
4244
-.B openssl dhparam -out dh1024.pem 1024
4244
+Set
4245
+.B file=none
4246
+to disable Diffie Hellman key exchange (and use ECDH only). Note that this
4247
+requires peers to be using an SSL library that supports ECDH TLS cipher suites
4248
+(e.g. OpenSSL 1.0.1+, or PolarSSL 1.3+).
4245 4249
 
4246
-to generate your own, or use the existing dh1024.pem file
4247
-included with the OpenVPN distribution.  Diffie Hellman parameters
4248
-may be considered public.
4250
+Use
4251
+.B openssl dhparam -out dh2048.pem 2048
4252
+to generate 2048-bit DH parameters. Diffie Hellman parameters may be considered
4253
+public.
4249 4254
 .\"*********************************************************
4250 4255
 .TP
4251 4256
 .B \-\-ecdh-curve name
... ...
@@ -2134,10 +2134,6 @@ options_postprocess_verify_ce (const struct options *options, const struct conne
2134 2134
       (options->shared_secret_file != NULL) > 1)
2135 2135
     msg (M_USAGE, "specify only one of --tls-server, --tls-client, or --secret");
2136 2136
 
2137
-  if (options->tls_server)
2138
-    {
2139
-      notnull (options->dh_file, "DH file (--dh)");
2140
-    }
2141 2137
   if (options->tls_server || options->tls_client)
2142 2138
     {
2143 2139
 #ifdef ENABLE_PKCS11
... ...
@@ -2497,6 +2493,16 @@ options_postprocess_mutate (struct options *o)
2497 2497
   for (i = 0; i < o->connection_list->len; ++i)
2498 2498
 	options_postprocess_mutate_ce (o, o->connection_list->array[i]);
2499 2499
 
2500
+#ifdef ENABLE_CRYPTO
2501
+  if (o->tls_server)
2502
+    {
2503
+      /* Check that DH file is specified, or explicitly disabled */
2504
+      notnull (o->dh_file, "DH file (--dh)");
2505
+      if (streq (o->dh_file, "none"))
2506
+	o->dh_file = NULL;
2507
+    }
2508
+#endif
2509
+
2500 2510
 #if ENABLE_MANAGEMENT
2501 2511
   if (o->http_proxy_override)
2502 2512
 	options_postprocess_http_proxy_override(o);
... ...
@@ -242,6 +242,7 @@ static const tls_cipher_name_pair tls_cipher_name_translation_table[] = {
242 242
     {"EDH", "EDH"},
243 243
     {"EXP", "EXP"},
244 244
     {"RSA", "RSA"},
245
+    {"kRSA", "kRSA"},
245 246
     {"SRP", "SRP"},
246 247
 #endif
247 248
     {NULL, NULL}
... ...
@@ -483,7 +484,10 @@ init_ssl (const struct options *options, struct tls_root_ctx *new_ctx)
483 483
   if (options->tls_server)
484 484
     {
485 485
       tls_ctx_server_new(new_ctx);
486
-      tls_ctx_load_dh_params(new_ctx, options->dh_file, options->dh_file_inline);
486
+
487
+      if (options->dh_file)
488
+	tls_ctx_load_dh_params(new_ctx, options->dh_file,
489
+			       options->dh_file_inline);
487 490
     }
488 491
   else				/* if client */
489 492
     {
... ...
@@ -234,7 +234,7 @@ tls_ctx_restrict_ciphers(struct tls_root_ctx *ctx, const char *ciphers)
234 234
   if (ciphers == NULL)
235 235
     {
236 236
       /* Use sane default (disable export, and unsupported cipher modes) */
237
-      if(!SSL_CTX_set_cipher_list(ctx->ctx, "DEFAULT:!EXP:!PSK:!SRP"))
237
+      if(!SSL_CTX_set_cipher_list(ctx->ctx, "DEFAULT:!EXP:!PSK:!SRP:!kRSA"))
238 238
 	crypto_msg (M_FATAL, "Failed to set default TLS cipher list.");
239 239
       return;
240 240
     }