EVP_PKEY_SET_TYPE(3ossl)
π EVP_PKEY_SET_TYPE π
okay bestie, welcome to the 3ossl girlies' guide to changing the type of an EVP_PKEY. yes this is the OpenSSL manual, yes we're doing this with sparkle, no the facts are not changing. sit down, hydrate, let's go π«Ά
β¨ NAME β¨
EVP_PKEY_set_type, EVP_PKEY_set_type_str, EVP_PKEY_set_type_by_keymgmt β the functions that literally change the EVP_PKEY type. that's the whole job. slay.
β¨ SYNOPSIS β¨
#include <openssl/evp.h>
int EVP_PKEY_set_type(EVP_PKEY *pkey, int type);
int EVP_PKEY_set_type_str(EVP_PKEY *pkey, const char *str, int len);
int EVP_PKEY_set_type_by_keymgmt(EVP_PKEY *pkey, EVP_KEYMGMT *keymgmt);
β¨ DESCRIPTION β¨
so here's the vibe check on all three of these: they all do the same big thing, they just take different little arguments to figure out what type you want. π
every single one of them clears all the previous key data and methods from pkey (bye bestie, gone, no notes) and resets it to be the type of key given by the different arguments. clean slate energy. β¨
and here's the little plot twist: ifpkeyisNULL, these functions will still return the same return values as if it wasn't. like. they'll behave the same way on the return-value front even though there's no pkey to poke. iconic tbh.
π EVP_PKEY_set_type()
this one initialises pkey to contain an internal legacy key. when it's doing that, it goes looking for a EVP_PKEY_ASN1_METHOD(3) that corresponds to type, and then associates pkey with its findings. π¦
it is an error if noEVP_PKEY_ASN1_METHOD(3)could be found fortype. no method found = we are NOT okay.
π EVP_PKEY_set_type_str()
same legacy-key situation, different lookup. this one initialises pkey to contain an internal legacy key too, and when it's doing that it finds a EVP_PKEY_ASN1_METHOD(3) corresponding to str that has the length len, and associates pkey with the findings. πΈ
and again: it is an error if noEVP_PKEY_ASN1_METHOD(3)could be found fortype. (yes, the manpage saystyperight there in this paragraph even though this function is aboutstrβ we are quoting the lore exactly, no editing, periodt.)
π the numeric type situation
for both EVP_PKEY_set_type() and EVP_PKEY_set_type_str(), pkey gets a numeric type, which you can retrieve with EVP_PKEY_get_id(3). that numeric type is taken from the EVP_PKEY_ASN1_METHOD(3) that was found, and it's equal to or closely related to type in the case of EVP_PKEY_set_type(), or related to str in the case of EVP_PKEY_set_type_str(). π₯
π EVP_PKEY_set_type_by_keymgmt()
this one is the provider-side girlie. it initialises pkey to contain an internal provider side key, and when it's doing that, it associates pkey with keymgmt. π§
heads up bestie: for keys initialised this way, the numeric type you get back fromEVP_PKEY_get_id(3)will always beEVP_PKEY_NONE. always. every time. that's just how it is. π
β¨ RETURN VALUES β¨
all the functions described here return 1 if successful, or 0 on error. binary. no in-between. no "it's complicated". π
β¨ SEE ALSO β¨
go read these next, i'm obsessed with them:
EVP_PKEY_assign(3)EVP_PKEY_get_id(3)EVP_PKEY_get0_RSA(3)EVP_PKEY_copy_parameters(3)EVP_PKEY_ASN1_METHOD(3)EVP_KEYMGMT(3)
β¨ COPYRIGHT β¨
Copyright 2020-2021 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 OpenSSL 3.5.9, dated 2026-09-29, and it's EVP_PKEY_SET_TYPE(3ossl) β the manual name is right there in the title the whole time, iykyk. go forth and set those types. 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