Commit 85645be82e for openssl.org
commit 85645be82e469a815c033ed97889df27b7349648
Author: Matt Caswell <matt@openssl.org>
Date: Wed Jan 7 10:24:10 2026 +0000
Clean up some unnecessary includes
Now that we have removed lots of deadcode various files are including
more than they need to. We can slim down the list of includes.
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29446)
diff --git a/crypto/evp/e_aes.c b/crypto/evp/e_aes.c
index ce880c8b4d..edea4c8763 100644
--- a/crypto/evp/e_aes.c
+++ b/crypto/evp/e_aes.c
@@ -7,27 +7,7 @@
* https://www.openssl.org/source/license.html
*/
-/*
- * This file uses the low-level AES functions (which are deprecated for
- * non-internal use) in order to implement the EVP AES ciphers.
- */
-#include "internal/deprecated.h"
-
-#include <string.h>
-#include <assert.h>
-#include <openssl/opensslconf.h>
-#include <openssl/crypto.h>
-#include <openssl/evp.h>
-#include <openssl/err.h>
-#include <openssl/aes.h>
-#include <openssl/rand.h>
-#include <openssl/cmac.h>
#include "crypto/evp.h"
-#include "internal/cryptlib.h"
-#include "crypto/modes.h"
-#include "crypto/siv.h"
-#include "crypto/aes_platform.h"
-#include "evp_local.h"
#define BLOCK_CIPHER_generic(nid, keylen, blocksize, ivlen, nmode, mode, MODE, flags) \
static const EVP_CIPHER aes_##keylen##_##mode = { \
diff --git a/crypto/evp/e_aes_cbc_hmac_sha1.c b/crypto/evp/e_aes_cbc_hmac_sha1.c
index 0b0f7ee1c4..09d2783381 100644
--- a/crypto/evp/e_aes_cbc_hmac_sha1.c
+++ b/crypto/evp/e_aes_cbc_hmac_sha1.c
@@ -7,19 +7,9 @@
* https://www.openssl.org/source/license.html
*/
-#include <stdio.h>
-#include <string.h>
-#include <openssl/opensslconf.h>
-#include <openssl/evp.h>
-#include <openssl/objects.h>
#include <openssl/aes.h>
-#include <openssl/sha.h>
-#include <openssl/rand.h>
#include "internal/cryptlib.h"
-#include "crypto/modes.h"
#include "crypto/evp.h"
-#include "internal/constant_time.h"
-#include "evp_local.h"
#if defined(AES_ASM) && (defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || defined(_M_X64))
diff --git a/crypto/evp/e_aes_cbc_hmac_sha256.c b/crypto/evp/e_aes_cbc_hmac_sha256.c
index c027af88d3..28a622fdaf 100644
--- a/crypto/evp/e_aes_cbc_hmac_sha256.c
+++ b/crypto/evp/e_aes_cbc_hmac_sha256.c
@@ -14,19 +14,10 @@
*/
#include "internal/deprecated.h"
-#include <stdio.h>
-#include <string.h>
-#include <openssl/opensslconf.h>
-#include <openssl/evp.h>
-#include <openssl/objects.h>
#include <openssl/aes.h>
#include <openssl/sha.h>
-#include <openssl/rand.h>
#include "internal/cryptlib.h"
-#include "crypto/modes.h"
-#include "internal/constant_time.h"
#include "crypto/evp.h"
-#include "evp_local.h"
#if defined(AES_ASM) && (defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || defined(_M_X64))
diff --git a/crypto/evp/e_aria.c b/crypto/evp/e_aria.c
index f6fcbe3f50..064d2500eb 100644
--- a/crypto/evp/e_aria.c
+++ b/crypto/evp/e_aria.c
@@ -8,17 +8,10 @@
* https://www.openssl.org/source/license.html
*/
-#include "internal/deprecated.h"
+#include <openssl/macros.h>
-#include "internal/cryptlib.h"
#ifndef OPENSSL_NO_ARIA
-#include <openssl/evp.h>
-#include <openssl/modes.h>
-#include <openssl/rand.h>
-#include "crypto/aria.h"
#include "crypto/evp.h"
-#include "crypto/modes.h"
-#include "evp_local.h"
IMPLEMENT_BLOCK_CIPHER(aria_128, ks, aria, EVP_ARIA_KEY,
NID_aria_128, 16, 16, 16, 128,
@@ -80,4 +73,6 @@ BLOCK_CIPHER_aead(128, ccm, CCM)
BLOCK_CIPHER_aead(192, ccm, CCM)
BLOCK_CIPHER_aead(256, ccm, CCM)
+#else
+NON_EMPTY_TRANSLATION_UNIT
#endif
diff --git a/crypto/evp/e_bf.c b/crypto/evp/e_bf.c
index 444145d109..542f536fd0 100644
--- a/crypto/evp/e_bf.c
+++ b/crypto/evp/e_bf.c
@@ -7,15 +7,13 @@
* https://www.openssl.org/source/license.html
*/
-#include <stdio.h>
-#include "internal/cryptlib.h"
+#include <openssl/macros.h>
+
#ifndef OPENSSL_NO_BF
-#include <openssl/evp.h>
#include "crypto/evp.h"
-#include <openssl/objects.h>
-#include <openssl/blowfish.h>
-#include "evp_local.h"
IMPLEMENT_BLOCK_CIPHER(bf, ks, BF, EVP_BF_KEY, NID_bf, 8, 16, 8, 64,
EVP_CIPH_VARIABLE_LENGTH)
+#else
+NON_EMPTY_TRANSLATION_UNIT
#endif
diff --git a/crypto/evp/e_camellia.c b/crypto/evp/e_camellia.c
index 99b69802ae..4e3349b1d8 100644
--- a/crypto/evp/e_camellia.c
+++ b/crypto/evp/e_camellia.c
@@ -7,17 +7,7 @@
* https://www.openssl.org/source/license.html
*/
-#include <openssl/opensslconf.h>
-
-#include <openssl/evp.h>
-#include <openssl/err.h>
-#include <string.h>
-#include <assert.h>
-#include <openssl/camellia.h>
#include "crypto/evp.h"
-#include "crypto/modes.h"
-#include "crypto/cmll_platform.h"
-#include "evp_local.h"
#define BLOCK_CIPHER_generic(nid, keylen, blocksize, ivlen, nmode, mode, MODE, flags) \
static const EVP_CIPHER camellia_##keylen##_##mode = { \
diff --git a/crypto/evp/e_cast.c b/crypto/evp/e_cast.c
index 18c2611e76..dbef502272 100644
--- a/crypto/evp/e_cast.c
+++ b/crypto/evp/e_cast.c
@@ -7,18 +7,16 @@
* https://www.openssl.org/source/license.html
*/
-#include <stdio.h>
-#include "internal/cryptlib.h"
+#include <openssl/macros.h>
#ifndef OPENSSL_NO_CAST
-#include <openssl/evp.h>
-#include <openssl/objects.h>
-#include "crypto/evp.h"
#include <openssl/cast.h>
-#include "evp_local.h"
+#include "crypto/evp.h"
IMPLEMENT_BLOCK_CIPHER(cast5, ks, CAST, EVP_CAST_KEY,
NID_cast5, 8, CAST_KEY_LENGTH, 8, 64,
EVP_CIPH_VARIABLE_LENGTH)
+#else
+NON_EMPTY_TRANSLATION_UNIT
#endif
diff --git a/crypto/evp/e_chacha20_poly1305.c b/crypto/evp/e_chacha20_poly1305.c
index 1aa70268c5..babc3c1888 100644
--- a/crypto/evp/e_chacha20_poly1305.c
+++ b/crypto/evp/e_chacha20_poly1305.c
@@ -7,16 +7,11 @@
* https://www.openssl.org/source/license.html
*/
-#include <stdio.h>
-#include "internal/cryptlib.h"
-#include "internal/endian.h"
+#include <openssl/macros.h>
#ifndef OPENSSL_NO_CHACHA
-#include <openssl/evp.h>
-#include <openssl/objects.h>
#include "crypto/evp.h"
-#include "evp_local.h"
#include "crypto/chacha.h"
static const EVP_CIPHER chacha20 = {
@@ -49,4 +44,6 @@ const EVP_CIPHER *EVP_chacha20_poly1305(void)
return (&chacha20_poly1305);
}
#endif
+#else
+NON_EMPTY_TRANSLATION_UNIT
#endif
diff --git a/crypto/evp/e_des.c b/crypto/evp/e_des.c
index ba4a214424..3549c09fc3 100644
--- a/crypto/evp/e_des.c
+++ b/crypto/evp/e_des.c
@@ -6,15 +6,11 @@
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
-#include <stdio.h>
-#include "internal/cryptlib.h"
+
+#include <openssl/macros.h>
+
#ifndef OPENSSL_NO_DES
-#include <openssl/evp.h>
-#include <openssl/objects.h>
#include "crypto/evp.h"
-#include <openssl/des.h>
-#include <openssl/rand.h>
-#include "evp_local.h"
BLOCK_CIPHER_defs(des, EVP_DES_KEY, NID_des, 8, 8, 8, 64,
EVP_CIPH_RAND_KEY)
@@ -25,4 +21,6 @@ BLOCK_CIPHER_def_cfb(des, EVP_DES_KEY, NID_des, 8, 8, 1,
BLOCK_CIPHER_def_cfb(des, EVP_DES_KEY, NID_des, 8, 8, 8,
EVP_CIPH_RAND_KEY)
+#else
+NON_EMPTY_TRANSLATION_UNIT
#endif
diff --git a/crypto/evp/e_des3.c b/crypto/evp/e_des3.c
index 2557360ff7..c0d6e4abde 100644
--- a/crypto/evp/e_des3.c
+++ b/crypto/evp/e_des3.c
@@ -7,14 +7,10 @@
* https://www.openssl.org/source/license.html
*/
-#include <stdio.h>
-#include "internal/cryptlib.h"
+#include <openssl/macros.h>
+
#ifndef OPENSSL_NO_DES
-#include <openssl/objects.h>
#include "crypto/evp.h"
-#include <openssl/des.h>
-#include <openssl/rand.h>
-#include "evp_local.h"
BLOCK_CIPHER_defs(des_ede, DES_EDE_KEY, NID_des_ede, 8, 16, 8, 64,
EVP_CIPH_RAND_KEY | EVP_CIPH_FLAG_DEFAULT_ASN1)
@@ -51,4 +47,6 @@ const EVP_CIPHER *EVP_des_ede3_wrap(void)
return &des3_wrap;
}
+#else
+NON_EMPTY_TRANSLATION_UNIT
#endif
diff --git a/crypto/evp/e_idea.c b/crypto/evp/e_idea.c
index c789b3bc89..86e4ee12aa 100644
--- a/crypto/evp/e_idea.c
+++ b/crypto/evp/e_idea.c
@@ -7,17 +7,14 @@
* https://www.openssl.org/source/license.html
*/
-#include <stdio.h>
-#include "internal/cryptlib.h"
+#include <openssl/macros.h>
#ifndef OPENSSL_NO_IDEA
-#include <openssl/evp.h>
-#include <openssl/objects.h>
#include "crypto/evp.h"
-#include <openssl/idea.h>
-#include "evp_local.h"
BLOCK_CIPHER_defs(idea, IDEA_KEY_SCHEDULE, NID_idea, 8, 16, 8, 64,
0)
+#else
+NON_EMPTY_TRANSLATION_UNIT
#endif
diff --git a/crypto/evp/e_null.c b/crypto/evp/e_null.c
index c4005f19a6..7ae34e4d64 100644
--- a/crypto/evp/e_null.c
+++ b/crypto/evp/e_null.c
@@ -7,10 +7,6 @@
* https://www.openssl.org/source/license.html
*/
-#include <stdio.h>
-#include "internal/cryptlib.h"
-#include <openssl/evp.h>
-#include <openssl/objects.h>
#include "crypto/evp.h"
static const EVP_CIPHER n_cipher = {
diff --git a/crypto/evp/e_rc2.c b/crypto/evp/e_rc2.c
index d3db95527b..ec7c8a30fb 100644
--- a/crypto/evp/e_rc2.c
+++ b/crypto/evp/e_rc2.c
@@ -6,16 +6,11 @@
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
-#include <stdio.h>
-#include "internal/cryptlib.h"
+#include <openssl/macros.h>
#ifndef OPENSSL_NO_RC2
-
-#include <openssl/evp.h>
-#include <openssl/objects.h>
#include "crypto/evp.h"
#include <openssl/rc2.h>
-#include "evp_local.h"
IMPLEMENT_BLOCK_CIPHER(rc2, ks, RC2, EVP_RC2_KEY, NID_rc2,
8,
@@ -46,4 +41,6 @@ const EVP_CIPHER *EVP_rc2_40_cbc(void)
return &r2_40_cbc_cipher;
}
+#else
+NON_EMPTY_TRANSLATION_UNIT
#endif
diff --git a/crypto/evp/e_rc4.c b/crypto/evp/e_rc4.c
index 6cab17c27b..69b525a3c3 100644
--- a/crypto/evp/e_rc4.c
+++ b/crypto/evp/e_rc4.c
@@ -7,15 +7,9 @@
* https://www.openssl.org/source/license.html
*/
-#include <stdio.h>
-#include "internal/cryptlib.h"
+#include <openssl/macros.h>
#ifndef OPENSSL_NO_RC4
-
-#include <openssl/evp.h>
-#include <openssl/objects.h>
-#include <openssl/rc4.h>
-
#include "crypto/evp.h"
static const EVP_CIPHER r4_cipher = {
@@ -41,4 +35,6 @@ const EVP_CIPHER *EVP_rc4_40(void)
{
return &r4_40_cipher;
}
+#else
+NON_EMPTY_TRANSLATION_UNIT
#endif
diff --git a/crypto/evp/e_rc4_hmac_md5.c b/crypto/evp/e_rc4_hmac_md5.c
index 65adc8ea79..86752a30b7 100644
--- a/crypto/evp/e_rc4_hmac_md5.c
+++ b/crypto/evp/e_rc4_hmac_md5.c
@@ -7,17 +7,9 @@
* https://www.openssl.org/source/license.html
*/
-/*
- * MD5 and RC4 low level APIs are deprecated for public use, but still ok for
- * internal use.
- */
-#include "internal/deprecated.h"
-
-#include "internal/cryptlib.h"
-#include <openssl/opensslconf.h>
+#include <openssl/macros.h>
#if !defined(OPENSSL_NO_RC4) && !defined(OPENSSL_NO_MD5)
-
#include "crypto/evp.h"
static const EVP_CIPHER r4_hmac_md5_cipher = {
@@ -35,4 +27,6 @@ const EVP_CIPHER *EVP_rc4_hmac_md5(void)
{
return &r4_hmac_md5_cipher;
}
+#else
+NON_EMPTY_TRANSLATION_UNIT
#endif
diff --git a/crypto/evp/e_rc5.c b/crypto/evp/e_rc5.c
index 48b011a697..64a4823cb9 100644
--- a/crypto/evp/e_rc5.c
+++ b/crypto/evp/e_rc5.c
@@ -7,19 +7,16 @@
* https://www.openssl.org/source/license.html
*/
-#include <stdio.h>
-#include "internal/cryptlib.h"
+#include <openssl/macros.h>
#ifndef OPENSSL_NO_RC5
-
-#include <openssl/evp.h>
#include "crypto/evp.h"
-#include <openssl/objects.h>
-#include "evp_local.h"
#include <openssl/rc5.h>
IMPLEMENT_BLOCK_CIPHER(rc5_32_12_16, ks, RC5_32, EVP_RC5_KEY, NID_rc5,
8, RC5_32_KEY_LENGTH, 8, 64,
EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CTRL_INIT)
+#else
+NON_EMPTY_TRANSLATION_UNIT
#endif
diff --git a/crypto/evp/e_seed.c b/crypto/evp/e_seed.c
index 7a7713020c..dd1b23a843 100644
--- a/crypto/evp/e_seed.c
+++ b/crypto/evp/e_seed.c
@@ -7,14 +7,7 @@
* https://www.openssl.org/source/license.html
*/
-#include <openssl/opensslconf.h>
-#include <openssl/evp.h>
-#include <openssl/err.h>
-#include <string.h>
-#include <assert.h>
-#include <openssl/seed.h>
#include "crypto/evp.h"
-#include "evp_local.h"
IMPLEMENT_BLOCK_CIPHER(seed, ks, SEED, EVP_SEED_KEY, NID_seed,
16, 16, 16, 128, EVP_CIPH_FLAG_DEFAULT_ASN1)
diff --git a/crypto/evp/e_sm4.c b/crypto/evp/e_sm4.c
index 18477798d7..91f8a04346 100644
--- a/crypto/evp/e_sm4.c
+++ b/crypto/evp/e_sm4.c
@@ -9,16 +9,10 @@
* https://www.openssl.org/source/license.html
*/
-#include "internal/deprecated.h"
+#include <openssl/macros.h>
-#include "internal/cryptlib.h"
#ifndef OPENSSL_NO_SM4
-#include <openssl/evp.h>
-#include <openssl/modes.h>
-#include "crypto/sm4.h"
#include "crypto/evp.h"
-#include "crypto/sm4_platform.h"
-#include "evp_local.h"
#define BLOCK_CIPHER_generic(nid, blocksize, ivlen, nmode, mode, MODE, flags) \
static const EVP_CIPHER sm4_##mode = { \
@@ -39,4 +33,6 @@
BLOCK_CIPHER_generic(nid, 1, 16, ctr, ctr, CTR, flags)
DEFINE_BLOCK_CIPHERS(NID_sm4, 0)
+#else
+NON_EMPTY_TRANSLATION_UNIT
#endif
diff --git a/crypto/evp/e_xcbc_d.c b/crypto/evp/e_xcbc_d.c
index 9903f3197f..8f281c90f4 100644
--- a/crypto/evp/e_xcbc_d.c
+++ b/crypto/evp/e_xcbc_d.c
@@ -7,16 +7,10 @@
* https://www.openssl.org/source/license.html
*/
-#include <stdio.h>
-#include "internal/cryptlib.h"
+#include <openssl/macros.h>
#ifndef OPENSSL_NO_DES
-
-#include <openssl/evp.h>
-#include <openssl/objects.h>
#include "crypto/evp.h"
-#include <openssl/des.h>
-#include "evp_local.h"
static const EVP_CIPHER d_xcbc_cipher = {
NID_desx_cbc,
@@ -29,4 +23,6 @@ const EVP_CIPHER *EVP_desx_cbc(void)
{
return &d_xcbc_cipher;
}
+#else
+NON_EMPTY_TRANSLATION_UNIT
#endif