Eliminate unnecessary includes from low-level crypto modules.

Beyond generally eliminating unnecessary includes, eliminate as many
includes of headers that declare/define particularly error-prone
functionality like strlen, malloc, and free. crypto/err/internal.h was
added to remove the dependency on openssl/thread.h from the public
openssl/err.h header. The include of <stdlib.h> in openssl/mem.h was
retained since it defines OPENSSL_malloc and friends as macros around
the stdlib.h functions. The public x509.h, x509v3.h, and ssl.h headers
were not changed in order to minimize breakage of source compatibility
with external code.

Change-Id: I0d264b73ad0a720587774430b2ab8f8275960329
Reviewed-on: https://boringssl-review.googlesource.com/4220
Reviewed-by: Adam Langley <agl@google.com>
This commit is contained in:
Brian Smith
2015-03-27 21:12:01 -10:00
committed by Adam Langley
parent ef24ac396a
commit 054e682675
68 changed files with 75 additions and 56 deletions
+1
View File
@@ -57,6 +57,7 @@
#include <openssl/asn1.h>
#include <string.h>
#include <time.h>
#include <openssl/err.h>
#include <openssl/mem.h>
+1
View File
@@ -57,6 +57,7 @@
#include <openssl/asn1.h>
#include <string.h>
#include <time.h>
#include <openssl/asn1t.h>
#include <openssl/buf.h>
+1
View File
@@ -57,6 +57,7 @@
#include <openssl/asn1.h>
#include <string.h>
#include <time.h>
#include <openssl/err.h>
#include <openssl/mem.h>
+1
View File
@@ -62,6 +62,7 @@
#include <openssl/mem.h>
#include <openssl/obj.h>
#include <openssl/err.h>
#include <openssl/thread.h>
/* Utility functions for manipulating fields and offsets */
-1
View File
@@ -58,7 +58,6 @@
#include <errno.h>
#include <limits.h>
#include <stddef.h>
#include <string.h>
#include <openssl/err.h>
+1
View File
@@ -36,6 +36,7 @@
#include <openssl/bio.h>
#include <openssl/crypto.h>
#include <openssl/err.h>
#include <openssl/mem.h>
#include <algorithm>
-2
View File
@@ -13,8 +13,6 @@
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <openssl/aead.h>
+1 -1
View File
@@ -54,7 +54,7 @@
* copied and put under another distribution licence
* [including the GNU Public Licence.] */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <openssl/cipher.h>
-1
View File
@@ -60,7 +60,6 @@
#include <openssl/base.h>
#include <openssl/aead.h>
#include <openssl/asn1t.h>
#if defined(__cplusplus)
extern "C" {
+1
View File
@@ -64,6 +64,7 @@
#if !defined(OPENSSL_NO_ASM) && (defined(OPENSSL_X86) || defined(OPENSSL_X86_64))
#include <inttypes.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+2
View File
@@ -56,6 +56,8 @@
#include <openssl/des.h>
#include <stdlib.h>
#include "internal.h"
+1
View File
@@ -58,6 +58,7 @@
#include <openssl/bn.h>
#include <openssl/err.h>
#include <openssl/thread.h>
#include "internal.h"
-2
View File
@@ -51,8 +51,6 @@
#include <openssl/base.h>
#include <string.h>
#if defined(__cplusplus)
extern "C" {
+1
View File
@@ -35,6 +35,7 @@
#include <dirent.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#if defined(OPENSSL_PNACL)
+3
View File
@@ -41,6 +41,9 @@
#define NAME_MAX 255
#endif
#include <openssl/mem.h>
struct OPENSSL_dir_context_st {
WIN32_FIND_DATA ctx;
HANDLE handle;
+1
View File
@@ -67,6 +67,7 @@
#include <openssl/err.h>
#include <openssl/ex_data.h>
#include <openssl/mem.h>
#include <openssl/thread.h>
#include "internal.h"
+1
View File
@@ -66,6 +66,7 @@
#include <openssl/err.h>
#include <openssl/rand.h>
#include <openssl/sha.h>
#include <openssl/thread.h>
#include "internal.h"
+1
View File
@@ -74,6 +74,7 @@
#include <openssl/err.h>
#include <openssl/ex_data.h>
#include <openssl/mem.h>
#include <openssl/thread.h>
#include "internal.h"
+1
View File
@@ -18,6 +18,7 @@
#include <openssl/crypto.h>
#include <openssl/ec_key.h>
#include <openssl/err.h>
#include <openssl/mem.h>
#include "internal.h"
+1
View File
@@ -72,6 +72,7 @@
#include <openssl/bn.h>
#include <openssl/err.h>
#include <openssl/mem.h>
#include <openssl/thread.h>
#include "internal.h"
-1
View File
@@ -57,7 +57,6 @@
#include <openssl/bn.h>
#include <openssl/err.h>
#include <openssl/mem.h>
#include <openssl/thread.h>
#include "../ec/internal.h"
-3
View File
@@ -111,8 +111,6 @@
#include <assert.h>
#include <errno.h>
#include <inttypes.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#if defined(OPENSSL_WINDOWS)
@@ -121,7 +119,6 @@
#pragma warning(pop)
#endif
#include <openssl/lhash.h>
#include <openssl/mem.h>
#include <openssl/thread.h>
+1
View File
@@ -67,6 +67,7 @@
#include <openssl/mem.h>
#include <openssl/obj.h>
#include <openssl/rsa.h>
#include <openssl/thread.h>
#include "internal.h"
+4
View File
@@ -108,7 +108,11 @@
#include <openssl/ex_data.h>
#include <assert.h>
#include <string.h>
#include <openssl/err.h>
#include <openssl/mem.h>
#include <openssl/thread.h>
#include "crypto_error.h"
+1
View File
@@ -56,6 +56,7 @@
#include <openssl/md4.h>
#include <stdlib.h>
#include <string.h>
+3
View File
@@ -121,6 +121,9 @@ extern "C" {
#endif
#elif defined(_MSC_VER)
#if _MSC_VER >= 1300
#pragma warning(push, 3)
#include <intrin.h>
#pragma warning(pop)
#pragma intrinsic(_byteswap_uint64, _byteswap_ulong)
#define BSWAP8(x) _byteswap_uint64((uint64_t)(x))
#define BSWAP4(x) _byteswap_ulong((uint32_t)(x))
+1
View File
@@ -59,6 +59,7 @@
#include <openssl/buf.h>
#include <openssl/err.h>
#include <openssl/evp.h>
#include <openssl/mem.h>
#include <openssl/obj.h>
#include <openssl/pkcs8.h>
#include <openssl/rand.h>
-1
View File
@@ -13,7 +13,6 @@
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
#include <stdio.h>
#include <stdlib.h>
#include <openssl/bio.h>
#include <openssl/bytestring.h>
-1
View File
@@ -19,7 +19,6 @@
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+1
View File
@@ -113,6 +113,7 @@
#include <openssl/bn.h>
#include <openssl/mem.h>
#include <openssl/err.h>
#include <openssl/thread.h>
#include "internal.h"
+1 -1
View File
@@ -60,7 +60,7 @@
#include <openssl/base.h>
#include <openssl/asn1.h>
#include <openssl/thread.h>
#if defined(__cplusplus)
extern "C" {
+1
View File
@@ -64,6 +64,7 @@
#include <openssl/ex_data.h>
#include <openssl/mem.h>
#include <openssl/obj.h>
#include <openssl/thread.h>
#include "internal.h"
+1
View File
@@ -61,6 +61,7 @@
#include <openssl/bn.h>
#include <openssl/err.h>
#include <openssl/mem.h>
#include <openssl/thread.h>
#include "internal.h"
+1
View File
@@ -56,6 +56,7 @@
#include <openssl/rsa.h>
#include <stdlib.h>
#include <string.h>
#include <openssl/bn.h>
+3 -2
View File
@@ -56,10 +56,11 @@
#include <openssl/thread.h>
#include <errno.h>
#include <string.h>
#if defined(OPENSSL_WINDOWS)
#if !defined(OPENSSL_WINDOWS)
#include <errno.h>
#else
#pragma warning(push, 3)
#include <windows.h>
#pragma warning(pop)
+3
View File
@@ -67,6 +67,9 @@
#include <openssl/time_support.h>
#include <time.h>
#define SECS_PER_DAY (24 * 60 * 60)
struct tm *OPENSSL_gmtime(const time_t *time, struct tm *result) {
+1
View File
@@ -63,6 +63,7 @@
#include <openssl/err.h>
#include <openssl/lhash.h>
#include <openssl/mem.h>
#include <openssl/thread.h>
#include <openssl/x509.h>
+4 -1
View File
@@ -55,11 +55,14 @@
* copied and put under another distribution licence
* [including the GNU Public Licence.] */
#include <stdlib.h>
#include <openssl/buf.h>
#include <openssl/err.h>
#include <openssl/lhash.h>
#include <openssl/pem.h>
#include <openssl/x509.h>
#include <openssl/thread.h>
#ifndef OPENSSL_NO_STDIO
+1
View File
@@ -18,6 +18,7 @@
#include <openssl/bytestring.h>
#include <openssl/err.h>
#include <openssl/mem.h>
#include <openssl/obj.h>
#include <openssl/pem.h>
#include <openssl/stack.h>
+1
View File
@@ -18,6 +18,7 @@
#include <openssl/bytestring.h>
#include <openssl/crypto.h>
#include <openssl/mem.h>
#include <openssl/stack.h>
#include <openssl/x509.h>
+1
View File
@@ -60,6 +60,7 @@
#include <openssl/err.h>
#include <openssl/lhash.h>
#include <openssl/mem.h>
#include <openssl/thread.h>
#include <openssl/x509.h>
#include <openssl/x509v3.h>
+1
View File
@@ -64,6 +64,7 @@
#include <openssl/lhash.h>
#include <openssl/mem.h>
#include <openssl/obj.h>
#include <openssl/thread.h>
#include <openssl/x509.h>
#include <openssl/x509v3.h>
+1
View File
@@ -61,6 +61,7 @@
#include <openssl/mem.h>
#include <openssl/obj.h>
#include <openssl/stack.h>
#include <openssl/thread.h>
#include <openssl/x509.h>
#include <openssl/x509v3.h>
+1
View File
@@ -59,6 +59,7 @@
#include <openssl/asn1.h>
#include <openssl/err.h>
#include <openssl/mem.h>
#include <openssl/thread.h>
X509_INFO *X509_INFO_new(void)
+2 -1
View File
@@ -59,8 +59,9 @@
#include <string.h>
#include <openssl/asn1.h>
#include <openssl/mem.h>
#include <openssl/err.h>
#include <openssl/mem.h>
#include <openssl/thread.h>
X509_PKEY *X509_PKEY_new(void)
+1
View File
@@ -60,6 +60,7 @@
#include <openssl/evp.h>
#include <openssl/mem.h>
#include <openssl/obj.h>
#include <openssl/thread.h>
#include <openssl/x509.h>
#include "../evp/internal.h"
+1
View File
@@ -63,6 +63,7 @@
#include <openssl/digest.h>
#include <openssl/mem.h>
#include <openssl/obj.h>
#include <openssl/thread.h>
#include <openssl/x509_vfy.h>
#include <openssl/x509v3.h>
+1
View File
@@ -52,6 +52,7 @@
* (eay@cryptsoft.com). This product includes software written by Tim
* Hudson (tjh@cryptsoft.com). */
#include <stdarg.h>
#include <string.h>
#include <openssl/crypto.h>
+6
View File
@@ -56,6 +56,12 @@
#include <openssl/cast.h>
#if defined(OPENSSL_WINDOWS)
#pragma warning(push, 3)
#include <intrin.h>
#pragma warning(pop)
#endif
#include "../macros.h"
-2
View File
@@ -61,8 +61,6 @@
#include <openssl/base.h>
#include <time.h>
#include <openssl/bio.h>
#include <openssl/stack.h>
+1 -1
View File
@@ -58,7 +58,7 @@
#ifndef HEADER_ASN1T_H
#define HEADER_ASN1T_H
#include <stddef.h>
#include <openssl/base.h>
#include <openssl/asn1.h>
#ifdef OPENSSL_BUILD_SHLIBCRYPTO
+3 -1
View File
@@ -56,8 +56,8 @@
/* This file should be the first included by all BoringSSL headers. */
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <sys/types.h>
#include <openssl/opensslfeatures.h>
@@ -175,6 +175,8 @@ typedef struct buf_mem_st BUF_MEM;
typedef struct cbb_st CBB;
typedef struct cbs_st CBS;
typedef struct conf_st CONF;
typedef struct conf_value_st CONF_VALUE;
typedef int CRYPTO_THREADID;
typedef struct dh_method DH_METHOD;
typedef struct dh_st DH;
typedef struct dsa_method DSA_METHOD;
-1
View File
@@ -59,7 +59,6 @@
#include <openssl/base.h>
#include <stdarg.h>
#include <stdio.h> /* For FILE */
#include <openssl/err.h> /* for ERR_print_errors_fp */
+2 -2
View File
@@ -79,11 +79,11 @@ extern "C" {
*
* Config files are representated by a |CONF|. */
typedef struct {
struct conf_value_st {
char *section;
char *name;
char *value;
} CONF_VALUE;
};
struct conf_st {
LHASH_OF(CONF_VALUE) *data;
-1
View File
@@ -17,7 +17,6 @@
#include <openssl/base.h>
#include <openssl/mem.h>
#if defined(__cplusplus)
extern "C" {
-2
View File
@@ -112,8 +112,6 @@
#include <stdio.h>
#include <openssl/base.h>
#include <openssl/thread.h>
#include <openssl/lhash.h>
#if defined(__cplusplus)
extern "C" {
-3
View File
@@ -58,7 +58,6 @@
#define OPENSSL_HEADER_EVP_H
#include <openssl/base.h>
#include <openssl/stack.h>
/* OpenSSL included digest and cipher functions in this header so we include
* them for users that still expect that.
@@ -67,9 +66,7 @@
#include <openssl/aead.h>
#include <openssl/cipher.h>
#include <openssl/digest.h>
#include <openssl/mem.h>
#include <openssl/obj.h>
#include <openssl/thread.h>
#if defined(__cplusplus)
extern "C" {
+1
View File
@@ -58,6 +58,7 @@
#include <openssl/base.h>
#include <stdlib.h>
#include <stdarg.h>
#if defined(__cplusplus)
+1 -3
View File
@@ -58,11 +58,9 @@
#define OPENSSL_HEADER_PKCS8_H
#include <openssl/base.h>
#include <stdio.h>
#include <openssl/x509.h>
#if defined(__cplusplus)
extern "C" {
#endif
-1
View File
@@ -60,7 +60,6 @@
#include <openssl/base.h>
#include <time.h>
#if defined(__cplusplus)
extern "C" {
+1
View File
@@ -85,6 +85,7 @@
#include <openssl/bytestring.h>
#include <openssl/err.h>
#include <openssl/mem.h>
#include <openssl/x509.h>
#include "internal.h"
+1 -2
View File
@@ -16,7 +16,6 @@
#include <vector>
#include <stdio.h>
#include <string.h>
#include "internal.h"
@@ -30,7 +29,7 @@ bool ParseKeyValueArguments(std::map<std::string, std::string> *out_args,
const std::string &arg = args[i];
const struct argument *templ = nullptr;
for (size_t j = 0; templates[j].name[0] != 0; j++) {
if (strcmp(arg.c_str(), templates[j].name) == 0) {
if (arg != std::string(templates[j].name)) {
templ = &templates[j];
break;
}
-7
View File
@@ -14,13 +14,6 @@
#include <openssl/base.h>
#include <string>
#include <vector>
#include <errno.h>
#include <stdlib.h>
#include <sys/types.h>
#include <openssl/err.h>
#include <openssl/pem.h>
#include <openssl/ssl.h>
+1 -1
View File
@@ -12,8 +12,8 @@
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
extern "C" {
+1 -2
View File
@@ -21,12 +21,11 @@
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#if !defined(OPENSSL_WINDOWS)
#include <string.h>
#include <unistd.h>
#if !defined(O_BINARY)
#define O_BINARY 0
-7
View File
@@ -14,13 +14,6 @@
#include <openssl/base.h>
#include <string>
#include <vector>
#include <errno.h>
#include <stdlib.h>
#include <sys/types.h>
#include <openssl/err.h>
#include <openssl/ssl.h>
-1
View File
@@ -19,7 +19,6 @@
#include <stdint.h>
#include <string.h>
#include <time.h>
#include <openssl/aead.h>
#include <openssl/digest.h>
+1 -1
View File
@@ -18,7 +18,7 @@
#include <vector>
#include <errno.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <sys/types.h>