-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
BUILD.gn
107 lines (88 loc) · 2.87 KB
/
BUILD.gn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# Copyright (c) 2020 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http:https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")
import("//build_overrides/nlassert.gni")
import("${chip_root}/build/chip/buildconfig_header.gni")
import("crypto.gni")
buildconfig_header("crypto_buildconfig") {
header = "CryptoBuildConfig.h"
header_dir = "crypto"
chip_crypto_mbedtls = chip_crypto == "mbedtls"
chip_crypto_openssl = chip_crypto == "openssl"
defines = [
"CHIP_CRYPTO_MBEDTLS=${chip_crypto_mbedtls}",
"CHIP_CRYPTO_OPENSSL=${chip_crypto_openssl}",
"CHIP_WITH_OPENSSL=${chip_crypto_openssl}",
]
if (chip_with_se05x == 1) {
defines += [ "CHIP_CRYPTO_HSM=1" ]
defines += [ "CHIP_CRYPTO_HSM_NXP=1" ]
} else {
defines += [ "CHIP_CRYPTO_HSM=0" ]
defines += [ "CHIP_CRYPTO_HSM_NXP=0" ]
}
if (chip_with_se05x_da == 1) {
defines += [ "ENABLE_HSM_DEVICE_ATTESTATION=1" ]
}
}
if (chip_crypto == "openssl") {
import("${build_root}/config/linux/pkg_config.gni")
pkg_config("openssl_config") {
packages = [ "openssl" ]
}
} else {
import("//build_overrides/mbedtls.gni")
}
static_library("crypto") {
output_name = "libChipCrypto"
sources = [
"CHIPCryptoPAL.cpp",
"CHIPCryptoPAL.h",
"RandUtils.cpp",
"RandUtils.h",
]
cflags = [ "-Wconversion" ]
public_deps = [
":crypto_buildconfig",
"${chip_root}/src/lib/asn1",
"${chip_root}/src/lib/core",
"${nlassert_root}:nlassert",
]
public_configs = []
if (chip_crypto == "mbedtls") {
sources += [ "CHIPCryptoPALmbedTLS.cpp" ]
external_mbedtls = current_os == "zephyr"
if (!external_mbedtls) {
public_deps += [ "${mbedtls_root}:mbedtls" ]
}
} else if (chip_crypto == "openssl") {
sources += [ "CHIPCryptoPALOpenSSL.cpp" ]
public_configs += [ ":openssl_config" ]
} else {
assert(false, "Invalid CHIP crypto")
}
if (chip_with_se05x == 1) {
sources += [
"hsm/nxp/CHIPCryptoPALHsm_SE05X_HKDF.cpp",
"hsm/nxp/CHIPCryptoPALHsm_SE05X_HMAC.cpp",
"hsm/nxp/CHIPCryptoPALHsm_SE05X_P256.cpp",
"hsm/nxp/CHIPCryptoPALHsm_SE05X_PBKDF.cpp",
"hsm/nxp/CHIPCryptoPALHsm_SE05X_Spake2p.cpp",
"hsm/nxp/CHIPCryptoPALHsm_SE05X_utils.cpp",
]
public_deps += [ "${chip_root}/third_party/simw-top-mini:se05x" ]
public_configs += [ "${chip_root}/third_party/simw-top-mini:se05x_config" ]
}
}