summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsthen <>2018-06-12 15:32:54 +0000
committersthen <>2018-06-12 15:32:54 +0000
commitf205a75959ba84bef74fc19e6728ba281c6b7575 (patch)
treefb7b950632b5c481da12c93906cbe9e80acccd57
parent5fafcafc436e54effef15dc1a5669f88d67b5bd7 (diff)
downloadopenbsd-f205a75959ba84bef74fc19e6728ba281c6b7575.tar.gz
openbsd-f205a75959ba84bef74fc19e6728ba281c6b7575.tar.bz2
openbsd-f205a75959ba84bef74fc19e6728ba281c6b7575.zip
Reject excessively large primes in DH key generation. Problem reported
by Guido Vranken to OpenSSL (https://github.com/openssl/openssl/pull/6457) and based on his diff. suggestions from tb@, ok tb@ jsing@ "During key agreement in a TLS handshake using a DH(E) based ciphersuite a malicious server can send a very large prime value to the client. This will cause the client to spend an unreasonably long period of time generating a key for this prime resulting in a hang until the client has finished. This could be exploited in a Denial Of Service attack."
-rw-r--r--src/lib/libcrypto/dh/dh_key.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/lib/libcrypto/dh/dh_key.c b/src/lib/libcrypto/dh/dh_key.c
index 63d38771c3..b46f037803 100644
--- a/src/lib/libcrypto/dh/dh_key.c
+++ b/src/lib/libcrypto/dh/dh_key.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: dh_key.c,v 1.27 2017/01/29 17:49:22 beck Exp $ */ 1/* $OpenBSD: dh_key.c,v 1.28 2018/06/12 15:32:54 sthen Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -108,6 +108,11 @@ generate_key(DH *dh)
108 BN_MONT_CTX *mont = NULL; 108 BN_MONT_CTX *mont = NULL;
109 BIGNUM *pub_key = NULL, *priv_key = NULL; 109 BIGNUM *pub_key = NULL, *priv_key = NULL;
110 110
111 if (BN_num_bits(dh->p) > OPENSSL_DH_MAX_MODULUS_BITS) {
112 DHerror(DH_R_MODULUS_TOO_LARGE);
113 return 0;
114 }
115
111 ctx = BN_CTX_new(); 116 ctx = BN_CTX_new();
112 if (ctx == NULL) 117 if (ctx == NULL)
113 goto err; 118 goto err;