DH_NEW(3ossl)
π DH_NEW β bestie, let's talk about allocating and freeing DH objects π
okay so real talk: this is from the OpenSSL manual, section 3ossl, and it's a little bit of a legacy situation, but we're gonna get through it together. π«Ά
β¨ NAME β¨
DH_new, DH_free β allocate and free DH objects. that's it, that's the whole vibe. π
πΈ SYNOPSIS πΈ
#include <openssl/dh.h>
β οΈ heads up bestie β the following functions have been deprecated since OpenSSL 3.0, and can be hidden entirely by definingOPENSSL_API_COMPATwith a suitable version value, seeopenssl_user_macros(7). so likeβ¦ they still work, but the library is lowkey giving you side-eye. π
DH* DH_new(void);
void DH_free(DH *dh);
π¦ DESCRIPTION π¦
DH_new()β allocates and initializes aDHstructure. it's giving "fresh start, new me, main character energy". β¨DH_free()β frees theDHstructure and its components. and the way that it does this?? the values are erased before the memory is returned to the system β that's right, it wipes them down first, no leftover secrets in your RAM, we love a hygienic icon. π§Όπ
oh and also: if dh is NULL, nothing is done. no crash, no drama, just vibes. π
π RETURN VALUES π
DH_new()β if the allocation fails, it returnsNULLand sets an error code that can be obtained byERR_get_error(3). otherwise it returns a pointer to the newly allocated structure. slay. π₯DH_free()β returns no value. literally nothing. void. it's above returning things. π
π SEE ALSO π
DH_new(3), ERR_get_error(3), DH_generate_parameters(3), DH_generate_key(3), EVP_PKEY-DH(7)
(yes DH_new(3) is in there. it's referencing itself. iconic self-referential behavior, no notes. π
)
π HISTORY π
all of these functions were deprecated in OpenSSL 3.0. π
for the replacement, go look at EVP_PKEY-DH(7) β that's your new bestie now, fr fr.
π COPYRIGHT π
Copyright 2000-2016 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>.
and that's the whole page, bestie β stay safe out there, free your structs, and remember to erase your values before you hand the memory back π«Άβ¨
version 3.5.0 Β· dated 2026-09-25 Β· DH_NEW(3ossl) Β· mwah π
π¦ 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