Skip to content

Commit

Permalink
Include common.h instead of config.h in library source files
Browse files Browse the repository at this point in the history
In library source files, include "common.h", which takes care of
including "mbedtls/config.h" (or the alternative MBEDTLS_CONFIG_FILE)
and other things that are used throughout the library.

FROM=$'#if !defined(MBEDTLS_CONFIG_FILE)\n#include "mbedtls/config.h"\n#else\n#include MBEDTLS_CONFIG_FILE\n#endif' perl -i -0777 -pe 's~\Q$ENV{FROM}~#include "common.h"~' library/*.c 3rdparty/*/library/*.c scripts/data_files/error.fmt scripts/data_files/version_features.fmt

Signed-off-by: Gilles Peskine <[email protected]>
  • Loading branch information
gilles-peskine-arm committed Jul 2, 2020
1 parent 66c3dc4 commit db09ef6
Show file tree
Hide file tree
Showing 86 changed files with 86 additions and 430 deletions.
6 changes: 1 addition & 5 deletions 3rdparty/everest/library/Hacl_Curve25519_joined.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@
* This file is part of mbed TLS (https://tls.mbed.org)
*/

#if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "common.h"

#if defined(MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED)

Expand Down
6 changes: 1 addition & 5 deletions 3rdparty/everest/library/everest.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@
* This file is part of Mbed TLS (https://tls.mbed.org).
*/

#if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "common.h"

#include <string.h>

Expand Down
6 changes: 1 addition & 5 deletions 3rdparty/everest/library/x25519.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@
* This file is part of mbed TLS (https://tls.mbed.org)
*/

#if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "common.h"

#if defined(MBEDTLS_ECDH_C) && defined(MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED)

Expand Down
6 changes: 1 addition & 5 deletions library/aes.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@
* http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf
*/

#if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "common.h"

#if defined(MBEDTLS_AES_C)

Expand Down
6 changes: 1 addition & 5 deletions library/aesni.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@
* [CLMUL-WP] http://software.intel.com/en-us/articles/intel-carry-less-multiplication-instruction-and-its-usage-for-computing-the-gcm-mode/
*/

#if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "common.h"

#if defined(MBEDTLS_AESNI_C)

Expand Down
6 changes: 1 addition & 5 deletions library/arc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@
* http://groups.google.com/group/sci.crypt/msg/10a300c9d21afca0
*/

#if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "common.h"

#if defined(MBEDTLS_ARC4_C)

Expand Down
6 changes: 1 addition & 5 deletions library/aria.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@
* [2] https://tools.ietf.org/html/rfc5794
*/

#if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "common.h"

#if defined(MBEDTLS_ARIA_C)

Expand Down
6 changes: 1 addition & 5 deletions library/asn1parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@
* This file is part of mbed TLS (https://tls.mbed.org)
*/

#if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "common.h"

#if defined(MBEDTLS_ASN1_PARSE_C)

Expand Down
6 changes: 1 addition & 5 deletions library/asn1write.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@
* This file is part of mbed TLS (https://tls.mbed.org)
*/

#if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "common.h"

#if defined(MBEDTLS_ASN1_WRITE_C)

Expand Down
6 changes: 1 addition & 5 deletions library/base64.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@
* This file is part of mbed TLS (https://tls.mbed.org)
*/

#if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "common.h"

#if defined(MBEDTLS_BASE64_C)

Expand Down
6 changes: 1 addition & 5 deletions library/bignum.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@
*
*/

#if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "common.h"

#if defined(MBEDTLS_BIGNUM_C)

Expand Down
6 changes: 1 addition & 5 deletions library/blowfish.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@
*
*/

#if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "common.h"

#if defined(MBEDTLS_BLOWFISH_C)

Expand Down
6 changes: 1 addition & 5 deletions library/camellia.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@
* http://info.isl.ntt.co.jp/crypt/eng/camellia/dl/01espec.pdf
*/

#if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "common.h"

#if defined(MBEDTLS_CAMELLIA_C)

Expand Down
6 changes: 1 addition & 5 deletions library/ccm.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@
* RFC 5116 "An Interface and Algorithms for Authenticated Encryption"
*/

#if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "common.h"

#if defined(MBEDTLS_CCM_C)

Expand Down
6 changes: 1 addition & 5 deletions library/certs.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@
* This file is part of mbed TLS (https://tls.mbed.org)
*/

#if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "common.h"

#include "mbedtls/certs.h"

Expand Down
6 changes: 1 addition & 5 deletions library/chacha20.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@
* This file is part of mbed TLS (https://tls.mbed.org)
*/

#if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "common.h"

#if defined(MBEDTLS_CHACHA20_C)

Expand Down
6 changes: 1 addition & 5 deletions library/chachapoly.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@
*
* This file is part of mbed TLS (https://tls.mbed.org)
*/
#if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "common.h"

#if defined(MBEDTLS_CHACHAPOLY_C)

Expand Down
6 changes: 1 addition & 5 deletions library/cipher.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@
* This file is part of mbed TLS (https://tls.mbed.org)
*/

#if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "common.h"

#if defined(MBEDTLS_CIPHER_C)

Expand Down
6 changes: 1 addition & 5 deletions library/cipher_wrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@
* This file is part of mbed TLS (https://tls.mbed.org)
*/

#if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "common.h"

#if defined(MBEDTLS_CIPHER_C)

Expand Down
6 changes: 1 addition & 5 deletions library/cmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@
*
*/

#if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "common.h"

#if defined(MBEDTLS_CMAC_C)

Expand Down
6 changes: 1 addition & 5 deletions library/ctr_drbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@
* http://csrc.nist.gov/publications/nistpubs/800-90/SP800-90revised_March2007.pdf
*/

#if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "common.h"

#if defined(MBEDTLS_CTR_DRBG_C)

Expand Down
6 changes: 1 addition & 5 deletions library/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@
* This file is part of mbed TLS (https://tls.mbed.org)
*/

#if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "common.h"

#if defined(MBEDTLS_DEBUG_C)

Expand Down
6 changes: 1 addition & 5 deletions library/des.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@
* http://csrc.nist.gov/publications/fips/fips46-3/fips46-3.pdf
*/

#if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "common.h"

#if defined(MBEDTLS_DES_C)

Expand Down
6 changes: 1 addition & 5 deletions library/dhm.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@
*
*/

#if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "common.h"

#if defined(MBEDTLS_DHM_C)

Expand Down
6 changes: 1 addition & 5 deletions library/ecdh.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@
* RFC 4492
*/

#if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "common.h"

#if defined(MBEDTLS_ECDH_C)

Expand Down
6 changes: 1 addition & 5 deletions library/ecdsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@
* SEC1 http://www.secg.org/index.php?action=secg,docs_secg
*/

#if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "common.h"

#if defined(MBEDTLS_ECDSA_C)

Expand Down
6 changes: 1 addition & 5 deletions library/ecjpake.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@
* available to members of the Thread Group http://threadgroup.org/
*/

#if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "common.h"

#if defined(MBEDTLS_ECJPAKE_C)

Expand Down
6 changes: 1 addition & 5 deletions library/ecp.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,7 @@
* <http://eprint.iacr.org/2004/342.pdf>
*/

#if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "common.h"

/**
* \brief Function level alternative implementation.
Expand Down
6 changes: 1 addition & 5 deletions library/ecp_curves.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@
* This file is part of mbed TLS (https://tls.mbed.org)
*/

#if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "common.h"

#if defined(MBEDTLS_ECP_C)

Expand Down
6 changes: 1 addition & 5 deletions library/entropy.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@
* This file is part of mbed TLS (https://tls.mbed.org)
*/

#if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "common.h"

#if defined(MBEDTLS_ENTROPY_C)

Expand Down
Loading

0 comments on commit db09ef6

Please sign in to comment.