EVP_KEM_FREE(3ossl)
π EVP_KEM_FREE β the girlies' guide to managing EVP_KEM algorithm objects π
okay so bestie, this is a page from the OpenSSL manual, section 3ossl, and it's literally all about how you hold, fetch, poke at and let go of EVP_KEM algorithm objects. no cap, it's giving "reference counting but make it cute". let's get into it π«Ά
β¨ NAME β¨
EVP_KEM_fetch, EVP_KEM_free, EVP_KEM_up_ref, EVP_KEM_get0_name, EVP_KEM_is_a, EVP_KEM_get0_provider, EVP_KEM_do_all_provided, EVP_KEM_names_do_all, EVP_KEM_get0_description, EVP_KEM_gettable_ctx_params, EVP_KEM_settable_ctx_params β these are the functions that manage EVP_KEM algorithm objects. that's the whole vibe π
πΈ SYNOPSIS πΈ
like, here's exactly what you type, verbatim, don't @ me:
#include <openssl/evp.h>
EVP_KEM *EVP_KEM_fetch(OSSL_LIB_CTX *ctx, const char *algorithm,
const char *properties);
void EVP_KEM_free(EVP_KEM *kem);
int EVP_KEM_up_ref(EVP_KEM *kem);
const char *EVP_KEM_get0_name(const EVP_KEM *kem);
int EVP_KEM_is_a(const EVP_KEM *kem, const char *name);
OSSL_PROVIDER *EVP_KEM_get0_provider(const EVP_KEM *kem);
void EVP_KEM_do_all_provided(OSSL_LIB_CTX *libctx,
void (*fn)(EVP_KEM *kem, void *arg), void *arg);
int EVP_KEM_names_do_all(const EVP_KEM *kem,
void (*fn)(const char *name, void *data), void *data);
const char *EVP_KEM_get0_description(const EVP_KEM *kem);
const OSSL_PARAM *EVP_KEM_gettable_ctx_params(const EVP_KEM *kem);
const OSSL_PARAM *EVP_KEM_settable_ctx_params(const EVP_KEM *kem);
π¦ DESCRIPTION π¦
EVP_KEM_fetch() goes and fetches the implementation for the given algorithm from any provider offering it, inside the criteria you gave it with properties, and within the scope of the given library context ctx (peep OSSL_LIB_CTX(3) for that one). the algorithm is gonna be one of those offering functions for doing asymmetric kem related tasks, like key encapsulation and decapsulation. for the full tea, check out "ALGORITHM FETCHING" in crypto(7).
β¨ the returned value must eventually be freed with EVP_KEM_free(). like, eventually bestie. don't just leave it there.
EVP_KEM_free() decrements the reference count for the EVP_KEM structure. typically this structure came from an earlier call to EVP_KEM_fetch(). if the reference count drops all the way to 0, then the structure gets freed. and if the argument is NULL? nothing happens, we simply do not engage π
EVP_KEM_up_ref() increments the reference count for an EVP_KEM structure. it's the opposite of free, the yin to its yang, the up to its down.
EVP_KEM_is_a() returns 1 if kem is an implementation of an algorithm that's identifiable with name, otherwise 0. it's a vibe check for algorithms, fr fr.
EVP_KEM_get0_provider() returns the provider that kem was fetched from. like, who's your provider bestie? π
EVP_KEM_do_all_provided() traverses all EVP_KEMs implemented by all activated providers in the given library context libctx, and for each of the implementations, calls the given function fn with the implementation method and the given arg as argument. it's a whole parade, and every EVP_KEM gets its moment on the float π
EVP_KEM_get0_name() returns the algorithm name from the provided implementation for the given kem. heads up tho: the kem may have multiple synonyms associated with it. in that case, the first name from the algorithm definition is the one that comes back. ownership of the returned string stays with the kem object, so the caller should not free it. hands off, it's not yours π
EVP_KEM_names_do_all() traverses all names for kem, and calls fn with each name and data. every name gets a little spotlight moment β¨
EVP_KEM_get0_description() returns a description of the kem, meant for display and human consumption. the description is at the discretion of the kem implementation, so like, whatever the implementation decided to say about itself.
EVP_KEM_gettable_ctx_params() and EVP_KEM_settable_ctx_params() return a constant OSSL_PARAM(3) array that describes the names and types of key parameters that can be retrieved or set by a key encapsulation algorithm using EVP_PKEY_CTX_get_params(3) and EVP_PKEY_CTX_set_params(3). so one's for getting, one's for setting, and they're both here to tell you what's allowed π
π RETURN VALUES π
EVP_KEM_fetch()returns a pointer to anEVP_KEMfor success, orNULLfor failure. simple as.EVP_KEM_up_ref()returns1for success, or0otherwise.EVP_KEM_names_do_all()returns1if the callback was called for all names. a return value of0means that the callback was not called for any names π (okay that's a little sad but it's the facts).EVP_KEM_gettable_ctx_params()andEVP_KEM_settable_ctx_params()return a constantOSSL_PARAM(3)array, orNULLon error.
π«Ά SEE ALSO π«Ά
- "ALGORITHM FETCHING" in
crypto(7) OSSL_PROVIDER(3)
go read those too, they're iconic.
π HISTORY π
the functions described here were added in OpenSSL 3.0. so they're not ancient relics, they're certified modern β¨
π COPYRIGHT π
Copyright 2020-2024 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, no notes π
this was OpenSSL 3.5.9, dated 2026-09-29, and yeah β that's the EVP_KEM_FREE(3ossl) manual, and it ate. periodt. ππ¦π
π¦ 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