EVP_CIPHER_DO_ALL(3)
π EVP_CIPHER_DO_ALL β bestie's guide to iterating lookup tables
okay so this is a libcrypto manpage, and honestly? it's giving "backstage tour of the cipher and digest closet." we're talking EVP_CIPHER_do_all, EVP_CIPHER_do_all_sorted, EVP_MD_do_all, EVP_MD_do_all_sorted, OBJ_NAME_do_all, and OBJ_NAME_do_all_sorted β the whole squad whose entire job is to walk over the lookup tables for ciphers and digests and call your callback on every single entry. no cap, that's it. π¦
β¨ SYNOPSIS β¨
you'll want the libcrypto library and this header, periodt:
#include <openssl/evp.h>
and here are the icons themselves, verbatim:
void
EVP_CIPHER_do_all(void (*fn)(const EVP_CIPHER *cipher, const char *from, const char *to, void *arg),
void *arg);
void
EVP_CIPHER_do_all_sorted(void (*fn)(const EVP_CIPHER *cipher, const char *from, const char *to, void *arg),
void *arg);
void
EVP_MD_do_all(void (*fn)(const EVP_MD *md, const char *from, const char *to, void *arg),
void *arg);
void
EVP_MD_do_all_sorted(void (*fn)(const EVP_MD *md, const char *from, const char *to, void *arg),
void *arg);
typedef struct {
int type;
int alias;
const char *name;
const char *data;
} OBJ_NAME;
void
OBJ_NAME_do_all(int type,
void (*fn)(const OBJ_NAME *obj_name, void *arg), void *arg);
void
OBJ_NAME_do_all_sorted(int type,
void (*fn)(const OBJ_NAME *obj_name, void *arg), void *arg);
πΈ DESCRIPTION πΈ
π the cipher ones
EVP_CIPHER_do_all() calls fn on every entry of the global table of cipher names and aliases. and the way it does it is kind of specific, so listen up bestie:
- for a cipher name entry,
fngets called with a non-NULLcipher, its non-NULL cipher name asfrom, aNULLto, and yourargpointer π - for an alias entry,
fngets called with aNULLcipher, its alias asfrom, the cipher name that alias points to asto, and theargpointer
EVP_CIPHER_do_all_sorted() is literally the same vibe, except it processes the cipher names and aliases in lexicographic order of their from names as determined by strcmp(3). sorted > chaos, iykyk β¨
π§ the digest ones
EVP_MD_do_all() calls fn on every entry of the global table of digest names and aliases:
- for a digest name entry,
fngets a non-NULLmd, its non-NULL digest name asfrom, aNULLto, and theargpointer - for an alias entry,
fngets aNULLmd, its alias asfrom, the digest name that alias points to, and theargpointer
EVP_MD_do_all_sorted() β same deal, except again it goes in lexicographic order of their from names, as determined by strcmp(3). consistent queen π
π the OBJ_NAME ones
OBJ_NAME is basically an abstraction of the types underlying those lookup tables β ciphers and their aliases, and digests and their aliases, respectively. here's the mapping, no guessing:
- for a cipher:
typeisOBJ_NAME_TYPE_CIPHER_METH,aliasis0,nameis its lookup name, anddatais theEVP_CIPHERobject it represents, cast toconst char * - for a cipher alias:
typeisOBJ_NAME_TYPE_CIPHER_METH,aliasisOBJ_NAME_ALIAS,nameis its lookup name, anddatais the name it aliases - for digests representing an
EVP_MDobject and their aliases: represented similarly, except theirtypeisOBJ_NAME_TYPE_MD_METHπ«Ά
OBJ_NAME_do_all() calls fn on every obj_name in the table that has the given type (either OBJ_NAME_TYPE_CIPHER_METH or OBJ_NAME_TYPE_MD_METH), also passing the arg pointer. and OBJ_NAME_do_all_sorted() is similar β except it processes the obj_name in lexicographic order of their names, as determined by strcmp(3). the sorted versions really said "alphabetize or die" π
π¦ SEE ALSO π¦
π HISTORY π
these functions first appeared in OpenSSL 1.0.0 and have been available since OpenBSD 4.9. vintage, honestly. iconic legacy behavior π
π CAVEATS π
okay so this is the part where we get serious for a sec, because it actually matters:
EVP_CIPHER_do_all_sorted(),EVP_MD_do_all_sorted(), andOBJ_NAME_do_all_sorted()cannot report errors. in some implementations they need to allocate internally, and if memory allocation fails they do nothing at all, without telling the caller about the problem. like, they'll just ghost you. π«
so yeah β sorted versions, love them, but know that silence is not always consent, sometimes it's a failed malloc.
this page is from the Debian build, dated June 8, 2025 β stay slaying, and remember: every flag, every signature, every caveat is exactly as written, fr fr ππβ
π¦ 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) 2023,2024 Theo Buehler <tb@openbsd.org>
- Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms