---
name: "EVP_PKEY_todata"
section: "3ssl"
platform: "linux"
package: "openssl"
version: "3.6.5-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/EVP_PKEY_todata"
---

# EVP\_PKEY\_todata(3ssl)

functions to return keys as an array of key parameters

## NAME

EVP\_PKEY\_todata, EVP\_PKEY\_export - functions to return keys as an array of key parameters

## SYNOPSIS

```
 #include <openssl/evp.h>
 int EVP_PKEY_todata(const EVP_PKEY *pkey, int selection, OSSL_PARAM **params);
 int EVP_PKEY_export(const EVP_PKEY *pkey, int selection,
                     OSSL_CALLBACK *export_cb, void *export_cbarg);
```

## DESCRIPTION

The functions described here are used to extract **EVP\_PKEY** key values as an array of **OSSL\_PARAM**(3).

**EVP\_PKEY\_todata()** extracts values from a key *pkey* using the *selection*. *selection* is described in "Selections" in **EVP\_PKEY\_fromdata**(3). **OSSL\_PARAM\_free**(3) should be used to free the returned parameters in *\*params*.

**EVP\_PKEY\_export()** is similar to **EVP\_PKEY\_todata()** but uses a callback *export\_cb* that gets passed the value of *export\_cbarg*. See **openssl-core.h**(7) for more information about the callback. Note that the **OSSL\_PARAM**(3) array that is passed to the callback is not persistent after the callback returns. The user must preserve the items of interest, or use **EVP\_PKEY\_todata()** if persistence is required.

## NOTES

These functions only work with key management methods coming from a provider. This is the mirror function to **EVP\_PKEY\_fromdata**(3).

LMS support is disabled by default at compile-time. To enable, specify the **enable-lms** build configuration option.

## RETURN VALUES

**EVP\_PKEY\_todata()** and **EVP\_PKEY\_export()** return 1 for success and 0 for failure.

## SEE ALSO

**OSSL\_PARAM**(3), **openssl-core.h**(7), **EVP\_PKEY\_fromdata**(3), **EVP\_PKEY-RSA**(7), **EVP\_PKEY-EC**(7), **EVP\_PKEY-DSA**(7), **EVP\_PKEY-ED25519**(7) **EVP\_PKEY-ED448**(7), **EVP\_PKEY-DH**(7), **EVP\_PKEY-X25519**(7), **EVP\_PKEY-X448**(7), **EVP\_PKEY-LMS**(7), **EVP\_PKEY-ML-DSA**(7), **EVP\_PKEY-ML-KEM**(7), **EVP\_PKEY-SLH-DSA**(7).

## HISTORY

These functions were added in OpenSSL 3.0.

Support for **ML-DSA**, **ML-KEM** and **SLH-DSA** was added in OpenSSL 3.5.

Support for **LMS** was added in OpenSSL 3.6.

## COPYRIGHT

Copyright 2021-2025 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\>.
