EVP_PKEY_ASN1_GET_COUNT(3)
π EVP_PKEY_ASN1_GET_COUNT(3) β like, the whole ASN.1 method roster
okay so bestie, this is a page from the Library Functions Manual and it's all about the libcrypto girlies who keep track of public key ASN.1 methods β the little descriptor objects (EVP_PKEY_ASN1_METHOD, aka ameth) that tell OpenSSL how each key type does its ASN.1 thing. We're literally just enumerating them, looking them up, and peeking inside. No cap, that's the whole vibe. π¦
β¨ NAME β¨
EVP_PKEY_asn1_get_count, EVP_PKEY_asn1_get0, EVP_PKEY_get0_asn1, EVP_PKEY_asn1_find, EVP_PKEY_asn1_find_str, EVP_PKEY_asn1_get0_info β enumerate public key ASN.1 methods π
πΈ SYNOPSIS πΈ
library βlibcryptoβ
#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_get0_asn1(const EVP_PKEY *pkey);
const EVP_PKEY_ASN1_METHOD *
EVP_PKEY_asn1_find(ENGINE **engine, int type);
const EVP_PKEY_ASN1_METHOD *
EVP_PKEY_asn1_find_str(ENGINE **engine, 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);
π DESCRIPTION π
So here's the tea on each one, mwah:
EVP_PKEY_asn1_get_count()β returns the number of public key ASN.1 methods available. Like a headcount for the group chat. πEVP_PKEY_asn1_get0()β returns the public key ASN.1 method at indexidx. Btw the value ofidxmust be in the range from zero toEVP_PKEY_asn1_get_count() - 1. Stay in your lane, bestie, or it's not gonna go how you want. πEVP_PKEY_asn1_find()β looks up the method with NIDtype, which can be any of the values thatEVP_PKEY_base_id(3)andEVP_PKEY_id(3)may return. And listen: ifengineis notNULL, then*engineis set toNULL. That's it, that's the whole engine situation. π«ΆEVP_PKEY_asn1_find_str()β looks up the method with the PEM type string given by the firstlenbytes ofstr. Iflenis-1, thestrlen(3)ofstris used instead (convenient, honestly π ). The PEM type strings supported by default are listed in theEVP_PKEY_base_id(3)manual page β go look, iykyk. Just likeEVP_PKEY_asn1_find(), ifengineis notNULL,*engineis set toNULL. Same energy. β¨EVP_PKEY_asn1_get0_info()β retrieves the public key ID as returned byEVP_PKEY_id(3), the base public key ID as returned byEVP_PKEY_base_id(3)(both NIDs, fyi), any flags, and internal pointers owned byamethpointing to its method description string and its PEM type string. It's giving "tell me everything about yourself." π₯
π the flags bits π
The following flags bits can occur, OR'ed together in *ppkey_flags:
ASN1_PKEY_ALIASβ thisamethobject serves as an alias for anotherEVP_PKEY_ASN1_METHODobject and will never be returned fromEVP_PKEY_asn1_find()orEVP_PKEY_asn1_find_str(). It's the understudy, not the main character. πASN1_PKEY_DYNAMICβ this flag is unused. It could formerly be used to mark anamethobject as dynamically allocated. So yeah, retired icon, we still respect it. πASN1_PKEY_SIGPARAM_NULLβ okay this one's a little more involved, stay with me: if the signing ctx uses anEVP_PKEYprivate key associated with thisameth, it instructsASN1_item_sign_ctx(3)to use a parameter type ofV_ASN1_NULLinstead of the defaultV_ASN1_UNDEFwhen encoding the ASN.1 AlgorithmIdentifier objects withX509_ALGOR_set0(3). In particular, this is used forEVP_PKEY_RSA. Slay, RSA, we see you. π
π RETURN VALUES π
EVP_PKEY_asn1_get_count()returns the number of available public key methods.EVP_PKEY_asn1_get0()returns a public key method orNULLifidxis out of range.EVP_PKEY_get0_asn1()returns the public key method used bypkey.EVP_PKEY_asn1_find()andEVP_PKEY_asn1_find_str()return a matching public key method orNULLif no match is found.EVP_PKEY_asn1_get0_info()returns1on success or0on failure.
ngl, NULL shows up a lot in these return values. That's not a bug, that's just what "didn't find it" looks like. π
π¦ SEE ALSO π¦
EVP_PKEY_base_id(3), EVP_PKEY_new(3)
β HISTORY β
These functions first appeared in OpenSSL 1.0.0 and have been available since OpenBSD 4.9. Vintage but make it iconic. π
and that's the whole page, bestie β sourced from Debian, dated June 8, 2025, filed under EVP_PKEY_ASN1_GET_COUNT(3). go forth and enumerate responsibly π§ββοΈπ
π¦ where this page comes from
- alpine 3.24: libressl-doc 4.3.1-r0 Β· custom
- arch rolling: libressl 4.4.0-1 Β· ISC AND custom:OpenSSL
- Copyright (c) 2020, 2023 Ingo Schwarze <schwarze@openbsd.org>
- Copyright (c) 2017 The OpenSSL Project. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms