DH_NEW(3SSL)
π DH_NEW(3SSL) β the OpenSSL girlies' guide to DH objects π
okay so bestie, we're in the OpenSSL manual, page DH_NEW(3SSL), and today's topic is literally just making and unmaking DH objects. lowkey the most basic thing ever but somebody's gotta explain it, so here I am π«Ά
β¨ NAME β¨
DH_new, DH_free β allocate and free DH objects. that's it. that's the whole job. iconic honestly π
πΈ SYNOPSIS πΈ
first, you gotta pull in the header:
#include <openssl/dh.h>
now, heads up babes β 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. wanna know what "suitable" means? go read openssl_user_macros(7) π
DH* DH_new(void);
void DH_free(DH *dh);
not me writing deprecated code in the group chat π anyway here are the signatures, character for character, don't @ me.
π DESCRIPTION π
DH_new()β allocates and initializes aDHstructure. it's giving "new beginnings", it's giving main character energy β¨DH_free()β frees theDHstructure and its components. and here's the part that's actually kind of hot: the values are erased before the memory is handed back to the system. like, wiped. goodbye. no leftovers π§Ή and ifdhisNULL, nothing happens at all β no crash, no drama, just vibes.
π RETURN VALUES π
- if the allocation fails,
DH_new()returnsNULLand sets an error code that you can grab withERR_get_error(3). otherwise? it returns a pointer to the newly allocated structure. slay π DH_free()returns no value. it's avoid. it does the thing and leaves. king behavior π
π¦ SEE ALSO π¦
go read those next bestie, i'll wait π
β HISTORY β
all of these functions were deprecated in OpenSSL 3.0.
for the replacement, see EVP_PKEY-DH(7). yes this is me gently telling you to move on, it's not you it's the API π
π 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 fr fr π this was DH_NEW(3SSL), from OpenSSL 4.0.3, dated 2026-09-29. periodt. now go free your memory before you leak it, i'm obsessed with you πβ¨
π¦ 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