EVP_SKEY(3ossl)
π EVP_SKEY β opaque symmetric key allocation and handling functions π
okay bestie, so this is the OpenSSL manual page EVP_SKEY(3ossl) and it's genuinely one of the cutest little abstractions in the whole crypto library. it's all about wrapping up symmetric keys in a nice opaque lil package so you can pass them around without poking at their insides. main character energy fr fr π
the cast of characters you're getting here (this is the NAME section, just with way more sparkle): 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, and EVP_SKEY_to_provider β collectively the opaque symmetric key allocation and handling functions. iconic lineup, no notes. β¨
πΈ 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);
π¦ DESCRIPTION π¦
so. EVP_SKEY is this generic structure that holds symmetric keys as opaque objects β meaning you don't get to stare directly at the bytes, you just trust the vibes and the API. the keys inside are often called the "internal key", and they're handled by providers using EVP_SKEYMGMT(3). π
conceptually (love that word), an EVP_SKEY internal key may hold a symmetric key, and along with those, key parameters if the key type requires them. so it's like, key + accessories. the key type decides if it needs the accessories. π
let's go through the functions one by one, because i love a list:
EVP_SKEY_generate()β creates a newEVP_SKEYobject and initializes it according to theparamsargument. freshly baked key, chef's kiss. πEVP_SKEY_import()β allocates an emptyEVP_SKEYstructure which is used by OpenSSL to store symmetric keys, assigns theEVP_SKEYMGMTobject associated with the key, and initializes the object from theparamsargument. it's giving "build-a-key workshop". β¨EVP_SKEY_import_raw_key()β a helper that creates anEVP_SKEYobject containing the raw byte representation of the symmetric keys. lowkey the shortcut function and we respect it. π₯EVP_SKEY_export()β extracts values from a keyskeyusing theselection.selectionis described below (scroll down bestie, it's the Selections bit). it uses a callbackexport_cbthat gets passed the value ofexport_cbarg. seeopenssl-core.h(7)for more information about the callback. β οΈ and heads up, theOSSL_PARAM(3)array that is passed to the callback is not persistent after the callback returns β so don't go stashing that pointer anywhere, it ghosts you immediately. πEVP_SKEY_get0_raw_key()β returns a pointer to a 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 β hands off, it's not yours, no cap. the operation can fail when the underlying key management doesn't support export of the secret key. πEVP_SKEY_get0_key_id()β returns a NUL-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. so like, it's a borrow, not a gift. π«ΆEVP_SKEY_get0_skeymgmt_name()andEVP_SKEY_get0_provider_name()β return the names of the associatedEVP_SKEYMGMTobject and its provider correspondingly. matching set, adorable. πEVP_SKEY_up_ref()β increments the reference count ofkey. girl math: one becomes two, but it's the same key. πEVP_SKEY_free()β decrements the reference count ofkeyand, if the reference count is zero, frees it. ifkeyisNULL, nothing is done. very chill, very "no worries if not". β¨EVP_SKEY_is_a()β checks if the key type ofskeyisname. vibe check on the key type, literally. π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. it's the key's passport-renewal function. π§
π Selections π
the following constants can be used for selection:
OSSL_SKEYMGMT_SELECT_SECRET_KEYβ only the raw key representation will be selected.OSSL_SKEYMGMT_SELECT_PARAMETERSβ only the key parameters will be selected. this includes optional key parameters. (optional!! fancee)OSSL_SKEYMGMT_SELECT_ALLβ all parameters will be selected. the "give me everything" option. π
π NOTES π
the EVP_SKEY structure is used by various OpenSSL functions which require a general symmetric key without reference to any particular algorithm. so it's the social butterfly of key types β algorithm-agnostic and ready to mingle. π¦
β οΈ important caveat bestie: theEVP_SKEY_to_provider()function will fail and returnNULLif the origin keyskeycannot be exported from its provider. no export, no travel. that's the rule. π
β 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 correspondigly. (yes, the manpage really does spell it "correspondigly" β i'm keeping it exactly as-is because we don't edit the sacred text ππ)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.
π 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. new drop, era-defining, we were all there. π
π COPYRIGHT π
Copyright 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>.
and that's the whole page bestie!! π«Ά this was version 3.5.0, dated 2026-09-25, filed under EVP_SKEY(3ossl) β go forth and handle those symmetric keys opaquely, mwah ππΈ
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms