EVP_SKEY(3ossl)
π EVP_SKEY β the opaque symmetric key glow-up π
okay bestie, so this is the OpenSSL manual page for EVP_SKEY (section 3ossl), and it's literally the whole lore of opaque symmetric key allocation and handling. sit down, hydrate, we're doing keys today π«Ά
β¨ NAME β¨
EVP_SKEY, EVP_SKEY_generate, EVP_SKEY_import, EVP_SKEY_import_raw_key, EVP_SKEY_up_ref, EVP_SKEY_export, EVP_SKEY_get0_raw_key, EVP_SKEY_get0_key_id, EVP_SKEY_get0_skeymgmt_name, EVP_SKEY_get0_provider_name, EVP_SKEY_free, EVP_SKEY_is_a, EVP_SKEY_to_provider β opaque symmetric key allocation and handling functions π
πΈ SYNOPSIS πΈ
#include <openssl/evp.h>
typedef evp_skey_st EVP_SKEY;
EVP_SKEY *EVP_SKEY_generate(OSSL_LIB_CTX *libctx, const char *skeymgmtname,
const char *propquery, const OSSL_PARAM *params);
EVP_SKEY *EVP_SKEY_import(OSSL_LIB_CTX *libctx, const char *skeymgmtname,
const char *propquery,
int selection, const OSSL_PARAM *params);
EVP_SKEY *EVP_SKEY_import_raw_key(OSSL_LIB_CTX *libctx, const char *skeymgmtname,
unsigned char *key, size_t len,
const char *propquery);
int EVP_SKEY_export(const EVP_SKEY *skey, int selection,
OSSL_CALLBACK *export_cb, void *export_cbarg);
int EVP_SKEY_get0_raw_key(const EVP_SKEY *skey, const unsigned char **key,
size_t *len);
const char *EVP_SKEY_get0_key_id(const EVP_SKEY *skey);
const char *EVP_SKEY_get0_skeymgmt_name(const EVP_SKEY *skey);
const char *EVP_SKEY_get0_provider_name(const EVP_SKEY *skey);
int EVP_SKEY_up_ref(EVP_SKEY *key);
void EVP_SKEY_free(EVP_SKEY *key);
int EVP_SKEY_is_a(const EVP_SKEY *skey, const char *name);
EVP_SKEY *EVP_SKEY_to_provider(EVP_SKEY *skey, OSSL_LIB_CTX *libctx,
OSSL_PROVIDER *prov, const char *propquery);
like look at that signature list. it's giving β¨*organized*β¨
π DESCRIPTION π
EVP_SKEY is a generic structure that holds symmetric keys as opaque objects. the keys themselves are often called the "internal key", and they get handled by providers using EVP_SKEYMGMT(3). iykyk.
so conceptually? an EVP_SKEY internal key may hold a symmetric key, and along with that, key parameters if the key type is the kind of diva that requires them. π
EVP_SKEY_generate()β creates a brand newEVP_SKEYobject and initializes it according to theparamsargument. new key, who dis π₯EVP_SKEY_import()β allocates an emptyEVP_SKEYstructure (this is the one OpenSSL uses to store symmetric keys), assigns theEVP_SKEYMGMTobject associated with the key, and initializes the object from theparamsargument. it's giving "move in, decorate later" πEVP_SKEY_import_raw_key()β a lil helper bestie π«Ά it creates anEVP_SKEYobject containing the raw byte representation of the symmetric keys from the bufferkeyhaving lengthlen. theskeymgmtnamedefines the name of the targetEVP_SKEYMGMTfor the newly created key.EVP_SKEY_export()β extracts values from a keyskeyusing theselection.selectionis described below (spoiler: it's the Selections bit, scroll down babe). it uses a callbackexport_cbthat gets passed the value ofexport_cbarg. checkopenssl-core.h(7)for more info about the callback. β οΈ heads up: theOSSL_PARAM(3)array that's passed to the callback is not persistent after the callback returns. so don't be out here holding onto it like it's gonna text back πEVP_SKEY_get0_raw_key()β returns a pointer to the raw key bytes to the passed address and sets the keylen. the returned address is managed by the internal key management and shouldn't be freed explicitly. also? this operation can fail when the underlying key management doesn't support export of the secret key. no key for you πEVP_SKEY_get0_key_id()β returns aNUL-terminated string providing some human-readable identifier of the key, if provided by the underlying key management. the pointer becomes invalid after freeing theEVP_SKEYobject. use it, love it, then let it go πEVP_SKEY_get0_skeymgmt_name()andEVP_SKEY_get0_provider_name()β return the names of the associatedEVP_SKEYMGMTobject and its provider, correspondingly. name drop, but make it architecture β¨EVP_SKEY_up_ref()β increments the reference count ofkey. more refs, more love πEVP_SKEY_free()β decrements the reference count ofkeyand, if the reference count is zero, frees it. ifkeyisNULL, nothing is done. respectful. iconic. no notes. πEVP_SKEY_is_a()β checks if the key type ofskeyisname. vibe check fr fr.EVP_SKEY_to_provider()β simplifies the task of importing askeyinto a different provider identified byprov. ifprovisNULL, the default provider for the key type identified viaskeyis used. glowed up and moved providers, we love a relocation arc π¦
π Selections π
these are the constants you can use for selection:
OSSL_SKEYMGMT_SELECT_SECRET_KEYβ only the raw key representation will be selected. just the secret, nothing else, mysterious πOSSL_SKEYMGMT_SELECT_PARAMETERSβ only the key parameters will be selected. this includes optional key parameters. the accessories, the whole fit πOSSL_SKEYMGMT_SELECT_ALLβ all parameters will be selected. everything. the full lewk. π₯
π«Ά NOTES π«Ά
the EVP_SKEY structure is used by various OpenSSL functions which require a general symmetric key without reference to any particular algorithm. it's the versatile bestie of the key world.
β οΈ real talk: theEVP_SKEY_to_provider()function will fail and returnNULLif the origin keyskeycannot be exported from its provider. no export, no glow-up, periodt.
π RETURN VALUES π
EVP_SKEY_generate(),EVP_SKEY_import()andEVP_SKEY_import_raw_key()return either the newly allocatedEVP_SKEYstructure orNULLif an error occurred.EVP_SKEY_get0_key_id()returns either a valid pointer orNULL.EVP_SKEY_up_ref()returns1for success and0on failure.EVP_SKEY_export()andEVP_SKEY_get0_raw_key()return1for success and0on failure.EVP_SKEY_get0_skeymgmt_name()andEVP_SKEY_get0_provider_name()return the names of the associatedEVP_SKEYMGMTobject and its provider correspondingly.EVP_SKEY_is_a()returns1ifskeyhas the key typename, otherwise0.EVP_SKEY_to_provider()returns a newEVP_SKEYsuitable for operations with theprovprovider orNULLin case of failure.
like 1 = slay, 0 = not slay. simple as. β¨
π SEE ALSO π
EVP_SKEYMGMT(3), provider(7), OSSL_PARAM(3)
β HISTORY β
the EVP_SKEY API and functions EVP_SKEY_export(), EVP_SKEY_free(), EVP_SKEY_get0_raw_key(), EVP_SKEY_import(), EVP_SKEY_import_raw_key(), EVP_SKEY_up_ref(), EVP_SKEY_generate(), EVP_SKEY_get0_key_id(), EVP_SKEY_get0_provider_name(), EVP_SKEY_get0_skeymgmt_name(), EVP_SKEY_is_a(), EVP_SKEY_to_provider() were introduced in OpenSSL 3.5. they're new new. fresh off the press. π
π COPYRIGHT π
Copyright 2025-2026 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're officially keypilled πβ¨ this was EVP_SKEY(3ossl) from OpenSSL 3.5.9, dated 2026-09-29 β go forth and handle those opaque symmetric keys responsibly, mwah ππ¦
π¦ 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