Commit cc7d680024 for openssl.org
commit cc7d680024b5483ce4e82ccd37b9e89d94ed15d0
Author: Bob Beck <beck@openssl.org>
Date: Mon Apr 27 16:50:06 2026 -0600
Make the crypto includes self-contained
Except for obj_dat.h and obj_xref.h which need perl mungery
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:57 2026
(Merged from https://github.com/openssl/openssl/pull/31001)
diff --git a/crypto/asn1/standard_methods.h b/crypto/asn1/standard_methods.h
index b123ee687f..b5f038969b 100644
--- a/crypto/asn1/standard_methods.h
+++ b/crypto/asn1/standard_methods.h
@@ -7,6 +7,13 @@
* https://www.openssl.org/source/license.html
*/
+#if !defined(OSSL_CRYPTO_ASN1_STANDARD_METHODS_H)
+#define OSSL_CRYPTO_ASN1_STANDARD_METHODS_H
+
+#include <openssl/types.h>
+
+#include <crypto/asn1.h>
+
/*
* This table MUST be kept in ascending order of the NID each method
* represents (corresponding to the pkey_id field) as OBJ_bsearch
@@ -41,3 +48,4 @@ static const EVP_PKEY_ASN1_METHOD *const standard_methods[] = {
&ossl_sm2_asn1_meth,
#endif
};
+#endif /* !defined(OSSL_CRYPTO_ASN1_STANDARD_METHODS_H) */
diff --git a/crypto/asn1/tbl_standard.h b/crypto/asn1/tbl_standard.h
index 79f2f06c75..41af74e27a 100644
--- a/crypto/asn1/tbl_standard.h
+++ b/crypto/asn1/tbl_standard.h
@@ -7,11 +7,14 @@
* https://www.openssl.org/source/license.html
*/
-/* size limits: this stuff is taken straight from RFC3280 */
-
#if !defined(OSSL_LIBCRYPTO_ASN1_TBL_STANDARD_H)
#define OSSL_LIBCRYPTO_ASN1_TBL_STANDARD_H
+/* size limits: this stuff is taken straight from RFC3280 */
+
+#include <openssl/asn1.h>
+#include <openssl/obj_mac.h>
+
#define ub_name 32768
#define ub_common_name 64
#define ub_locality_name 128
diff --git a/crypto/bf/bf_pi.h b/crypto/bf/bf_pi.h
index 6971865c1b..1419a5cf4a 100644
--- a/crypto/bf/bf_pi.h
+++ b/crypto/bf/bf_pi.h
@@ -10,6 +10,8 @@
#if !defined(OSSL_LIBCRYPTO_BF_BF_PI_H)
#define OSSL_LIBCRYPTO_BF_BF_PI_H
+#include <openssl/blowfish.h>
+
static const BF_KEY bf_init = {
{ 0x243f6a88L, 0x85a308d3L, 0x13198a2eL, 0x03707344L,
0xa4093822L, 0x299f31d0L, 0x082efa98L, 0xec4e6c89L,
diff --git a/crypto/camellia/cmll_local.h b/crypto/camellia/cmll_local.h
index f585994ff9..5740307385 100644
--- a/crypto/camellia/cmll_local.h
+++ b/crypto/camellia/cmll_local.h
@@ -25,6 +25,8 @@
#ifndef OSSL_CRYPTO_CAMELLIA_CMLL_LOCAL_H
#define OSSL_CRYPTO_CAMELLIA_CMLL_LOCAL_H
+#include <openssl/camellia.h>
+
typedef unsigned int u32;
typedef unsigned char u8;
diff --git a/crypto/cast/cast_local.h b/crypto/cast/cast_local.h
index a3ea4d14de..954a5b237c 100644
--- a/crypto/cast/cast_local.h
+++ b/crypto/cast/cast_local.h
@@ -10,6 +10,8 @@
#if !defined(OSSL_LIBCRYPTO_CAST_CAST_LOCAL_H)
#define OSSL_LIBCRYPTO_CAST_CAST_LOCAL_H
+#include <openssl/cast.h>
+
#ifdef OPENSSL_SYS_WIN32
#include <stdlib.h>
#endif
diff --git a/crypto/cast/cast_s.h b/crypto/cast/cast_s.h
index c76770f344..89cb6223a3 100644
--- a/crypto/cast/cast_s.h
+++ b/crypto/cast/cast_s.h
@@ -10,6 +10,8 @@
#if !defined(OSSL_LIBCRYPTO_CAST_CAST_S_H)
#define OSSL_LIBCRYPTO_CAST_CAST_S_H
+#include <openssl/cast.h>
+
const CAST_LONG CAST_S_table0[256] = {
0x30fb40d4,
0x9fa0ff0b,
diff --git a/crypto/cms/cms_local.h b/crypto/cms/cms_local.h
index ed37289066..5e0ac3907f 100644
--- a/crypto/cms/cms_local.h
+++ b/crypto/cms/cms_local.h
@@ -10,6 +10,7 @@
#ifndef OSSL_CRYPTO_CMS_LOCAL_H
#define OSSL_CRYPTO_CMS_LOCAL_H
+#include <openssl/cms.h>
#include <openssl/x509.h>
/*
diff --git a/crypto/comp/comp_local.h b/crypto/comp/comp_local.h
index 913eb09f70..bb9d4a0f79 100644
--- a/crypto/comp/comp_local.h
+++ b/crypto/comp/comp_local.h
@@ -10,6 +10,8 @@
#if !defined(OSSL_LIBCRYPTO_COMP_COMP_LOCAL_H)
#define OSSL_LIBCRYPTO_COMP_COMP_LOCAL_H
+#include <openssl/comp.h>
+
struct comp_method_st {
int type; /* NID for compression library */
const char *name; /* A text string to identify the library */
diff --git a/crypto/des/spr.h b/crypto/des/spr.h
index 3687bb3720..fe3e9d31e3 100644
--- a/crypto/des/spr.h
+++ b/crypto/des/spr.h
@@ -10,6 +10,8 @@
#if !defined(OSSL_LIBCRYPTO_DES_SPR_H)
#define OSSL_LIBCRYPTO_DES_SPR_H
+#include <openssl/des.h>
+
const DES_LONG DES_SPtrans[8][64] = {
{
/* nibble 0 */
diff --git a/crypto/ec/curve448/arch_64/arch_intrinsics.h b/crypto/ec/curve448/arch_64/arch_intrinsics.h
index 09f0fdf34e..14294892e7 100644
--- a/crypto/ec/curve448/arch_64/arch_intrinsics.h
+++ b/crypto/ec/curve448/arch_64/arch_intrinsics.h
@@ -13,6 +13,8 @@
#ifndef OSSL_CRYPTO_EC_CURVE448_ARCH_64_INTRINSICS_H
#define OSSL_CRYPTO_EC_CURVE448_ARCH_64_INTRINSICS_H
+#include <stdint.h>
+
#include "internal/constant_time.h"
#define ARCH_WORD_BITS 64
diff --git a/crypto/ec/curve448/ed448.h b/crypto/ec/curve448/ed448.h
index 1c94649557..29e732d629 100644
--- a/crypto/ec/curve448/ed448.h
+++ b/crypto/ec/curve448/ed448.h
@@ -13,6 +13,8 @@
#ifndef OSSL_CRYPTO_EC_CURVE448_ED448_H
#define OSSL_CRYPTO_EC_CURVE448_ED448_H
+#include <openssl/types.h>
+
#include "point_448.h"
/* Number of bytes in an EdDSA public key. */
diff --git a/crypto/evp/evp_local.h b/crypto/evp/evp_local.h
index fc00d24840..fc01b71efc 100644
--- a/crypto/evp/evp_local.h
+++ b/crypto/evp/evp_local.h
@@ -11,6 +11,10 @@
#define OSSL_LIBCRYPTO_EVP_EVP_LOCAL_H
#include <openssl/core_dispatch.h>
+#include <openssl/evp.h>
+
+#include <crypto/evp.h>
+
#include "internal/refcount.h"
#define EVP_CTRL_RET_UNSUPPORTED -1
diff --git a/crypto/lhash/lhash_local.h b/crypto/lhash/lhash_local.h
index c35b398746..8d1b671d18 100644
--- a/crypto/lhash/lhash_local.h
+++ b/crypto/lhash/lhash_local.h
@@ -10,6 +10,7 @@
#define OSSL_LIBCRYPTO_LHASH_LHASH_LOCAL_H
#include <openssl/crypto.h>
+#include <openssl/lhash.h>
#include "internal/tsan_assist.h"
diff --git a/crypto/ml_dsa/ml_dsa_matrix.h b/crypto/ml_dsa/ml_dsa_matrix.h
index 2610e17dfe..3bc053720b 100644
--- a/crypto/ml_dsa/ml_dsa_matrix.h
+++ b/crypto/ml_dsa/ml_dsa_matrix.h
@@ -11,6 +11,8 @@
#if !defined(OSSL_LIBCRYPTO_ML_DSA_ML_DSA_MATRIX_H)
#define OSSL_LIBCRYPTO_ML_DSA_ML_DSA_MATRIX_H
+#include "ml_dsa_local.h"
+
struct matrix_st {
POLY *m_poly;
size_t k, l;
diff --git a/crypto/ml_dsa/ml_dsa_poly.h b/crypto/ml_dsa/ml_dsa_poly.h
index 3cdb38ea16..061deb147b 100644
--- a/crypto/ml_dsa/ml_dsa_poly.h
+++ b/crypto/ml_dsa/ml_dsa_poly.h
@@ -11,6 +11,8 @@
#include <openssl/crypto.h>
+#include "ml_dsa_local.h"
+
#define ML_DSA_NUM_POLY_COEFFICIENTS 256
/* Polynomial object with 256 coefficients. The coefficients are unsigned 32 bits */
diff --git a/crypto/ml_dsa/ml_dsa_sign.h b/crypto/ml_dsa/ml_dsa_sign.h
index be4b2920e0..1a13410050 100644
--- a/crypto/ml_dsa/ml_dsa_sign.h
+++ b/crypto/ml_dsa/ml_dsa_sign.h
@@ -10,6 +10,8 @@
#if !defined(OSSL_LIBCRYPTO_ML_DSA_ML_DSA_SIGN_H)
#define OSSL_LIBCRYPTO_ML_DSA_ML_DSA_SIGN_H
+#include "ml_dsa_vector.h"
+
struct ml_dsa_sig_st {
VECTOR z;
VECTOR hint;
diff --git a/crypto/objects/o_names.c b/crypto/objects/o_names.c
index 7c0bdddc7c..9ab9a2acd1 100644
--- a/crypto/objects/o_names.c
+++ b/crypto/objects/o_names.c
@@ -29,12 +29,6 @@ static LHASH_OF(OBJ_NAME) *names_lh = NULL;
static int names_type_num = OBJ_NAME_TYPE_NUM;
static CRYPTO_RWLOCK *obj_lock = NULL;
-struct name_funcs_st {
- unsigned long (*hash_func)(const char *name);
- int (*cmp_func)(const char *a, const char *b);
- void (*free_func)(const char *, int, const char *);
-};
-
static STACK_OF(NAME_FUNCS) *name_funcs_stack;
/*
diff --git a/crypto/objects/obj_local.h b/crypto/objects/obj_local.h
index b17ef9ae09..29e5cc034b 100644
--- a/crypto/objects/obj_local.h
+++ b/crypto/objects/obj_local.h
@@ -10,7 +10,16 @@
#if !defined(OSSL_LIBCRYPTO_OBJECTS_OBJ_LOCAL_H)
#define OSSL_LIBCRYPTO_OBJECTS_OBJ_LOCAL_H
-typedef struct name_funcs_st NAME_FUNCS;
+#include <openssl/lhash.h>
+#include <openssl/objects.h>
+#include <openssl/safestack.h>
+
+typedef struct name_funcs_st {
+ unsigned long (*hash_func)(const char *name);
+ int (*cmp_func)(const char *a, const char *b);
+ void (*free_func)(const char *, int, const char *);
+} NAME_FUNCS;
+
DEFINE_STACK_OF(NAME_FUNCS)
DEFINE_LHASH_OF_EX(OBJ_NAME);
typedef struct added_obj_st ADDED_OBJ;
diff --git a/crypto/ocsp/ocsp_local.h b/crypto/ocsp/ocsp_local.h
index 2a9e95852a..82676ce2d4 100644
--- a/crypto/ocsp/ocsp_local.h
+++ b/crypto/ocsp/ocsp_local.h
@@ -10,6 +10,9 @@
#if !defined(OSSL_LIBCRYPTO_OCSP_OCSP_LOCAL_H)
#define OSSL_LIBCRYPTO_OCSP_OCSP_LOCAL_H
+#include <openssl/ocsp.h>
+#include <openssl/x509v3.h>
+
#include "crypto/x509.h" /* for ossl_x509_add_cert_new() */
/*- CertID ::= SEQUENCE {
diff --git a/crypto/pkcs12/p12_local.h b/crypto/pkcs12/p12_local.h
index 9dce1e14f9..ef5866ad9b 100644
--- a/crypto/pkcs12/p12_local.h
+++ b/crypto/pkcs12/p12_local.h
@@ -10,6 +10,10 @@
#if !defined(OSSL_LIBCRYPTO_PKCS12_P12_LOCAL_H)
#define OSSL_LIBCRYPTO_PKCS12_P12_LOCAL_H
+#include <openssl/asn1.h>
+#include <openssl/pkcs12.h>
+#include <openssl/x509.h>
+
struct PKCS12_MAC_DATA_st {
X509_SIG *dinfo;
ASN1_OCTET_STRING *salt;
diff --git a/crypto/rcu_internal.h b/crypto/rcu_internal.h
index 3408923eba..e4b9aab6fa 100644
--- a/crypto/rcu_internal.h
+++ b/crypto/rcu_internal.h
@@ -11,6 +11,8 @@
#define OPENSSL_RCU_INTERNAL_H
#pragma once
+#include <internal/rcu.h>
+
struct rcu_qp;
struct rcu_cb_item {
diff --git a/crypto/slh_dsa/slh_dsa_key.h b/crypto/slh_dsa/slh_dsa_key.h
index 412bffdeea..6f7554a315 100644
--- a/crypto/slh_dsa/slh_dsa_key.h
+++ b/crypto/slh_dsa/slh_dsa_key.h
@@ -10,8 +10,15 @@
#if !defined(OSSL_LIBCRYPTO_SLH_DSA_SLH_DSA_KEY_H)
#define OSSL_LIBCRYPTO_SLH_DSA_SLH_DSA_KEY_H
+#include <openssl/crypto.h>
#include <openssl/e_os2.h>
+#include "crypto/slh_dsa.h"
+
+#include "slh_params.h"
+#include "slh_adrs.h"
+#include "slh_hash.h"
+
#define SLH_DSA_MAX_N 32
#define SLH_DSA_SK_SEED(key) ((key)->priv)
#define SLH_DSA_SK_PRF(key) ((key)->priv + (key)->params->n)
diff --git a/crypto/slh_dsa/slh_hash.h b/crypto/slh_dsa/slh_hash.h
index ded22f7e60..27f2332392 100644
--- a/crypto/slh_dsa/slh_hash.h
+++ b/crypto/slh_dsa/slh_hash.h
@@ -12,6 +12,9 @@
#pragma once
#include <openssl/e_os2.h>
+
+#include "crypto/slh_dsa.h"
+
#include "slh_adrs.h"
#include "internal/packet.h"
diff --git a/crypto/ts/ts_local.h b/crypto/ts/ts_local.h
index d86b395472..be1be4ad5f 100644
--- a/crypto/ts/ts_local.h
+++ b/crypto/ts/ts_local.h
@@ -7,13 +7,18 @@
* https://www.openssl.org/source/license.html
*/
+#if !defined(OSSL_LIBCRYPTO_TS_TS_LOCAL_H)
+#define OSSL_LIBCRYPTO_TS_TS_LOCAL_H
+
+#include <openssl/asn1.h>
+#include <openssl/ts.h>
+#include <openssl/x509.h>
+
/*-
* MessageImprint ::= SEQUENCE {
* hashAlgorithm AlgorithmIdentifier,
* hashedMessage OCTET STRING }
*/
-#if !defined(OSSL_LIBCRYPTO_TS_TS_LOCAL_H)
-#define OSSL_LIBCRYPTO_TS_TS_LOCAL_H
struct TS_msg_imprint_st {
X509_ALGOR *hash_algo;
diff --git a/crypto/x509/ext_dat.h b/crypto/x509/ext_dat.h
index bec7716135..668f05c6e9 100644
--- a/crypto/x509/ext_dat.h
+++ b/crypto/x509/ext_dat.h
@@ -10,6 +10,8 @@
#if !defined(OSSL_LIBCRYPTO_X509_EXT_DAT_H)
#define OSSL_LIBCRYPTO_X509_EXT_DAT_H
+#include <openssl/x509v3.h>
+
int ossl_v3_name_cmp(const char *name, const char *cmp);
extern const X509V3_EXT_METHOD ossl_v3_bcons, ossl_v3_nscert, ossl_v3_key_usage, ossl_v3_ext_ku;
diff --git a/crypto/x509/pcy_local.h b/crypto/x509/pcy_local.h
index 56466ea07f..0892c8dd0b 100644
--- a/crypto/x509/pcy_local.h
+++ b/crypto/x509/pcy_local.h
@@ -10,6 +10,11 @@
#if !defined(OSSL_LIBCRYPTO_X509_PCY_LOCAL_H)
#define OSSL_LIBCRYPTO_X509_PCY_LOCAL_H
+#include <openssl/asn1.h>
+#include <openssl/safestack.h>
+#include <openssl/types.h>
+#include <openssl/x509v3.h>
+
typedef struct X509_POLICY_DATA_st X509_POLICY_DATA;
DEFINE_STACK_OF(X509_POLICY_DATA)
diff --git a/crypto/x509/standard_exts.h b/crypto/x509/standard_exts.h
index 14e6455ae1..e72cc98da7 100644
--- a/crypto/x509/standard_exts.h
+++ b/crypto/x509/standard_exts.h
@@ -15,6 +15,8 @@
#if !defined(OSSL_LIBCRYPTO_X509_STANDARD_EXTS_H)
#define OSSL_LIBCRYPTO_X509_STANDARD_EXTS_H
+#include "ext_dat.h"
+
static const X509V3_EXT_METHOD *const standard_exts[] = {
&ossl_v3_nscert,
&ossl_v3_ns_ia5_list[0],
diff --git a/crypto/x509/v3_admis.h b/crypto/x509/v3_admis.h
index 75a07c1fcd..fa4a409f24 100644
--- a/crypto/x509/v3_admis.h
+++ b/crypto/x509/v3_admis.h
@@ -10,6 +10,10 @@
#ifndef OSSL_CRYPTO_X509_V3_ADMIS_H
#define OSSL_CRYPTO_X509_V3_ADMIS_H
+#include <openssl/asn1.h>
+#include <openssl/safestack.h>
+#include <openssl/x509v3.h>
+
struct NamingAuthority_st {
ASN1_OBJECT *namingAuthorityId;
ASN1_IA5STRING *namingAuthorityUrl;
diff --git a/include/crypto/riscv_arch.h b/include/crypto/riscv_arch.h
index 347b9df74f..ddc36e58f1 100644
--- a/include/crypto/riscv_arch.h
+++ b/include/crypto/riscv_arch.h
@@ -11,6 +11,7 @@
#define OSSL_CRYPTO_RISCV_ARCH_H
#include <ctype.h>
+#include <stddef.h>
#include <stdint.h>
#if defined(OPENSSL_SYS_LINUX) && !defined(FIPS_MODULE)