---
name: "libressl-RSA_security_bits"
section: "3"
platform: "linux"
package: "libressl"
version: "4.4.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/libressl-RSA_security_bits"
---

# libressl-RSA\_security\_bits(3)

get security strength

## NAME

**RSA\_security\_bits**, **DSA\_security\_bits**, **DH\_security\_bits**, **BN\_security\_bits** – get security strength

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

**#include \<openssl/rsa.h\>**

*int*\

**RSA\_security\_bits**(*const RSA \*rsa*);

**#include \<openssl/dsa.h\>**

*int*\

**DSA\_security\_bits**(*const DSA \*dsa*);

**#include \<openssl/dh.h\>**

*int*\

**DH\_security\_bits**(*const DH \*dh*);

**#include \<openssl/bn.h\>**

*int*\

**BN\_security\_bits**(*int pubbits*, *int privbits*);

## DESCRIPTION

These functions return the security strength of some specific types of cryptographic keys, measured in bits. It is approximately the binary logarithm of the number of operations an attacker has to perform in order to break the key.

**RSA\_security\_bits**() uses only the number of significant bits in the public modulus of *rsa* as returned by RSA\_bits(3). It returns

| | | | |
| --- | --- | --- | --- |
| 256 | for | 15360 | or more significant bits |
| 192 |  | 7680 |  |
| 128 |  | 3072 |  |
| 112 |  | 2048 |  |
| 80 |  | 1024 |  |

or 0 otherwise.

**DSA\_security\_bits**() uses the number of significant bits in the public domain parameter *p* contained in the *dsa* object, which is equal to the size of the public key, in the same way as **RSA\_security\_bits**(). In addition, the public domain parameter *q* contained in the *dsa* object, which is equal to the size of the private key, is inspected. The return value is either the security strength according to the above table or half the size of the private key, whichever is smaller. If the return value would be smaller than 80, 0 is returned instead.

**DH\_security\_bits**() uses the number of significant bits in the shared secret contained in the *dh* object as returned by DH\_bits(3) in the same way as **RSA\_security\_bits**(). If *dh* contains the domain parameter *q*, its number of significant bits is used in the same way as for **DSA\_security\_bits**() to limit the return value. Otherwise, if *dh* contains the length of the secret exponent in bits, that number is used. If neither is available, only the above table is used without calculating a minimum.

**BN\_security\_bits**() is a combined function. If -1 is passed for the *privbits* argument, it behaves like **RSA\_security\_bits**(). Otherwise, it behaves like **DSA\_security\_bits**().

## RETURN VALUES

All these functions return numbers in the range from 0 to 256 inclusive.

**DSA\_security\_bits**() fails and returns -1 unless both of the *p* and *q* domain parameters are present.

## SEE ALSO

BN\_num\_bits(3), DH\_bits(3), DH\_get0\_pqg(3), DSA\_get0\_pqg(3), RSA\_bits(3), SSL\_CTX\_set\_security\_level(3) Elaine Barker, *Recommendation for Key Management*, NIST Special Publication 800-57 Part 1 Revision 5, U.S. National Institute of Standards and Technology, Gaithersburg, MD, May 2020, https://doi.org/10.6028/NIST.SP.800-57pt1r5.

## HISTORY

These functions first appeared in OpenSSL 1.1.0 and have been available since OpenBSD 7.2.
