DH_SIZE(3ossl)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1

πŸ’… DH_SIZE(3ossl) β€” like, the OpenSSL manual, but make it make sense 🫢

okay so bestie, welcome to the DH_SIZE(3ossl) page of the OpenSSL manual πŸ’– this is where we learn how to get the Diffie-Hellman prime size and the security bits, and honestly? it's giving "small but mighty." no cap.


✨ NAME ✨

DH_size, DH_bits, DH_security_bits β€” get the Diffie-Hellman prime size and the security bits 🌸


πŸŽ€ SYNOPSIS πŸŽ€

#include <openssl/dh.h>

so like, heads up bestie πŸ™ˆ β€” the functions below have been deprecated since OpenSSL 3.0, and you can hide them entirely by defining OPENSSL_API_COMPAT with a suitable version value. see openssl_user_macros(7) for the deets ✨

int DH_bits(const DH *dh);

int DH_size(const DH *dh);

int DH_security_bits(const DH *dh);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so first thing first: the functions on this page are deprecated πŸ’€ like, they still work, but they're not the moment anymore. applications should instead use EVP_PKEY_get_bits(3), EVP_PKEY_get_security_bits(3) and EVP_PKEY_get_size(3). slay, moving on πŸ’…

  • DH_bits() β€” returns the number of significant bits ✨
🚨 tiny but crucial: dh and dh->p must not be NULL. like, don't do that. please. 😭
  • DH_size() β€” returns the Diffie-Hellman prime size in bytes. it's literally the glow-up you need to figure out how much memory must be allocated for the shared secret computed by DH_compute_key(3) 🧚
  • DH_security_bits() β€” returns the number of security bits of the given dh key. see BN_security_bits(3) for the full vibe check πŸ”₯

⭐ RETURN VALUES ⭐

  • DH_bits() β€” returns the number of bits in the key, or -1 if dh doesn't hold any key parameters πŸ™ˆ
  • DH_size() β€” returns the prime size of Diffie-Hellman in bytes, or -1 if dh doesn't hold any key parameters πŸ’€
  • DH_security_bits() β€” returns the number of security bits, or -1 if dh doesn't hold any key parameters 😭
so yeah, if you see a -1 it's not a personality trait, it means dh is out here holding zero key parameters. empty-handed. iconic but unhelpful 🫢

🌈 SEE ALSO 🌈

go read those too, iykyk πŸ’œ


πŸ‘‘ HISTORY πŸ‘‘

all of these functions were deprecated in OpenSSL 3.0. that's the whole saga. periodt. πŸ’…


Copyright 2000-2021 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 page bestie! πŸ’– this was version 3.5.6, dated 2026-04-07, filed under DH_SIZE(3ossl) β€” go forth and check your bits responsibly, mwah πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from