Commit d8183f352d for openssl.org
commit d8183f352d96fdc140de7d52021fe1f024780895
Author: kovan <xaum.io@gmail.com>
Date: Tue Jan 27 09:25:10 2026 +0100
doc: add documentation for OBJ_NAME_do_all and OBJ_NAME_do_all_sorted
Document the OBJ_NAME_do_all() and OBJ_NAME_do_all_sorted() functions,
which iterate over objects of a given type in the internal globally
defined object name table.
Importantly, document that these functions are not thread safe and must
not be called concurrently with functions that modify the object name
table such as OBJ_NAME_add() or OBJ_NAME_remove().
Resolves: https://github.com/openssl/openssl/issues/29277
Assisted-by: Claude:claude-opus-4-5
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Merge-date: Wed Oct 28 09:36:22 2026
Merged-from: https://github.com/openssl/openssl/pull/29780
diff --git a/doc/build.info b/doc/build.info
index e89862b72b..2f400822d7 100644
--- a/doc/build.info
+++ b/doc/build.info
@@ -1511,6 +1511,10 @@ DEPEND[html/man3/NCONF_new_ex.html]=man3/NCONF_new_ex.pod
GENERATE[html/man3/NCONF_new_ex.html]=man3/NCONF_new_ex.pod
DEPEND[man/man3/NCONF_new_ex.3]=man3/NCONF_new_ex.pod
GENERATE[man/man3/NCONF_new_ex.3]=man3/NCONF_new_ex.pod
+DEPEND[html/man3/OBJ_NAME_do_all.html]=man3/OBJ_NAME_do_all.pod
+GENERATE[html/man3/OBJ_NAME_do_all.html]=man3/OBJ_NAME_do_all.pod
+DEPEND[man/man3/OBJ_NAME_do_all.3]=man3/OBJ_NAME_do_all.pod
+GENERATE[man/man3/OBJ_NAME_do_all.3]=man3/OBJ_NAME_do_all.pod
DEPEND[html/man3/OBJ_nid2obj.html]=man3/OBJ_nid2obj.pod
GENERATE[html/man3/OBJ_nid2obj.html]=man3/OBJ_nid2obj.pod
DEPEND[man/man3/OBJ_nid2obj.3]=man3/OBJ_nid2obj.pod
@@ -3453,6 +3457,7 @@ html/man3/MD5.html \
html/man3/MDC2_Init.html \
html/man3/NAME_CONSTRAINTS_check.html \
html/man3/NCONF_new_ex.html \
+html/man3/OBJ_NAME_do_all.html \
html/man3/OBJ_nid2obj.html \
html/man3/OCSP_REQUEST_new.html \
html/man3/OCSP_cert_to_id.html \
@@ -4134,6 +4139,7 @@ man/man3/MD5.3 \
man/man3/MDC2_Init.3 \
man/man3/NAME_CONSTRAINTS_check.3 \
man/man3/NCONF_new_ex.3 \
+man/man3/OBJ_NAME_do_all.3 \
man/man3/OBJ_nid2obj.3 \
man/man3/OCSP_REQUEST_new.3 \
man/man3/OCSP_cert_to_id.3 \
diff --git a/doc/man3/OBJ_NAME_do_all.pod b/doc/man3/OBJ_NAME_do_all.pod
new file mode 100644
index 0000000000..7f03fe7817
--- /dev/null
+++ b/doc/man3/OBJ_NAME_do_all.pod
@@ -0,0 +1,137 @@
+=pod
+
+=head1 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
+
+=head1 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);
+
+=head1 DESCRIPTION
+
+OBJ_NAME_do_all() calls the function I<fn> for each object of type I<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 I<arg> value is passed as the
+second argument to each call of I<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 I<type> argument specifies which category of objects to iterate over.
+The following type values are defined:
+
+=over 4
+
+=item B<OBJ_NAME_TYPE_MD_METH>
+
+Digest methods (message digests).
+
+=item B<OBJ_NAME_TYPE_CIPHER_METH>
+
+Cipher methods.
+
+=item B<OBJ_NAME_TYPE_PKEY_METH>
+
+Public key methods.
+
+=item B<OBJ_NAME_TYPE_COMP_METH>
+
+Compression methods.
+
+=item B<OBJ_NAME_TYPE_MAC_METH>
+
+MAC methods.
+
+=item B<OBJ_NAME_TYPE_KDF_METH>
+
+KDF methods.
+
+=back
+
+The callback function I<fn> receives a pointer to an immutable B<OBJ_NAME>
+structure containing information about each object. The I<type> field indicates the
+object type. The I<alias> field is nonzero if this name is an alias for
+another name. The I<name> field contains the object name. The I<data> field
+contains type-specific data associated with the object.
+
+=head1 NOTES
+
+These functions are typically used to enumerate available algorithms,
+for example, to display a list of supported digest or cipher algorithms.
+
+B<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.
+
+=head1 RETURN VALUES
+
+OBJ_NAME_do_all() and OBJ_NAME_do_all_sorted() do not return a value.
+
+=head1 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);
+ }
+
+=head1 SEE ALSO
+
+L<OBJ_nid2obj(3)>, L<EVP_MD_do_all_provided(3)>, L<EVP_CIPHER_do_all_provided(3)>
+
+=head1 HISTORY
+
+OBJ_NAME_do_all() and OBJ_NAME_do_all_sorted() were added in OpenSSL 0.9.7.
+
+=head1 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
+L<https://www.openssl.org/source/license.html>.
+
+=cut
diff --git a/util/missingcrypto.txt b/util/missingcrypto.txt
index 7a489a1b6a..bbf4f086ed 100644
--- a/util/missingcrypto.txt
+++ b/util/missingcrypto.txt
@@ -590,8 +590,6 @@ NETSCAPE_SPKI_verify(3)
NOTICEREF_it(3)
OBJ_NAME_add(3)
OBJ_NAME_cleanup(3)
-OBJ_NAME_do_all(3)
-OBJ_NAME_do_all_sorted(3)
OBJ_NAME_get(3)
OBJ_NAME_init(3)
OBJ_NAME_new_index(3)
diff --git a/util/other.syms b/util/other.syms
index 9b36384dd8..b3ce2ecb4a 100644
--- a/util/other.syms
+++ b/util/other.syms
@@ -418,6 +418,13 @@ EVP_sm4_cfb define
EXT_UTF8STRING define
FIPS_mode define
OBJ_cleanup define deprecated 1.1.0
+OBJ_NAME datatype
+OBJ_NAME_TYPE_CIPHER_METH define
+OBJ_NAME_TYPE_COMP_METH define
+OBJ_NAME_TYPE_KDF_METH define
+OBJ_NAME_TYPE_MAC_METH define
+OBJ_NAME_TYPE_MD_METH define
+OBJ_NAME_TYPE_PKEY_METH define
OCSP_parse_url define
OCSP_REQ_CTX datatype deprecated 3.0.0
OCSP_REQ_CTX_add1_header define deprecated 3.0.0