From 3ceee15db7dfd33091f5425ba76336915236aa2e Mon Sep 17 00:00:00 2001 From: Tennessee Carmel-Veilleux Date: Mon, 18 Jul 2022 15:23:50 -0400 Subject: [PATCH] Fix CryptoBuildConfig.h usage PR #20824 moved some defines out of CryptoBuildConfig.h by mistake. This caused some defines to be globalized but only in GN builds. Fixes #20883 This PR brings back the defines in CryptoBuildConfig.h and fixes what's needed for that to build Testing done: - Unit tests still pass - Integration tests still pass --- src/crypto/BUILD.gn | 26 +++++++++------------ src/crypto/CHIPCryptoPAL.h | 4 ++-- src/crypto/tests/AES_CCM_128_test_vectors.h | 4 ++++ 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/crypto/BUILD.gn b/src/crypto/BUILD.gn index b003f5d480da3f..359bb9d289cf0a 100644 --- a/src/crypto/BUILD.gn +++ b/src/crypto/BUILD.gn @@ -24,7 +24,15 @@ buildconfig_header("crypto_buildconfig") { header = "CryptoBuildConfig.h" header_dir = "crypto" - defines = [] + chip_crypto_mbedtls = chip_crypto == "mbedtls" + chip_crypto_openssl = chip_crypto == "openssl" + chip_crypto_boringssl = chip_crypto == "boringssl" + + defines = [ + "CHIP_CRYPTO_MBEDTLS=${chip_crypto_mbedtls}", + "CHIP_CRYPTO_OPENSSL=${chip_crypto_openssl}", + "CHIP_CRYPTO_BORINGSSL=${chip_crypto_boringssl}", + ] if (chip_with_se05x == 1) { defines += [ "CHIP_CRYPTO_HSM=1" ] @@ -39,18 +47,6 @@ buildconfig_header("crypto_buildconfig") { } } -config("crypto_config") { - chip_crypto_mbedtls = chip_crypto == "mbedtls" - chip_crypto_openssl = chip_crypto == "openssl" - chip_crypto_boringssl = chip_crypto == "boringssl" - - defines = [ - "CHIP_CRYPTO_MBEDTLS=${chip_crypto_mbedtls}", - "CHIP_CRYPTO_OPENSSL=${chip_crypto_openssl}", - "CHIP_CRYPTO_BORINGSSL=${chip_crypto_boringssl}", - ] -} - if (chip_crypto == "openssl") { import("${build_root}/config/linux/pkg_config.gni") @@ -76,6 +72,8 @@ static_library("crypto") { "RandUtils.h", ] + public_configs = [] + cflags = [ "-Wconversion" ] public_deps = [ @@ -86,8 +84,6 @@ static_library("crypto") { "${nlassert_root}:nlassert", ] - public_configs = [ ":crypto_config" ] - if (chip_crypto == "mbedtls") { sources += [ "CHIPCryptoPALmbedTLS.cpp" ] diff --git a/src/crypto/CHIPCryptoPAL.h b/src/crypto/CHIPCryptoPAL.h index 11fa24003733e2..58d4845567dc61 100644 --- a/src/crypto/CHIPCryptoPAL.h +++ b/src/crypto/CHIPCryptoPAL.h @@ -22,9 +22,9 @@ #pragma once -//#if CHIP_HAVE_CONFIG_H +#if CHIP_HAVE_CONFIG_H #include -//#endif +#endif // CHIP_HAVE_CONFIG_H #include diff --git a/src/crypto/tests/AES_CCM_128_test_vectors.h b/src/crypto/tests/AES_CCM_128_test_vectors.h index 1e1bf51005dadb..98eb06e29d6492 100644 --- a/src/crypto/tests/AES_CCM_128_test_vectors.h +++ b/src/crypto/tests/AES_CCM_128_test_vectors.h @@ -25,6 +25,10 @@ #include +#if CHIP_HAVE_CONFIG_H +#include +#endif // CHIP_HAVE_CONFIG_H + struct ccm_128_test_vector { const uint8_t * pt;