EVP_PKEY_IS_A(3ossl)
π EVP_PKEY_IS_A(3ossl) π
okay bestie, this is the <openssl/evp.h> girlies page β the one about key type and capabilities functions β¨. It's part of the OpenSSL fam, and it's literally all about asking your EVP_PKEY "who are you" and "can you even sign tho".
πΈ SYNOPSIS πΈ
#include <openssl/evp.h>
int EVP_PKEY_is_a(const EVP_PKEY *pkey, const char *name);
int EVP_PKEY_can_sign(const EVP_PKEY *pkey);
int EVP_PKEY_type_names_do_all(const EVP_PKEY *pkey,
void (*fn)(const char *name, void *data),
void *data);
const char *EVP_PKEY_get0_type_name(const EVP_PKEY *key);
const char *EVP_PKEY_get0_description(const EVP_PKEY *key);
const OSSL_PROVIDER *EVP_PKEY_get0_provider(const EVP_PKEY *key);
π¦ DESCRIPTION π¦
so here's the whole vibe check on each one, bestie:
EVP_PKEY_is_a()β checks if the key type ofpkeyisname. that's it. that's the whole function πEVP_PKEY_can_sign()β checks if the functionality for the key type ofpkeysupports signing. and likeβ¦ no other check is done, okay? not even whetherpkeycontains a private key. so don't get it twisted πEVP_PKEY_type_names_do_all()β traverses all names forpkey's key type, and callsfnwith each name anddata. for example, an RSAEVP_PKEYmay be named both"RSA"and"rsaEncryption". the order of the names depends on the provider implementation that holds the key. so it's giving "alphabetical? no. provider's choice? yes."EVP_PKEY_get0_type_name()β returns the first key type name that is found for the givenpkey. note that thepkeymay have multiple synonyms associated with it β in this case it depends on the provider implementation that holds the key which one will be returned. π also important: ownership of the returned string is retained by thepkeyobject and should not be freed by the caller. do NOT free it. put thefree()down. π«ΆEVP_PKEY_get0_description()β returns a description of the type ofEVP_PKEY, meant for display and human consumption. the description is at the discretion of the key type implementation. so it's a vibe, not a contract.EVP_PKEY_get0_provider()β returns the provider of theEVP_PKEY'sEVP_KEYMGMT(3). yep, the whole keymgmt situation.
β RETURN VALUES β
EVP_PKEY_is_a()returns1ifpkeyhas the key typename, otherwise0.EVP_PKEY_can_sign()returns1if thepkeykey type functionality supports signing, otherwise0.EVP_PKEY_get0_type_name()returns the name that is found orNULLon error.EVP_PKEY_get0_description()returns the description if found orNULLif not.EVP_PKEY_get0_provider()returns the provider if found orNULLif not.EVP_PKEY_type_names_do_all()returns1if the callback was called for all names. a return value of0means that the callback was not called for any names.
π₯ EXAMPLES π₯
β¨ EVP_PKEY_is_a() β¨
the loaded providers and what key types they support will ultimately determine what name is possible to use with EVP_PKEY_is_a(). we do know that the default provider supports RSA, DH, DSA and EC keys, so we can use this as an crude example:
#include <openssl/evp.h>
...
/* |pkey| is an EVP_PKEY* */
if (EVP_PKEY_is_a(pkey, "RSA")) {
BIGNUM *modulus = NULL;
if (EVP_PKEY_get_bn_param(pkey, "n", &modulus))
/* do whatever with the modulus */
BN_free(modulus);
}
π EVP_PKEY_can_sign() π
#include <openssl/evp.h>
...
/* |pkey| is an EVP_PKEY* */
if (!EVP_PKEY_can_sign(pkey)) {
fprintf(stderr, "Not a signing key!");
exit(1);
}
/* Sign something... */
π HISTORY π
the functions described here were added in OpenSSL 3.0. so if you're on something olderβ¦ yeah, no. not available. π
π 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 yes the manual page really is named EVP_PKEY_IS_A(3ossl) π¦π slay, go check your key types, 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