---
name: "libressl-EVP_PKEY_size"
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-EVP_PKEY_size"
---

# libressl-EVP\_PKEY\_size(3)

EVP\_PKEY information functions

## NAME

**EVP\_PKEY\_size**, **EVP\_PKEY\_bits**, **EVP\_PKEY\_security\_bits** – EVP\_PKEY information functions

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

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

*int*\

**EVP\_PKEY\_size**(*const EVP\_PKEY \*pkey*);

*int*\

**EVP\_PKEY\_bits**(*const EVP\_PKEY \*pkey*);

*int*\

**EVP\_PKEY\_security\_bits**(*const EVP\_PKEY \*pkey*);

## DESCRIPTION

**EVP\_PKEY\_size**() returns the maximum size in bytes needed for the output buffer for almost any operation that can be done with *pkey*. The primary use is with EVP\_SignFinal(3) and EVP\_SealInit(3). The returned size is also large enough for the output buffer of EVP\_PKEY\_sign(3), EVP\_PKEY\_encrypt(3), EVP\_PKEY\_decrypt(3), and EVP\_PKEY\_derive(3).

Unless the documentation for the operation says otherwise, the size returned by **EVP\_PKEY\_size**() is only an upper limit and the final content of the target buffer may be smaller. It is therefore crucial to take note of the size given back by the function that performs the operation. For example, EVP\_PKEY\_sign(3) returns that length in the \**siglen* argument.

Using **EVP\_PKEY\_size**() is discouraged with EVP\_DigestSignFinal(3).

Most functions using an output buffer support passing NULL for the buffer and a pointer to an integer to get the exact size that this function call delivers in the context that it is called in. This allows those functions to be called twice, once to find out the exact buffer size, then allocate the buffer in between, and call that function again to actually output the data. For those functions, it isn't strictly necessary to call **EVP\_PKEY\_size**() to find out the buffer size, but it may still be useful in cases where it's desirable to know the upper limit in advance.

**EVP\_PKEY\_size**() is supported for the following algorithms:

| | |
| --- | --- |
|  | same result as from: |
| CMAC | EVP\_MAX\_BLOCK\_LENGTH = 32 |
| DH | DH\_size(3) |
| DSA | DSA\_size(3) |
| EC | ECDSA\_size(3) |
| ED25519 | 64, but see below |
| HMAC | EVP\_MAX\_MD\_SIZE = 64 |
| RSA | RSA\_size(3) |
| X25519 | X25519\_KEYLEN = 32 |

For EVP\_PKEY\_ED25519, the situation is special: while the key size is ED25519\_KEYLEN = 32 bytes, **EVP\_PKEY\_size**() returns 64 because the signature is longer than the keys.

**EVP\_PKEY\_bits**() returns the cryptographic length of the cryptosystem to which the key in *pkey* belongs, in bits. The definition of cryptographic length is specific to the key cryptosystem. The following algorithms are supported:

| | | |
| --- | --- | --- |
|  | cryptographic length = | same result as from: |
|  | significant bits in ... |  |
| DH | the public domain parameter *p* | DH\_bits(3) |
| DSA | the public domain parameter *p* | DSA\_bits(3) |
| EC | the order of the group | EC\_GROUP\_order\_bits(3) |
| ED25519 | 253 | — |
| RSA | the public modulus | RSA\_bits(3) |
| X25519 | 253 | — |

**EVP\_PKEY\_security\_bits**() returns the security strength measured in bits of the given *pkey* as defined in NIST SP800-57. The following algorithms are supported:

| | |
| --- | --- |
|  | same result as from: |
| DH | DH\_security\_bits(3) |
| DSA | DSA\_security\_bits(3) |
| EC | EC\_GROUP\_order\_bits(3) divided by 2 |
| ED25519 | 128 |
| RSA | RSA\_security\_bits(3) |
| X25519 | 128 |

For EC keys, if the result is greater than 80, it is rounded down to 256, 192, 128, 112, or 80.

## RETURN VALUES

**EVP\_PKEY\_size**() and **EVP\_PKEY\_bits**() return a positive number or 0 if this size isn't available.

**EVP\_PKEY\_security\_bits**() returns a number in the range from 0 to 256 inclusive or -2 if this function is unsupported for the algorithm used by *pkey*. It returns 0 if *pkey* is NULL.

## SEE ALSO

EVP\_PKEY\_decrypt(3), EVP\_PKEY\_derive(3), EVP\_PKEY\_encrypt(3), EVP\_PKEY\_new(3), EVP\_PKEY\_sign(3), EVP\_SealInit(3), EVP\_SignFinal(3)

## HISTORY

**EVP\_PKEY\_size**() first appeared in SSLeay 0.6.0 and **EVP\_PKEY\_bits**() in SSLeay 0.9.0. Both functions have been available since OpenBSD 2.4.

**EVP\_PKEY\_security\_bits**() first appeared in OpenSSL 1.1.0 and has been available since OpenBSD 7.2.
