EVP_SKEY(3SSL)
β¨ EVP_SKEY β¨
okay so bestie, this is the EVP_SKEY(3SSL) page from the OpenSSL fam β the one all about opaque symmetric key allocation and handling functions. Sit down, hydrate, we're learning key objects π
EVP_SKEY, EVP_SKEY_generate, EVP_SKEY_import, EVP_SKEY_import_raw_key, EVP_SKEY_import_SKEYMGMT, 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 β that's the whole lineup, no one's left out.
πΈ 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);
EVP_SKEY *EVP_SKEY_import_SKEYMGMT(OSSL_LIB_CTX *libctx, EVP_SKEYMGMT *skeymgmt,
int selection, const OSSL_PARAM *params);
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 π¦
EVP_SKEY is like... a generic lil structure that holds symmetric keys as opaque objects. The keys themselves get called the "internal key" all the time, and providers handle them through EVP_SKEYMGMT(3). iykyk.
So conceptually? An EVP_SKEY internal key may hold a symmetric key, and along with it, key parameters β but only if the key type requires them. Not every key is high-maintenance like that. π
EVP_SKEY_generate()β creates a newEVP_SKEYobject and initializes it according to the params argument. Fresh key, who dis.EVP_SKEY_import()β allocates an emptyEVP_SKEYstructure (which is what OpenSSL uses to store symmetric keys), assigns theEVP_SKEYMGMTobject associated with the key, and initializes the object from the params argument.EVP_SKEY_import_raw_key()β a lil helper that creates anEVP_SKEYobject holding the raw byte representation of the symmetric keys from the buffer key having length len. The skeymgmtname defines the name of the targetEVP_SKEYMGMTfor the newly created key.EVP_SKEY_import_SKEYMGMT()β another helper, this one creating anEVP_SKEYobject containing the representation of the symmetric keys specific to that particularEVP_SKEYMGMT.EVP_SKEY_export()β extracts values from a key skey using the selection. (selection is described below, don't worry.) It uses a callback export_cb that gets passed the value of export_cbarg. Peepopenssl-core.h(7)for more info about the callback. β οΈ Note that theOSSL_PARAM(3)array that is passed to the callback is not persistent after the callback returns β so don't be out here holding onto it like it's yours.EVP_SKEY_get0_raw_key()β returns a pointer to a raw key bytes to the passed address and sets the key len. The returned address is managed by the internal key management and shouldn't be freed explicitly. The operation can fail when the underlying key management doesn't support export of the secret key. π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. Gone. Poof. πEVP_SKEY_get0_skeymgmt_name()andEVP_SKEY_get0_provider_name()β return the names of the associatedEVP_SKEYMGMTobject and its provider, correspondingly. Matchy matchy.EVP_SKEY_up_ref()β increments the reference count of key. Bestie's getting popular.EVP_SKEY_free()β decrements the reference count of key and, if the reference count is zero, frees it. If key isNULL, nothing is done. No drama.EVP_SKEY_is_a()β checks if the key type of skey is name. Vibe check, basically.EVP_SKEY_to_provider()β simplifies the task of importing a skey into a different provider identified by prov. If prov isNULL, the default provider for the key type identified via skey is used.
π Selections π
These are the constants you can use for selection, and honestly? Pick your fighter:
OSSL_SKEYMGMT_SELECT_SECRET_KEYβ only the raw key representation will be selected. Just the secret, thank you. πOSSL_SKEYMGMT_SELECT_PARAMETERSβ only the key parameters will be selected. This includes optional key parameters too, we're inclusive here.OSSL_SKEYMGMT_SELECT_ALLβ all parameters will be selected. Give me everything, main character energy. β¨
Notes
The EVP_SKEY structure is used by various OpenSSL functions which require a general symmetric key without reference to any particular algorithm. Mysterious. Versatile. Iconic.
The EVP_SKEY_to_provider() function will fail and return NULL if the origin key skey cannot be exported from its provider. π«
Real talk: that's a documented failure mode, not a "huh it broke" moment. Plan for it.
π RETURN VALUES π
EVP_SKEY_generate(),EVP_SKEY_import(),EVP_SKEY_import_raw_key(), andEVP_SKEY_import_SKEYMGMT()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()returns1if skey has the key type name, otherwise0.EVP_SKEY_to_provider()returns a newEVP_SKEYsuitable for operations with the prov provider orNULLin case of failure.
π§ SEE ALSO π§
EVP_SKEYMGMT(3), provider(7), OSSL_PARAM(3) β go read those next, bestie, it's the whole friend group π«Ά
π HISTORY π
The EVP_SKEY API and the 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.
The EVP_SKEY_import_SKEYMGMT() function is the baby of the bunch β introduced in OpenSSL 4.0. Not me being late to the party, I'm just newer. π
π 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>.
and that's the whole page, bestie!! this was the OpenSSL 4.0.3 version, dated 2026-09-29 β go forth and hold your symmetric keys as the gorgeous opaque objects they were always meant to be. slay, no cap. πβ¨
π¦ where this page comes from
- ubuntu stonking: libssl-doc 4.0.3-1ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms