RSA_SIZE(3ossl)
π RSA_SIZE β get that RSA modulus size or security bits, bestie (3ossl)
okay so real talk, this page is your cheat sheet for asking an RSA key how big it is β whether you want it in bits, in bytes, or in security bits. three little functions, one of them still iconic and current, the other two lowkey retired. let's get into it π«Ά
β¨ SYNOPSIS β¨
drop this include first, obviously:
#include <openssl/rsa.h>
here's the one that's still living her best life:
int RSA_bits(const RSA *rsa);
and then the deprecated girlies β these 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):
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 vibe β¨
β οΈ heads up bestie:rsaandrsa->nmust not beNULL. like, do not do that. not a slay.
the remaining functions described on this page are deprecated π applications should instead use EVP_PKEY_get_size(3), EVP_PKEY_get_bits(3) and EVP_PKEY_get_security_bits(3). yes, all three. go follow them instead, they're 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, this is your "how big is this gonna be" function π
RSA_security_bits() returns the number of security bits of the given rsa key. see BN_security_bits(3) for the deets π
π RETURN VALUES π
RSA_bits()β returns the number of bits in the key.RSA_size()β returns the size of the modulus in bytes.RSA_security_bits()β returns the number of security bits.
three functions, three different units, do not mix them up, i'm begging π
π¦ SEE ALSO π¦
iykyk, go read it π
π HISTORY π
- the
RSA_size()andRSA_security_bits()functions were deprecated in OpenSSL 3.0. rip to them but they're still here. - the
RSA_bits()function was added in OpenSSL 1.1.0. our queen π
π COPYRIGHT π
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>.
okay that's the whole page, bestie, you did it, go forth and check your modulus sizes responsibly πβ¨π
π§ this was version3.5.0, dated2026-09-25, from the3osslmanual section β periodt. π
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms