DH_SET_METHOD(3ossl)
π NAME π
DH_set_default_method, DH_get_default_method, DH_set_method, DH_new_method, DH_OpenSSL β select DH method. This is the OpenSSL manual page, bestie, and yes we're keeping every single one of those function names.
β¨ SYNOPSIS β¨
#include <openssl/dh.h>
The following functions have been deprecated since OpenSSL 3.0, and can be hidden entirely by defining OPENSSL_API_COMPAT with a suitable version value, see openssl_user_macros(7):
void DH_set_default_method(const DH_METHOD *meth);
const DH_METHOD *DH_get_default_method(void);
int DH_set_method(DH *dh, const DH_METHOD *meth);
DH *DH_new_method(ENGINE *engine);
const DH_METHOD *DH_OpenSSL(void);
πΈ DESCRIPTION πΈ
Okay so first things first: all of the functions described on this page are deprecated. Applications should instead use the provider APIs. That's the whole vibe check here.
A DH_METHOD specifies the functions that OpenSSL uses for Diffie-Hellman operations. By modifying the method, alternative implementations such as hardware accelerators may be used.
IMPORTANT: See the NOTES section for important information about how these DH API functions are affected by the use of ENGINE API calls.
Initially, the default DH_METHOD is the OpenSSL internal implementation, as returned by DH_OpenSSL().
DH_set_default_method()β makesmeththe default method for allDHstructures created later. NB: This is true only whilst noENGINEhas been set as a default forDH, so this function is no longer recommended. This function is not thread-safe and should not be called at the same time as other OpenSSL functions. Pls respect the thread-safety warning, bestie.DH_get_default_method()β returns a pointer to the current defaultDH_METHOD. However, the meaningfulness of this result is dependent on whether theENGINEAPI is being used, so this function is no longer recommended.DH_set_method()β selectsmethto perform all operations using the keydh. This will replace theDH_METHODused by theDHkey and if the previous method was supplied by anENGINE, the handle to thatENGINEwill be released during the change. It is possible to haveDHkeys that only work with certainDH_METHODimplementations (e.g. from anENGINEmodule that supports embedded hardware-protected keys), and in such cases attempting to change theDH_METHODfor the key can have unexpected results. So likeβ¦ be careful with that one.DH_new_method()β allocates and initializes aDHstructure so thatenginewill be used for theDHoperations. IfengineisNULL, the defaultENGINEforDHoperations is used, and if no defaultENGINEis set, theDH_METHODcontrolled byDH_set_default_method()is used.
A new DH_METHOD object may be constructed using DH_meth_new() (see DH_meth_new(3)).
π RETURN VALUES π
DH_OpenSSL()andDH_get_default_method()return pointers to the respectiveDH_METHODs.DH_set_default_method()returns no value. Literally nothing. void energy.DH_set_method()returns nonzero if the providedmethwas successfully set as the method fordh(including unloading theENGINEhandle if the previous method was supplied by anENGINE).DH_new_method()returnsNULLand sets an error code that can be obtained byERR_get_error(3)if the allocation fails. Otherwise it returns a pointer to the newly allocated structure.
π₯ SEE ALSO π₯
Not a typo β the original lists DH_new(3) twice, and we're keeping it twice. Iconic.
π¦ HISTORY π¦
All of these functions were deprecated in OpenSSL 3.0. Yes, all of them. The whole squad.
π COPYRIGHT π
Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.
This page is from OpenSSL 3.5.0, dated 2026-09-25. Bye bestie, go use the provider APIs πβ¨
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms