RSA_SIZE(3ossl)

πŸ’– RSA_SIZE(3ossl) β€” bestie, let's talk modulus math πŸ’–

okay so this is the manual page for RSA_SIZE(3ossl), and it's literally the trio of functions that tell you how big an RSA key is and how safe it is. small page, big vibes. let's go πŸ¦‹


✨ NAME ✨

RSA_size, RSA_bits, RSA_security_bits β€” get RSA modulus size or security bits πŸŽ€


🌸 SYNOPSIS 🌸

#include <openssl/rsa.h>

int RSA_bits(const RSA *rsa);

okay so heads up: 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 β€” go peek at openssl_user_macros(7) for the tea πŸ’…

int RSA_size(const RSA *rsa);

int RSA_security_bits(const RSA *rsa);

πŸ’œ DESCRIPTION πŸ’œ

RSA_bits() returns the number of significant bits. that's it, that's the whole job. slay.

important!! rsa and rsa->n must not be NULL. like, do not pass null in here. i'm begging 🫢

the remaining functions described on this page are deprecated, bestie. sad but true 😭 applications should instead use EVP_PKEY_get_size(3), EVP_PKEY_get_bits(3) and EVP_PKEY_get_security_bits(3). those are the main characters now.

RSA_size() returns the RSA modulus size in bytes. it can be used to determine how much memory must be allocated for an RSA encrypted value. so like, if you're about to malloc something for an encrypted blob, this is the number you want β€” not too much, not too little, just right πŸ“

RSA_security_bits() returns the number of security bits of the given rsa key. see BN_security_bits(3) for more on that.


⭐ RETURN VALUES ⭐

  • RSA_bits() returns the number of bits in the key.
  • RSA_size() returns the size of modulus in bytes.
  • RSA_security_bits() returns the number of security bits.

three functions, three little numbers, no cap ✨


πŸŽ€ SEE ALSO πŸŽ€


🌈 HISTORY 🌈

  • the RSA_size() and RSA_security_bits() functions were deprecated in OpenSSL 3.0. rip to a real one πŸ’€
  • the RSA_bits() function was added in OpenSSL 1.1.0. she's the new-ish girl but she ate πŸ‘‘

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 OpenSSL 3.5.9, dated 2026-09-29, and the page is RSA_SIZE(3ossl) β€” go forth and size your moduli responsibly πŸ’–βœ¨

πŸ“¦ where this page comes from