summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortb <>2021-11-14 22:31:29 +0000
committertb <>2021-11-14 22:31:29 +0000
commit0a9989975f8999ece81564c98fe6a2fbbbf20eab (patch)
tree4820be7a499bbd3da441800bc5d0eaa3a2fd64d3
parentee9bc50424ede76b319dc894116bafba41fd5d47 (diff)
downloadopenbsd-0a9989975f8999ece81564c98fe6a2fbbbf20eab.tar.gz
openbsd-0a9989975f8999ece81564c98fe6a2fbbbf20eab.tar.bz2
openbsd-0a9989975f8999ece81564c98fe6a2fbbbf20eab.zip
Fix a strange check in the auto DH codepath
The code assumes that the server certificate has an RSA key and bases the calculation of the size of the ephemeral DH key on this assumption. So instead of checking whether we have any key by inspecting the dh part of the union, let's check that we actually have an RSA key. While here, make sure that its length is non-negative. ok jsing
-rw-r--r--src/lib/libssl/ssl_lib.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/lib/libssl/ssl_lib.c b/src/lib/libssl/ssl_lib.c
index b6882e7b12..662013378e 100644
--- a/src/lib/libssl/ssl_lib.c
+++ b/src/lib/libssl/ssl_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_lib.c,v 1.278 2021/11/08 18:19:22 bcook Exp $ */ 1/* $OpenBSD: ssl_lib.c,v 1.279 2021/11/14 22:31:29 tb 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 *
@@ -2335,9 +2335,11 @@ ssl_get_auto_dh(SSL *s)
2335 } else { 2335 } else {
2336 if ((cpk = ssl_get_server_send_pkey(s)) == NULL) 2336 if ((cpk = ssl_get_server_send_pkey(s)) == NULL)
2337 return (NULL); 2337 return (NULL);
2338 if (cpk->privatekey == NULL || cpk->privatekey->pkey.dh == NULL) 2338 if (cpk->privatekey == NULL ||
2339 EVP_PKEY_get0_RSA(cpk->privatekey) == NULL)
2340 return (NULL);
2341 if ((keylen = EVP_PKEY_bits(cpk->privatekey)) <= 0)
2339 return (NULL); 2342 return (NULL);
2340 keylen = EVP_PKEY_bits(cpk->privatekey);
2341 } 2343 }
2342 2344
2343 if ((dhp = DH_new()) == NULL) 2345 if ((dhp = DH_new()) == NULL)