summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjsing <>2018-06-13 15:12:39 +0000
committerjsing <>2018-06-13 15:12:39 +0000
commit82a1fcd5a9a11792a08e3a5139638f5a29651ec4 (patch)
tree7fa80863e5887970150a1ddb31e8293ab18275b4
parentb6faac1f1a48896c4bea8877382f91ff23c964f7 (diff)
downloadopenbsd-OPENBSD_6_2.tar.gz
openbsd-OPENBSD_6_2.tar.bz2
openbsd-OPENBSD_6_2.zip
MFC: Reject excessively large primes in DH key generation. Problem reportedlibressl-v2.6.5OPENBSD_6_2
by Guido Vranken to OpenSSL (https://github.com/openssl/openssl/pull/6457) and based on his diff. suggestions from tb@, ok tb@ jsing@ Original commit by sthen@
-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..1a2c591ed0 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.27.6.1 2018/06/13 15:12:39 jsing 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;