Skip to content

Commit

Permalink
Merge pull request #3454 from gilles-peskine-arm/include-common-h-dev…
Browse files Browse the repository at this point in the history
…elopment

Include common.h from all library source files
  • Loading branch information
mpg authored Jul 3, 2020
2 parents 41f2011 + e1c4362 commit 527b878
Show file tree
Hide file tree
Showing 93 changed files with 136 additions and 464 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
3 changes: 3 additions & 0 deletions ChangeLog.d/cmake-install.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Bugfix
* Library files installed after a CMake build no longer have execute
permission.
49 changes: 21 additions & 28 deletions library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,14 @@ if (NOT USE_STATIC_MBEDTLS_LIBRARY AND NOT USE_SHARED_MBEDTLS_LIBRARY)
message(FATAL_ERROR "Need to choose static or shared mbedtls build!")
endif(NOT USE_STATIC_MBEDTLS_LIBRARY AND NOT USE_SHARED_MBEDTLS_LIBRARY)

set(target_libraries "mbedcrypto" "mbedx509" "mbedtls")

if(USE_STATIC_MBEDTLS_LIBRARY AND USE_SHARED_MBEDTLS_LIBRARY)
set(mbedtls_static_target "mbedtls_static")
set(mbedx509_static_target "mbedx509_static")
set(mbedcrypto_static_target "mbedcrypto_static")
list(APPEND target_libraries
"mbedcrypto_static" "mbedx509_static" "mbedtls_static")
elseif(USE_STATIC_MBEDTLS_LIBRARY)
set(mbedtls_static_target "mbedtls")
set(mbedx509_static_target "mbedx509")
Expand All @@ -162,58 +166,47 @@ if(USE_STATIC_MBEDTLS_LIBRARY)
add_library(${mbedcrypto_static_target} STATIC ${src_crypto})
set_target_properties(${mbedcrypto_static_target} PROPERTIES OUTPUT_NAME mbedcrypto)
target_link_libraries(${mbedcrypto_static_target} ${libs})
target_include_directories(${mbedcrypto_static_target}
PUBLIC ${MBEDTLS_DIR}/include/
PUBLIC ${thirdparty_inc_public}
PRIVATE ${thirdparty_inc})
target_compile_definitions(${mbedcrypto_static_target}
PRIVATE ${thirdparty_def})

add_library(${mbedx509_static_target} STATIC ${src_x509})
set_target_properties(${mbedx509_static_target} PROPERTIES OUTPUT_NAME mbedx509)
target_link_libraries(${mbedx509_static_target} ${libs} ${mbedcrypto_static_target})
target_include_directories(${mbedx509_static_target}
PUBLIC ${MBEDTLS_DIR}/include/)

add_library(${mbedtls_static_target} STATIC ${src_tls})
set_target_properties(${mbedtls_static_target} PROPERTIES OUTPUT_NAME mbedtls)
target_link_libraries(${mbedtls_static_target} ${libs} ${mbedx509_static_target})
target_include_directories(${mbedtls_static_target}
PUBLIC ${MBEDTLS_DIR}/include/)

install(TARGETS ${mbedtls_static_target} ${mbedx509_static_target} ${mbedcrypto_static_target}
DESTINATION ${LIB_INSTALL_DIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
endif(USE_STATIC_MBEDTLS_LIBRARY)

if(USE_SHARED_MBEDTLS_LIBRARY)

add_library(mbedcrypto SHARED ${src_crypto})
set_target_properties(mbedcrypto PROPERTIES VERSION 2.23.0 SOVERSION 5)
target_link_libraries(mbedcrypto ${libs})
target_include_directories(mbedcrypto
PUBLIC ${MBEDTLS_DIR}/include/
PUBLIC ${thirdparty_inc_public}
PRIVATE ${thirdparty_inc})
target_compile_definitions(mbedcrypto
PRIVATE ${thirdparty_def})

add_library(mbedx509 SHARED ${src_x509})
set_target_properties(mbedx509 PROPERTIES VERSION 2.23.0 SOVERSION 1)
target_link_libraries(mbedx509 ${libs} mbedcrypto)
target_include_directories(mbedx509
PUBLIC ${MBEDTLS_DIR}/include/)

add_library(mbedtls SHARED ${src_tls})
set_target_properties(mbedtls PROPERTIES VERSION 2.23.0 SOVERSION 13)
target_link_libraries(mbedtls ${libs} mbedx509)
target_include_directories(mbedtls
PUBLIC ${MBEDTLS_DIR}/include/)
endif(USE_SHARED_MBEDTLS_LIBRARY)

install(TARGETS mbedtls mbedx509 mbedcrypto
foreach(target IN LISTS target_libraries)
# Include public header files from /include and other directories
# declared by /3rdparty/**/CMakeLists.txt. Include private header files
# from /library and others declared by /3rdparty/**/CMakeLists.txt.
# /library needs to be listed explicitly when building .c files outside
# of /library (which currently means: under /3rdparty).
target_include_directories(${target}
PUBLIC ${MBEDTLS_DIR}/include/
PUBLIC ${thirdparty_inc_public}
PRIVATE ${MBEDTLS_DIR}/library/
PRIVATE ${thirdparty_inc})
target_compile_definitions(${target}
PRIVATE ${thirdparty_def})
install(TARGETS ${target}
DESTINATION ${LIB_INSTALL_DIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
endif(USE_SHARED_MBEDTLS_LIBRARY)
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
endforeach(target)

add_custom_target(lib DEPENDS mbedcrypto mbedx509 mbedtls)
if(USE_STATIC_MBEDTLS_LIBRARY AND USE_SHARED_MBEDTLS_LIBRARY)
Expand Down
6 changes: 5 additions & 1 deletion library/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ CFLAGS ?= -O2
WARNING_CFLAGS ?= -Wall -Wextra
LDFLAGS ?=

LOCAL_CFLAGS = $(WARNING_CFLAGS) -I../include -D_FILE_OFFSET_BITS=64
# Include ../include for public headers and . for private headers.
# Note that . needs to be included explicitly for the sake of library
# files that are not in the /library directory (which currently means
# under /3rdparty).
LOCAL_CFLAGS = $(WARNING_CFLAGS) -I. -I../include -D_FILE_OFFSET_BITS=64
LOCAL_LDFLAGS =

ifdef DEBUG
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
Loading

0 comments on commit 527b878

Please sign in to comment.