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 a DH structure. it's giving "new beginnings", it's giving main character energy ✨
  • DH_free() β€” frees the DH structure 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 if dh is NULL, nothing happens at all β€” no crash, no drama, just vibes.

πŸŽ€ RETURN VALUES πŸŽ€

  • if the allocation fails, DH_new() returns NULL and sets an error code that you can grab with ERR_get_error(3). otherwise? it returns a pointer to the newly allocated structure. slay πŸ’–
  • DH_free() returns no value. it's a void. 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 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