Commit ad5277a4b1 for openssl.org

commit ad5277a4b1d6d682072bbe7d134fbae2338329eb
Author: Bob Beck <beck@openssl.org>
Date:   Tue Sep 2 18:54:49 2025 -0600

    make includes self-contained

    Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
    Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
    Reviewed-by: Norbert Pocs <norbertp@openssl.org>
    MergeDate: Wed May  6 11:35:48 2026
    (Merged from https://github.com/openssl/openssl/pull/31001)

diff --git a/include/crypto/bn_dh.h b/include/crypto/bn_dh.h
index fdb170ab3f..89175dfac2 100644
--- a/include/crypto/bn_dh.h
+++ b/include/crypto/bn_dh.h
@@ -10,6 +10,8 @@
 #if !defined(OSSL_CRYPTO_BN_DH_H)
 #define OSSL_CRYPTO_BN_DH_H

+#include <openssl/bn.h>
+
 #define declare_dh_bn(x)                       \
     extern const BIGNUM ossl_bignum_dh##x##_p; \
     extern const BIGNUM ossl_bignum_dh##x##_q; \
diff --git a/include/crypto/bn_srp.h b/include/crypto/bn_srp.h
index 00b160aad1..7e3dade0bd 100644
--- a/include/crypto/bn_srp.h
+++ b/include/crypto/bn_srp.h
@@ -6,9 +6,13 @@
  * in the file LICENSE in the source distribution or at
  * https://www.openssl.org/source/license.html
  */
+#if !defined(OPENSSL_CRYPTO_BN_SRP_H)
+#define OPENSSL_CRYPTO_BN_SRP_H

 #ifndef OPENSSL_NO_SRP

+#include <openssl/bn.h>
+
 extern const BIGNUM ossl_bn_group_1024;

 extern const BIGNUM ossl_bn_group_1536;
@@ -30,3 +34,4 @@ extern const BIGNUM ossl_bn_generator_5;
 extern const BIGNUM ossl_bn_generator_2;

 #endif
+#endif /* !defined(OPENSSL_CRYPTO_BN_SRP_H) */
diff --git a/include/crypto/ess.h b/include/crypto/ess.h
index c29752117e..cc5bb7febc 100644
--- a/include/crypto/ess.h
+++ b/include/crypto/ess.h
@@ -11,6 +11,10 @@
 #define OSSL_CRYPTO_ESS_H
 #pragma once

+#include <openssl/asn1.h>
+#include <openssl/ess.h>
+#include <openssl/safestack.h>
+
 /*-
  * IssuerSerial ::= SEQUENCE {
  *        issuer                  GeneralNames,
diff --git a/include/crypto/lms_util.h b/include/crypto/lms_util.h
index 0f4f4e6143..54aa51e17a 100644
--- a/include/crypto/lms_util.h
+++ b/include/crypto/lms_util.h
@@ -17,6 +17,8 @@
 #include <openssl/core_names.h>
 #include <openssl/evp.h>

+#include "crypto/lms.h"
+
 /*
  * This LMS implementation assumes that the hash algorithm must be the same for
  * LMS params and OTS params. Since OpenSSL does not have a "SHAKE256-192"
diff --git a/include/crypto/pkcs7.h b/include/crypto/pkcs7.h
index bf0e6bf607..8d999fd44f 100644
--- a/include/crypto/pkcs7.h
+++ b/include/crypto/pkcs7.h
@@ -11,6 +11,8 @@
 #define OSSL_CRYPTO_PKCS7_H
 #pragma once

+#include <openssl/pkcs7.h>
+
 void ossl_pkcs7_resolve_libctx(PKCS7 *p7);

 void ossl_pkcs7_set0_libctx(PKCS7 *p7, OSSL_LIB_CTX *ctx);
diff --git a/include/crypto/security_bits.h b/include/crypto/security_bits.h
index 56fe8d2573..8b42338a4d 100644
--- a/include/crypto/security_bits.h
+++ b/include/crypto/security_bits.h
@@ -11,6 +11,8 @@
 #define OSSL_SECURITY_BITS_H
 #pragma once

+#include <stdint.h>
+
 uint16_t ossl_ifc_ffc_compute_security_bits(int n);

 #endif
diff --git a/include/crypto/siphash.h b/include/crypto/siphash.h
index 3ffdc055e6..cb2f6de68f 100644
--- a/include/crypto/siphash.h
+++ b/include/crypto/siphash.h
@@ -12,6 +12,7 @@
 #pragma once

 #include <stddef.h>
+#include <stdint.h>

 #define SIPHASH_BLOCK_SIZE 8
 #define SIPHASH_KEY_SIZE 16
diff --git a/include/crypto/siv.h b/include/crypto/siv.h
index b4f04a80c8..d842baae49 100644
--- a/include/crypto/siv.h
+++ b/include/crypto/siv.h
@@ -6,9 +6,15 @@
  * in the file LICENSE in the source distribution or at
  * https://www.openssl.org/source/license.html
  */
+#if !defined(OPENSSL_CRYPTO_SIV_H)
+#define OPENSSL_CRYPTO_SIV_H

 #ifndef OPENSSL_NO_SIV

+#include <stddef.h>
+
+#include <openssl/evp.h>
+
 typedef struct siv128_context SIV128_CONTEXT;

 SIV128_CONTEXT *ossl_siv128_new(const unsigned char *key, int klen,
@@ -31,3 +37,4 @@ int ossl_siv128_cleanup(SIV128_CONTEXT *ctx);
 int ossl_siv128_speed(SIV128_CONTEXT *ctx, int arg);

 #endif /* OPENSSL_NO_SIV */
+#endif /* !defined (OPENSSL_CRYPTO_SIV_H) */
diff --git a/include/internal/core.h b/include/internal/core.h
index 98fc4681d8..5c9ffc657b 100644
--- a/include/internal/core.h
+++ b/include/internal/core.h
@@ -12,6 +12,7 @@
 #pragma once

 #include <openssl/conf.h>
+#include <openssl/types.h>

 /*
  * namespaces:
diff --git a/include/internal/dane.h b/include/internal/dane.h
index 9c040eedc6..8df761facf 100644
--- a/include/internal/dane.h
+++ b/include/internal/dane.h
@@ -11,6 +11,7 @@
 #define OSSL_INTERNAL_DANE_H
 #pragma once

+#include <openssl/evp.h>
 #include <openssl/safestack.h>

 /*-
diff --git a/include/internal/ech_helpers.h b/include/internal/ech_helpers.h
index 6e7a7e29ff..00053eed6a 100644
--- a/include/internal/ech_helpers.h
+++ b/include/internal/ech_helpers.h
@@ -15,6 +15,9 @@
 #define OPENSSL_ECH_HELPERS_H
 #pragma once

+#include <stddef.h>
+#include <stdint.h>
+
 #ifndef OPENSSL_NO_ECH

 /*
diff --git a/include/internal/hashtable.h b/include/internal/hashtable.h
index 56a8b8254c..7c4150ba28 100644
--- a/include/internal/hashtable.h
+++ b/include/internal/hashtable.h
@@ -13,6 +13,7 @@

 #include <stddef.h>
 #include <stdint.h>
+#include <string.h>
 #include <openssl/e_os2.h>
 #include <internal/rcu.h>
 #include "crypto/context.h"
diff --git a/include/internal/hpke_util.h b/include/internal/hpke_util.h
index 9c52ba4693..152c3213ed 100644
--- a/include/internal/hpke_util.h
+++ b/include/internal/hpke_util.h
@@ -11,6 +11,11 @@
 #define OSSL_INTERNAL_HPKE_UTIL_H
 #pragma once

+#include <stdint.h>
+
+#include <openssl/hpke.h>
+#include <openssl/types.h>
+
 /* Constants from RFC 9180 Section 7.1 and 7.3 */
 #define OSSL_HPKE_MAX_SECRET 64
 #define OSSL_HPKE_MAX_PUBLIC 133
diff --git a/include/internal/passphrase.h b/include/internal/passphrase.h
index 803622867b..b7cbaa1057 100644
--- a/include/internal/passphrase.h
+++ b/include/internal/passphrase.h
@@ -11,6 +11,8 @@
 #define OSSL_INTERNAL_PASSPHRASE_H
 #pragma once

+#include <openssl/ui.h>
+
 /*
  * This is a passphrase reader bridge with bells and whistles.
  *
diff --git a/include/internal/qlog.h b/include/internal/qlog.h
index eb68570e60..ecabe942f2 100644
--- a/include/internal/qlog.h
+++ b/include/internal/qlog.h
@@ -21,10 +21,11 @@ typedef struct qlog_st QLOG;

 enum {
     QLOG_EVENT_TYPE_NONE,
-
+/* clang-format off */
 #define QLOG_EVENT(cat, name) QLOG_EVENT_TYPE_##cat##_##name,
-#include "internal/qlog_events.h"
+#include "internal/qlog_events.inc"
 #undef QLOG_EVENT
+    /* clang-format on */

     QLOG_EVENT_TYPE_NUM
 };
diff --git a/include/internal/quic_thread_assist.h b/include/internal/quic_thread_assist.h
index fbfac146da..152c84663d 100644
--- a/include/internal/quic_thread_assist.h
+++ b/include/internal/quic_thread_assist.h
@@ -11,6 +11,8 @@
 #define OSSL_QUIC_THREAD_ASSIST_H

 #include <openssl/ssl.h>
+
+#include "internal/quic_channel.h"
 #include "internal/thread.h"
 #include "internal/time.h"

diff --git a/include/internal/quic_trace.h b/include/internal/quic_trace.h
index f462ce0c00..bddb9823c2 100644
--- a/include/internal/quic_trace.h
+++ b/include/internal/quic_trace.h
@@ -12,6 +12,10 @@

 #ifndef OPENSSL_NO_QUIC

+#include <stddef.h>
+
+#include <openssl/ssl.h>
+
 int ossl_quic_trace(int write_p, int version, int content_type,
     const void *buf, size_t msglen, SSL *ssl, void *arg);

diff --git a/include/internal/ring_buf.h b/include/internal/ring_buf.h
index cc70bfaeac..19c13817fd 100644
--- a/include/internal/ring_buf.h
+++ b/include/internal/ring_buf.h
@@ -11,7 +11,12 @@
 #define OSSL_INTERNAL_RING_BUF_H
 #pragma once

+#include <assert.h>
+#include <string.h>
+
 #include <openssl/e_os2.h> /* For 'ossl_inline' */
+#include <openssl/crypto.h>
+
 #include "internal/safe_math.h"

 /*
diff --git a/include/internal/skey.h b/include/internal/skey.h
index a4b6c6e6a9..b511af8c32 100644
--- a/include/internal/skey.h
+++ b/include/internal/skey.h
@@ -10,6 +10,10 @@
 #ifndef OSSL_CRYPTO_SKEY_H
 #define OSSL_CRYPTO_SKEY_H

+#include <stddef.h>
+
+#include <openssl/types.h>
+
 /* Known symmetric key type definitions */
 #define SKEY_TYPE_GENERIC 1 /* generic bytes container unknown key types */
 #define SKEY_TYPE_AES 2 /* AES keys */
diff --git a/include/internal/sm3.h b/include/internal/sm3.h
index ee097d85e6..0faf544942 100644
--- a/include/internal/sm3.h
+++ b/include/internal/sm3.h
@@ -13,6 +13,8 @@
 #define OSSL_INTERNAL_SM3_H
 #pragma once

+#include <stddef.h>
+
 #include <openssl/opensslconf.h>

 #ifdef OPENSSL_NO_SM3
diff --git a/include/internal/sslconf.h b/include/internal/sslconf.h
index 49da923059..a016613a57 100644
--- a/include/internal/sslconf.h
+++ b/include/internal/sslconf.h
@@ -11,6 +11,10 @@
 #define OSSL_INTERNAL_SSLCONF_H
 #pragma once

+#include <stddef.h>
+
+#include <openssl/conf.h>
+
 typedef struct ssl_conf_cmd_st SSL_CONF_CMD;

 /*
diff --git a/include/internal/statem.h b/include/internal/statem.h
index 3a6a63238c..990100c4dc 100644
--- a/include/internal/statem.h
+++ b/include/internal/statem.h
@@ -9,6 +9,11 @@
 #ifndef OSSL_INTERNAL_STATEM_H
 #define OSSL_INTERNAL_STATEM_H

+#include <stddef.h>
+
+#include <openssl/e_os2.h>
+#include <openssl/ssl.h>
+
 /*****************************************************************************
  *                                                                           *
  * These enums should be considered PRIVATE to the state machine. No         *
diff --git a/include/internal/threads_common.h b/include/internal/threads_common.h
index cf54914866..1f54eadf82 100644
--- a/include/internal/threads_common.h
+++ b/include/internal/threads_common.h
@@ -10,6 +10,8 @@
 #ifndef _CRYPTO_THREADS_COMMON_H_
 #define _CRYPTO_THREADS_COMMON_H_

+#include <openssl/types.h>
+
 #if defined(__clang__) && defined(__has_feature)
 #if __has_feature(thread_sanitizer)
 #define __SANITIZE_THREAD__
diff --git a/include/internal/tlsgroups.h b/include/internal/tlsgroups.h
index c702471f6c..f12e142b9a 100644
--- a/include/internal/tlsgroups.h
+++ b/include/internal/tlsgroups.h
@@ -11,6 +11,10 @@
 #define OSSL_INTERNAL_TLSGROUPS_H
 #pragma once

+#include <stdint.h>
+
+#include <openssl/e_os2.h> /* For 'ossl_inline' */
+
 #define OSSL_TLS_GROUP_ID_sect163k1 0x0001
 #define OSSL_TLS_GROUP_ID_sect163r1 0x0002
 #define OSSL_TLS_GROUP_ID_sect163r2 0x0003
diff --git a/include/internal/to_hex.h b/include/internal/to_hex.h
index 36f4671c66..4b3940800f 100644
--- a/include/internal/to_hex.h
+++ b/include/internal/to_hex.h
@@ -11,6 +11,8 @@
 #define OSSL_INTERNAL_TO_HEX_H
 #pragma once

+#include <openssl/e_os2.h>
+
 static ossl_inline size_t to_hex(char *buf, uint8_t n, const char hexdig[17])
 {
     *buf++ = hexdig[(n >> 4) & 0xf];
diff --git a/include/internal/unicode.h b/include/internal/unicode.h
index 4ef53cd69c..d1dae6d245 100644
--- a/include/internal/unicode.h
+++ b/include/internal/unicode.h
@@ -11,6 +11,8 @@
 #define OSSL_INTERNAL_UNICODE_H
 #pragma once

+#include <openssl/e_os2.h>
+
 typedef enum {
     SURROGATE_MIN = 0xd800UL,
     SURROGATE_MAX = 0xdfffUL,