summaryrefslogtreecommitdiff
path: root/src/lib/libssl/ssl_lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libssl/ssl_lib.c')
-rw-r--r--src/lib/libssl/ssl_lib.c50
1 files changed, 12 insertions, 38 deletions
diff --git a/src/lib/libssl/ssl_lib.c b/src/lib/libssl/ssl_lib.c
index 662013378e..a0d3d05775 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.279 2021/11/14 22:31:29 tb Exp $ */ 1/* $OpenBSD: ssl_lib.c,v 1.280 2021/12/04 14:03:22 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 *
@@ -147,7 +147,6 @@
147#include <limits.h> 147#include <limits.h>
148#include <stdio.h> 148#include <stdio.h>
149 149
150#include <openssl/bn.h>
151#include <openssl/dh.h> 150#include <openssl/dh.h>
152#include <openssl/lhash.h> 151#include <openssl/lhash.h>
153#include <openssl/objects.h> 152#include <openssl/objects.h>
@@ -2319,54 +2318,29 @@ ssl_get_sign_pkey(SSL *s, const SSL_CIPHER *cipher, const EVP_MD **pmd,
2319 return (pkey); 2318 return (pkey);
2320} 2319}
2321 2320
2322DH * 2321size_t
2323ssl_get_auto_dh(SSL *s) 2322ssl_dhe_params_auto_key_bits(SSL *s)
2324{ 2323{
2325 CERT_PKEY *cpk; 2324 CERT_PKEY *cpk;
2326 int keylen; 2325 int key_bits;
2327 DH *dhp;
2328 2326
2329 if (s->cert->dh_tmp_auto == 2) { 2327 if (s->cert->dh_tmp_auto == 2) {
2330 keylen = 1024; 2328 key_bits = 1024;
2331 } else if (S3I(s)->hs.cipher->algorithm_auth & SSL_aNULL) { 2329 } else if (S3I(s)->hs.cipher->algorithm_auth & SSL_aNULL) {
2332 keylen = 1024; 2330 key_bits = 1024;
2333 if (S3I(s)->hs.cipher->strength_bits == 256) 2331 if (S3I(s)->hs.cipher->strength_bits == 256)
2334 keylen = 3072; 2332 key_bits = 3072;
2335 } else { 2333 } else {
2336 if ((cpk = ssl_get_server_send_pkey(s)) == NULL) 2334 if ((cpk = ssl_get_server_send_pkey(s)) == NULL)
2337 return (NULL); 2335 return 0;
2338 if (cpk->privatekey == NULL || 2336 if (cpk->privatekey == NULL ||
2339 EVP_PKEY_get0_RSA(cpk->privatekey) == NULL) 2337 EVP_PKEY_get0_RSA(cpk->privatekey) == NULL)
2340 return (NULL); 2338 return 0;
2341 if ((keylen = EVP_PKEY_bits(cpk->privatekey)) <= 0) 2339 if ((key_bits = EVP_PKEY_bits(cpk->privatekey)) <= 0)
2342 return (NULL); 2340 return 0;
2343 } 2341 }
2344 2342
2345 if ((dhp = DH_new()) == NULL) 2343 return key_bits;
2346 return (NULL);
2347
2348 dhp->g = BN_new();
2349 if (dhp->g != NULL)
2350 BN_set_word(dhp->g, 2);
2351
2352 if (keylen >= 8192)
2353 dhp->p = get_rfc3526_prime_8192(NULL);
2354 else if (keylen >= 4096)
2355 dhp->p = get_rfc3526_prime_4096(NULL);
2356 else if (keylen >= 3072)
2357 dhp->p = get_rfc3526_prime_3072(NULL);
2358 else if (keylen >= 2048)
2359 dhp->p = get_rfc3526_prime_2048(NULL);
2360 else if (keylen >= 1536)
2361 dhp->p = get_rfc3526_prime_1536(NULL);
2362 else
2363 dhp->p = get_rfc2409_prime_1024(NULL);
2364
2365 if (dhp->p == NULL || dhp->g == NULL) {
2366 DH_free(dhp);
2367 return (NULL);
2368 }
2369 return (dhp);
2370} 2344}
2371 2345
2372static int 2346static int