EVP_PKEY_ASN1_GET_COUNT(3ossl)

πŸ’– NAME πŸ’–

okay so bestie, meet the girlies that let you peek at all the public key ASN.1 methods: EVP_PKEY_asn1_find, EVP_PKEY_asn1_find_str, EVP_PKEY_asn1_get_count, EVP_PKEY_asn1_get0, and EVP_PKEY_asn1_get0_info. literally the whole squad for enumerating public key ASN.1 methods. this is all part of OpenSSL, the 3ossl manual era, and yes we are going to go through every single one of them, no skips πŸŽ€


✨ SYNOPSIS ✨

#include <openssl/evp.h>

int EVP_PKEY_asn1_get_count(void);
const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_get0(int idx);
const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find(ENGINE **pe, int type);
const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find_str(ENGINE **pe,
                                                   const char *str, int len);
int EVP_PKEY_asn1_get0_info(int *ppkey_id, int *pkey_base_id,
                            int *ppkey_flags, const char **pinfo,
                            const char **ppem_str,
                            const EVP_PKEY_ASN1_METHOD *ameth);

like. look at that include. #include <openssl/evp.h>. slay. copy it exactly, she does not appreciate typos πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

EVP_PKEY_asn1_count() hands you a count of how many public key ASN.1 methods are out there. and bestie, it's not just the standard ones β€” anything the application added counts too. the whole roster. πŸ‘‘

EVP_PKEY_asn1_get0() gives you back the public key ASN.1 method at position idx. and listen, idx has to be between zero and EVP_PKEY_asn1_get_count() - 1. stay in your lane, bestie, or it's giving out-of-range energy.

EVP_PKEY_asn1_find() goes looking for the EVP_PKEY_ASN1_METHOD with NID type. and here's the plot twist: if pe isn't NULL, it will look up an engine implementing an EVP_PKEY_ASN1_METHOD for that NID type and return that instead, and it also sets *pe to point at the engine that implements it. main character engine behavior, honestly.

EVP_PKEY_asn1_find_str() is the same vibe but it looks up the EVP_PKEY_ASN1_METHOD by the PEM type string str. and just like EVP_PKEY_asn1_find(), if pe isn't NULL, it will look up an engine implementing an EVP_PKEY_ASN1_METHOD for the NID type and return that instead, and also set *pe to point at the engine that implements it. same energy, different lookup key. πŸ’…

EVP_PKEY_asn1_get0_info() spills the tea on the public key ASN.1 method *ameth: it returns the public key ID, the base public key ID (both of those are NIDs, fyi), any flags, the method description, and the PEM type string associated with it.

okay so real talk, important: EVP_PKEY_asn1_count(), EVP_PKEY_asn1_get0(), EVP_PKEY_asn1_find() and EVP_PKEY_asn1_find_str() are not thread safe. the way that this is fine is if every single EVP_PKEY_ASN1_METHOD object gets added before the application gets threaded. do that and using them is safe, periodt. see EVP_PKEY_asn1_add0(3). 🫢

🌸 RETURN VALUES 🌸

  • EVP_PKEY_asn1_count() returns the number of available public key methods. iconic.
  • EVP_PKEY_asn1_get0() returns a public key method, or NULL if idx is out of range. 😭
  • EVP_PKEY_asn1_get0_info() returns 0 on failure, 1 on success. no cap.

πŸŽ€ SEE ALSO πŸŽ€

go read those too bestie, iykyk 🧚


Copyright 2017 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 the EVP_PKEY_ASN1_GET_COUNT(3ossl) manual β€” obsessed with her fr fr. stay safe, stay thread-aware, mwah πŸ’–βœ¨

πŸ“¦ where this page comes from