OBJ_NAME_do_all¶
NAME¶
OBJ_NAME_do_all, OBJ_NAME_do_all_sorted, OBJ_NAME, OBJ_NAME_TYPE_MD_METH, OBJ_NAME_TYPE_CIPHER_METH, OBJ_NAME_TYPE_PKEY_METH, OBJ_NAME_TYPE_COMP_METH, OBJ_NAME_TYPE_MAC_METH, OBJ_NAME_TYPE_KDF_METH - iterate over objects of a given type
SYNOPSIS¶
#include <openssl/objects.h>
typedef struct obj_name_st OBJ_NAME;
struct obj_name_st {
int type;
int alias;
const char *name;
const char *data;
};
#define OBJ_NAME_TYPE_MD_METH 0x01
#define OBJ_NAME_TYPE_CIPHER_METH 0x02
#define OBJ_NAME_TYPE_PKEY_METH 0x03
#define OBJ_NAME_TYPE_COMP_METH 0x04
#define OBJ_NAME_TYPE_MAC_METH 0x05
#define OBJ_NAME_TYPE_KDF_METH 0x06
void OBJ_NAME_do_all(int type,
void (*fn)(const OBJ_NAME *, void *arg),
void *arg);
void OBJ_NAME_do_all_sorted(int type,
void (*fn)(const OBJ_NAME *, void *arg),
void *arg);
DESCRIPTION¶
OBJ_NAME_do_all() calls the function fn for each object of type type in the internal globally defined name table. This table maps algorithm names to their implementations and is used by OpenSSL to look up ciphers, digests, and other cryptographic methods by name. The arg value is passed as the second argument to each call of fn. The order in which objects are iterated is undefined.
OBJ_NAME_do_all_sorted() is similar to OBJ_NAME_do_all(), except that the objects being iterated over are sorted by name using strcmp(3).
The type argument specifies which category of objects to iterate over. The following type values are defined:
OBJ_NAME_TYPE_MD_METH
Digest methods (message digests).
OBJ_NAME_TYPE_CIPHER_METH
Cipher methods.
OBJ_NAME_TYPE_PKEY_METH
Public key methods.
OBJ_NAME_TYPE_COMP_METH
Compression methods.
OBJ_NAME_TYPE_MAC_METH
MAC methods.
OBJ_NAME_TYPE_KDF_METH
KDF methods.
The callback function fn receives a pointer to an immutable OBJ_NAME structure containing information about each object. The type field indicates the object type. The alias field is nonzero if this name is an alias for another name. The name field contains the object name. The data field contains type-specific data associated with the object.
NOTES¶
These functions are typically used to enumerate available algorithms, for example, to display a list of supported digest or cipher algorithms.
These functions are not thread safe. They must not be called concurrently with functions that modify the object name table, such as OBJ_NAME_add() or OBJ_NAME_remove(). The object enumeration functions do not acquire locks, whereas the modification functions do. Calling these functions concurrently with modifications to the object table may result in undefined behavior.
In practice, this means these functions should only be called during single-threaded initialization or after all objects have been added to the table.
RETURN VALUES¶
OBJ_NAME_do_all() and OBJ_NAME_do_all_sorted() do not return a value.
EXAMPLES¶
Print all available digest algorithm names:
static void print_digest(const OBJ_NAME *name, void *arg)
{
if (name->alias == 0)
printf("%s\n", name->name);
}
void list_digests(void)
{
OBJ_NAME_do_all_sorted(OBJ_NAME_TYPE_MD_METH, print_digest, NULL);
}
SEE ALSO¶
OBJ_nid2obj(3), EVP_MD_do_all_provided(3), EVP_CIPHER_do_all_provided(3)
HISTORY¶
OBJ_NAME_do_all() and OBJ_NAME_do_all_sorted() were added in OpenSSL 0.9.7.
COPYRIGHT¶
Copyright 2026 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.