EVP_PKEY_TODATA(3ossl)
β¨ EVP_PKEY_TODATA β¨
okay so bestie, welcome to the OpenSSL manual page for EVP_PKEY_todata and EVP_PKEY_export β the two functions whose whole job is handing you your key's values as an array of key parameters. it's giving "unpack your bags, we're staying" π
πΈ 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 π
So the functions we're talking about here are the ones you use to pull the actual values out of an EVP_PKEY key and get them back as an array of OSSL_PARAM(3). like, the key goes in, the little parameter array comes out. iconic behaviour, no notes β¨
EVP_PKEY_todata()β this one extracts values from a keypkeyusing theselection. and what even isselection, you ask? it's described over in "Selections" inEVP_PKEY_fromdata(3), go check it out π«Ά. and listen, when you're done with the params it gives you, you must useOSSL_PARAM_free(3)to free the returned parameters in*params. don't just leave them lying around, that's not the vibe πEVP_PKEY_export()β this is basicallyEVP_PKEY_todata()'s sibling, except instead of handing you a params array directly it uses a callbackexport_cb, and it passes that callback the value ofexport_cbarg. seeopenssl-core.h(7)for more info about how that callback works π¦
π¨ okay this part is IMPORTANT bestie: theOSSL_PARAM(3)array that gets passed to the callback is not persistent after the callback returns. like it's gone, it's not sticking around, it said "my work here is done". so if you need any of those items later you have to preserve the items you actually care about yourself, or just useEVP_PKEY_todata()instead if persistence is what you're after. periodt π
π NOTES π
These functions only work with key management methods coming from a provider. no provider, no party π
Also, this is the mirror function to EVP_PKEY_fromdata(3). yes, they're mirrors, they're the same picture, one goes in and one comes out, we love a matching set π
π RETURN VALUES π
EVP_PKEY_todata() and EVP_PKEY_export() return 1 for success and 0 for failure. that's it, that's the whole range. 1 = slay, 0 = not slay π
π₯ 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-ML-DSA(7)EVP_PKEY-ML-KEM(7)EVP_PKEY-SLH-DSA(7)
π¦ HISTORY π¦
- These functions were added in OpenSSL 3.0. a classic, a legend, an elder π
- Support for ML-DSA, ML-KEM and SLH-DSA was added in OpenSSL 3.5. new girls on the block, and they ate π
π 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>.
okay that's the whole page bestie, go forth and export those key params responsibly π«Ά this has been the EVP_PKEY_TODATA(3ossl) page from OpenSSL 3.5.9, dated 2026-09-29 β mwah, drink water, free your OSSL_PARAMs β¨ππ§
π¦ where this page comes from
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms