DH_NEW(3ossl)

πŸ“¦ version 3.5.0, in opensuse-leap 16.0

πŸ’– 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 defining OPENSSL_API_COMPAT with a suitable version value, see openssl_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 a DH structure. it's giving "fresh start, new me, main character energy". ✨
  • DH_free() β€” frees the DH structure 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 returns NULL and sets an error code that can be obtained by ERR_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 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