EVP_PKEY_IS_A(3ossl)

πŸ“¦ version 3.5.0, in opensuse-leap 16.0

πŸ’… EVP_PKEY_IS_A(3ossl) πŸ’…

okay so bestie, this is an OpenSSL manpage β€” EVP_PKEY_is_a, EVP_PKEY_can_sign, EVP_PKEY_type_names_do_all, EVP_PKEY_get0_type_name, EVP_PKEY_get0_description, EVP_PKEY_get0_provider β€” literally the key type and capabilities functions, and we're gonna get into all of it 🫢


✨ 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() β€” vibe-checks the key type of pkey against name. Is it that? Yes or no, queen.
  • EVP_PKEY_can_sign() β€” checks whether the functionality for the key type of pkey supports signing. and that's it, that's the whole check β€” no other check is done, like, fr fr it does not check whether pkey actually contains a private key. so don't come for her if you get humbled later 😭
  • EVP_PKEY_type_names_do_all() β€” walks through all the 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" (two names, one icon). the order of the names depends on the provider implementation that holds the key β€” so it's giving "whoever's holding the aux decides the playlist" πŸ’…
  • EVP_PKEY_get0_type_name() β€” returns the first key type name that is found for the given pkey. note (and this is the lowkey important part): pkey may have multiple synonyms associated with it, and in that 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 β€” hands off, bestie, it's not yours πŸŽ€
  • 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, so it's whatever the implementation felt like writing that day ✨
  • EVP_PKEY_get0_provider() β€” returns the provider of the EVP_PKEY's EVP_KEYMGMT(3). yep.

πŸ¦‹ RETURN VALUES πŸ¦‹

  • EVP_PKEY_is_a() returns 1 if pkey has the key type name, otherwise 0.
  • EVP_PKEY_can_sign() returns 1 if the pkey key type functionality supports signing, otherwise 0.
  • EVP_PKEY_get0_type_name() returns the name that is found or NULL on error.
  • EVP_PKEY_get0_description() returns the description if found or NULL if not.
  • EVP_PKEY_get0_provider() returns the provider if found or NULL if not.
  • EVP_PKEY_type_names_do_all() returns 1 if the callback was called for all names. a return value of 0 means that the callback was not called for any names. no in-between, no "some of them", just 1 or 0 😌

πŸ”₯ EXAMPLES πŸ”₯

πŸ’– EVP_PKEY_is_a() πŸ’–

so the loaded providers and what key types they support will ultimately determine what name is possible to use with EVP_PKEY_is_a(). what we do know (screenshot-worthy intel) is 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. (glow-up era ✨)


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>.


bestie real talk: the LICENSE thing is not a suggestion, the lawyers are watching πŸ‘€

okay that's the whole page, mwah πŸ’‹ this was 3.5.0 on 2026-09-25, EVP_PKEY_IS_A(3ossl), OpenSSL β€” go forth and query your key types, i'm obsessed with you πŸ§šπŸ’–

πŸ“¦ where this page comes from