Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CryptoBuildConfig.h usage #20887

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/unit_integration_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,13 @@ jobs:
if_true: "${{ github.sha }}"
if_false: "pull-${{ github.event.pull_request.number }}"
- name: Setup Build
# TODO: If rotating_device_id is ever removed/combined, we have to cover boringssl otherwise
run: |
case $BUILD_TYPE in
"main") GN_ARGS='';;
"clang") GN_ARGS='is_clang=true';;
"mbedtls") GN_ARGS='chip_crypto="mbedtls"';;
"rotating_device_id") GN_ARGS='chip_enable_rotating_device_id=true';;
"rotating_device_id") GN_ARGS='chip_crypto="boringssl" chip_enable_rotating_device_id=true';;
*) ;;
esac

Expand Down
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