EVP_PKEY_IS_A(3ossl)
πΈ EVP_PKEY_IS_A(3ossl) β OpenSSL key type & capabilities functions πΈ
Okay bestie, welcome to the OpenSSL manual page for EVP_PKEY_IS_A(3ossl) β manual name folded in right here so we're literally on the same page. This one is all about key type and capabilities functions, and it's lowkey a whole vibe. π
πΈ NAME πΈ
The whole squad on this page is: EVP_PKEY_is_a, EVP_PKEY_can_sign, EVP_PKEY_type_names_do_all, EVP_PKEY_get0_type_name, EVP_PKEY_get0_description, and EVP_PKEY_get0_provider β key type and capabilities functions, periodt. β¨
β¨ 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 π
EVP_PKEY_is_a() checks if the key type of pkey is name. Simple vibe check, no cap.
EVP_PKEY_can_sign() checks if the functionality for the key type of pkey supports signing. That's it β no other check is done, such as whether pkey contains a private key. So yes, it's specifically asking "can this key type sign?" not "do we have the full private-key situation ready?" π
EVP_PKEY_type_names_do_all() traverses all names for pkey's key type, and calls fn with each name and data. For example, an RSA EVP_PKEY may be named both "RSA" and "rsaEncryption". The order of the names depends on the provider implementation that holds the key. Provider says jump, we say how high. π¦
EVP_PKEY_get0_type_name() returns the first key type name that is found for the given pkey. Note that the pkey may have multiple synonyms associated with it. In this case it depends on the provider implementation that holds the key which one will be returned. Ownership of the returned string is retained by the pkey object and should not be freed by the caller. Do not free it, bestie β that's not your string. π
EVP_PKEY_get0_description() returns a description of the type of EVP_PKEY, meant for display and human consumption. The description is at the discretion of the key type implementation. It's giving "for the humans," not "for the internals." π
EVP_PKEY_get0_provider() returns the provider of the EVP_PKEY's EVP_KEYMGMT(3). Provider reveal, iconic. π
π 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. A historic moment, honestly. π
π 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.
π Cute little sign-off: source/version 3.5.6, dated 2026-04-07, and yes bestie, this is EVP_PKEY_IS_A(3ossl). Periodt. π
π¦ where this page comes from
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms