DH_SET_METHOD(3SSL)
π DH_SET_METHOD β okay bestie, let's talk about picking your DH method π
So this is the OpenSSL manual page DH_set_default_method(3ssl) and it's giving "legacy but make it cute" energy. Buckle up, we're doing cryptography selection drama β¨
πΈ NAME πΈ
DH_set_default_method, DH_get_default_method, DH_set_method, DH_new_method, DH_OpenSSL β select DH method π
β¨ SYNOPSIS β¨
First things first, you gotta include the header:
#include <openssl/dh.h>
Okay so important tea β β the following functions have been deprecated since OpenSSL 3.0, and you can hide them entirely by defining OPENSSL_API_COMPAT with a suitable version value. Check openssl_user_macros(7) for the deets π
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, real talk: all of the functions described on this page are deprecated. Applications should instead use the provider APIs. Not a vibe, but that's the law π«Ά
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. Fancy, right? π
Initially, the default DH_METHOD is the OpenSSL internal implementation, as returned by DH_OpenSSL().
DH_set_default_method()β makes meth the default method for allDHstructures created later. NB: this function is not thread-safe and should not be called at the same time as other OpenSSL functions. So likeβ¦ don't do that. Fr fr πDH_get_default_method()β returns a pointer to the current defaultDH_METHOD.DH_set_method()β selects meth to perform all operations using the key dh. This will replace theDH_METHODused by theDHkey. It is possible to haveDHkeys that only work with certainDH_METHODimplementations, and in such cases attempting to change theDH_METHODfor the key can have unexpected results. SeeDH_meth_new(3)for information on constructing customDH_METHODobjects. β οΈDH_new_method()β allocates and initializes aDHstructure. engine must beNULLand 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. It's giving silent, mysterious, no follow-up text energy πDH_set_method()β returns nonzero if the provided meth was successfully set as the method for dh.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. So like, check forNULL, bestie, don't be naive π
π SEE ALSO π
(yes, DH_new(3) is listed twice, and honestly? iconic. it said "say it again for the people in the back" π)
π HISTORY π
All of these functions were deprecated in OpenSSL 3.0. That's the whole history lesson, short and shady β
π COPYRIGHT π
Copyright 2000-2025 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>.
okay that's the whole page, you ate that π
This was version 4.0.3, dated 2026-09-29, straight from the OpenSSL crew β mwah, take care of your keys, hydrate, and never call DH_set_default_method() in a thread race π«Άβ¨π
π¦ where this page comes from
- ubuntu stonking: libssl-doc 4.0.3-1ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms