Skip to content

Commit

Permalink
Fix CryptoBuildConfig.h usage
Browse files Browse the repository at this point in the history
PR project-chip#20824 moved some defines out of CryptoBuildConfig.h by mistake.

This caused some defines to be globalized but only in GN builds.

Fixes project-chip#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
  • Loading branch information
tcarmelveilleux committed Jul 18, 2022
1 parent 953abf5 commit 3ceee15
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
26 changes: 11 additions & 15 deletions src/crypto/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
Expand All @@ -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")

Expand All @@ -76,6 +72,8 @@ static_library("crypto") {
"RandUtils.h",
]

public_configs = []

cflags = [ "-Wconversion" ]

public_deps = [
Expand All @@ -86,8 +84,6 @@ static_library("crypto") {
"${nlassert_root}:nlassert",
]

public_configs = [ ":crypto_config" ]

if (chip_crypto == "mbedtls") {
sources += [ "CHIPCryptoPALmbedTLS.cpp" ]

Expand Down
4 changes: 2 additions & 2 deletions src/crypto/CHIPCryptoPAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@

#pragma once

//#if CHIP_HAVE_CONFIG_H
#if CHIP_HAVE_CONFIG_H
#include <crypto/CryptoBuildConfig.h>
//#endif
#endif // CHIP_HAVE_CONFIG_H

#include <system/SystemConfig.h>

Expand Down
4 changes: 4 additions & 0 deletions src/crypto/tests/AES_CCM_128_test_vectors.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@

#include <lib/core/CHIPError.h>

#if CHIP_HAVE_CONFIG_H
#include <crypto/CryptoBuildConfig.h>
#endif // CHIP_HAVE_CONFIG_H

struct ccm_128_test_vector
{
const uint8_t * pt;
Expand Down

0 comments on commit 3ceee15

Please sign in to comment.