]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: ssl: Factorize ssl_get_tmp_dh and append a cbk to its name
authorRemi Tricot-Le Breton <rlebreton@haproxy.com>
Fri, 11 Feb 2022 11:04:49 +0000 (12:04 +0100)
committerWilliam Lallemand <wlallemand@haproxy.org>
Mon, 14 Feb 2022 09:07:14 +0000 (10:07 +0100)
In the upcoming OpenSSLv3 specific patches, we will make use of the
newly created ssl_get_tmp_dh that returns an EVP_PKEY containing DH
parameters of the same size as a bind line's RSA or DSA private key.
The previously named ssl_get_tmp_dh function was renamed
ssl_get_tmp_dh_cbk because it is only used as a callback passed to
OpenSSL through SSL_CTX_set_tmp_dh_callback calls.

src/ssl_sock.c

index 41a716573dce57ad187af1b072ba8b9f21c3b879..d615593194ebf8ae15183619e3e54a49c2b6be24 100644 (file)
@@ -471,7 +471,7 @@ static DH *global_dh = NULL;
 static DH *local_dh_1024 = NULL;
 static DH *local_dh_2048 = NULL;
 static DH *local_dh_4096 = NULL;
-static DH *ssl_get_tmp_dh(SSL *ssl, int export, int keylen);
+static DH *ssl_get_tmp_dh_cbk(SSL *ssl, int export, int keylen);
 #endif /* OPENSSL_NO_DH */
 
 #if (defined SSL_CTRL_SET_TLSEXT_HOSTNAME && !defined SSL_NO_GENERATE_CERTIFICATES)
@@ -2237,7 +2237,7 @@ ssl_sock_do_create_cert(const char *servername, struct bind_conf *bind_conf, SSL
        if (newcrt) X509_free(newcrt);
 
 #ifndef OPENSSL_NO_DH
-       SSL_CTX_set_tmp_dh_callback(ssl_ctx, ssl_get_tmp_dh);
+       SSL_CTX_set_tmp_dh_callback(ssl_ctx, ssl_get_tmp_dh_cbk);
 #endif
 
 #if (HA_OPENSSL_VERSION_NUMBER >= 0x10101000L)
@@ -3050,13 +3050,11 @@ static DH *ssl_get_dh_4096(void)
        return dh;
 }
 
-/* Returns Diffie-Hellman parameters matching the private key length
-   but not exceeding global_ssl.default_dh_param */
-static DH *ssl_get_tmp_dh(SSL *ssl, int export, int keylen)
+static DH *ssl_get_tmp_dh(EVP_PKEY *pkey)
 {
        DH *dh = NULL;
-       EVP_PKEY *pkey = SSL_get_privatekey(ssl);
        int type;
+       int keylen = 0;
 
        type = pkey ? EVP_PKEY_base_id(pkey) : EVP_PKEY_NONE;
 
@@ -3084,6 +3082,15 @@ static DH *ssl_get_tmp_dh(SSL *ssl, int export, int keylen)
        return dh;
 }
 
+/* Returns Diffie-Hellman parameters matching the private key length
+   but not exceeding global_ssl.default_dh_param */
+static DH *ssl_get_tmp_dh_cbk(SSL *ssl, int export, int keylen)
+{
+       EVP_PKEY *pkey = SSL_get_privatekey(ssl);
+
+       return ssl_get_tmp_dh(pkey);
+}
+
 HASSL_DH *ssl_sock_get_dh_from_bio(BIO *bio)
 {
 #if (HA_OPENSSL_VERSION_NUMBER >= 0x3000000fL)
@@ -3351,7 +3358,7 @@ static int ssl_sock_load_dh_params(SSL_CTX *ctx, const struct cert_key_and_chain
                        }
                }
                else {
-                       SSL_CTX_set_tmp_dh_callback(ctx, ssl_get_tmp_dh);
+                       SSL_CTX_set_tmp_dh_callback(ctx, ssl_get_tmp_dh_cbk);
                }
        }