• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2021-2025 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6#     http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14if (defined(ohos_lite)) {
15  import("//build/lite/config/component/lite_component.gni")
16} else {
17  import("//build/ohos.gni")
18}
19import("deviceauth_hals.gni")
20
21if (defined(ohos_lite)) {
22  if (ohos_kernel_type == "liteos_m") {
23    static_library("deviceauth_hal_liteos") {
24      include_dirs = hals_inc_path
25      include_dirs += [
26        "//base/security/device_auth/interfaces/inner_api",
27        "//third_party/cJSON",
28        "//commonlibrary/utils_lite/include",
29        "//base/hiviewdfx/hilog_lite/interfaces/native/kits/hilog_lite",
30        "//commonlibrary/utils_lite/memory/include",
31        "//base/startup/init/interfaces/innerkits/include/syspara",
32      ]
33
34      if (device_auth_use_customized_key_adapter == false) {
35        include_dirs += [ "//third_party/mbedtls/include" ]
36      }
37
38      sources = hal_common_files
39      sources += [
40        "${os_adapter_path}/impl/src/liteos/hc_condition.c",
41        "${os_adapter_path}/impl/src/liteos/hc_dev_info.c",
42        "${os_adapter_path}/impl/src/liteos/hc_thread.c",
43        "${os_adapter_path}/impl/src/liteos/hc_types.c",
44        "${os_adapter_path}/impl/src/liteos/mini/hc_init_protection.c",
45      ]
46
47      if (device_auth_use_customized_key_adapter == false) {
48        sources += [
49          "${key_management_adapter_path}/impl/src/common/mbedtls_ec_adapter.c",
50          "${key_management_adapter_path}/impl/src/huks_adapter.c",
51          "${key_management_adapter_path}/impl/src/huks_adapter_utils.c",
52          "${key_management_adapter_path}/impl/src/mini/huks_adapter_diff_impl.c",
53        ]
54      }
55
56      if (device_auth_enable_posix_interface) {
57        sources += [ "${os_adapter_path}/impl/src/liteos/mini/hc_file_posix.c" ]
58      } else {
59        sources += [ "${os_adapter_path}/impl/src/liteos/mini/hc_file.c" ]
60      }
61
62      cflags = [ "-DHILOG_ENABLE" ]
63      cflags += [ "-DAUTH_STORAGE_PATH=\"${device_auth_storage_path}\"" ]
64      if (board_toolchain_type == "iccarm") {
65        cflags += [
66          "--diag_suppress",
67          "Pe223,Pe226",
68          "-DOHOS_MEM",
69          "-DSET_THREAD_NAME",
70        ]
71      } else if (board_toolchain_type == "clang") {
72        cflags += [
73          "-DOHOS_MEM",
74          "-DSET_THREAD_NAME",
75        ]
76      } else {
77        cflags += build_flags
78      }
79      deps = [
80        "//base/startup/init/interfaces/innerkits:libbegetutil",
81        "//build/lite/config/component/cJSON:cjson_shared",
82        "//commonlibrary/utils_lite:utils",
83      ]
84      if (device_auth_use_customized_key_adapter == false) {
85        deps += [
86          "//base/security/huks/interfaces/inner_api/huks_lite:huks_3.0_sdk",
87          "//third_party/mbedtls:mbedtls_shared",
88        ]
89      }
90    }
91  } else {
92    static_library("deviceauth_hal_linux") {
93      include_dirs = hals_inc_path
94      include_dirs += [
95        "//base/security/device_auth/interfaces/inner_api",
96        "//third_party/cJSON",
97        "//commonlibrary/utils_lite/include",
98        "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog",
99        "//third_party/bounds_checking_function/include",
100        "//base/startup/init/interfaces/innerkits/include/syspara",
101        "//third_party/mbedtls/include",
102      ]
103
104      sources = hal_common_files
105      sources += [
106        "${key_management_adapter_path}/impl/src/common/mbedtls_ec_adapter.c",
107        "${key_management_adapter_path}/impl/src/huks_adapter.c",
108        "${key_management_adapter_path}/impl/src/huks_adapter_utils.c",
109        "${key_management_adapter_path}/impl/src/small/huks_adapter_diff_impl.c",
110        "${os_adapter_path}/impl/src/hc_log.c",
111        "${os_adapter_path}/impl/src/linux/hc_condition.c",
112        "${os_adapter_path}/impl/src/linux/hc_dev_info.c",
113        "${os_adapter_path}/impl/src/linux/hc_file.c",
114        "${os_adapter_path}/impl/src/linux/hc_init_protection.c",
115        "${os_adapter_path}/impl/src/linux/hc_thread.c",
116        "${os_adapter_path}/impl/src/linux/hc_types.c",
117      ]
118
119      defines = []
120      if (enable_extend_plugin) {
121        defines += [ "DEV_AUTH_PLUGIN_ENABLE" ]
122        sources += [
123          "${os_adapter_path}/impl/src/liteos/small/dev_auth_dynamic_load.c",
124        ]
125      }
126
127      cflags = build_flags
128      cflags += [ "-DHILOG_ENABLE" ]
129      defines += [ "LITE_DEVICE" ]
130      deps = [
131        "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
132        "//base/security/huks/interfaces/inner_api/huks_lite:huks_3.0_sdk",
133        "//base/startup/init/interfaces/innerkits:libbegetutil",
134        "//build/lite/config/component/cJSON:cjson_shared",
135        "//commonlibrary/utils_lite:utils",
136        "//third_party/bounds_checking_function:libsec_shared",
137        "//third_party/mbedtls:mbedtls_shared",
138      ]
139    }
140  }
141} else {
142  ohos_static_library("deviceauth_hal_linux") {
143    subsystem_name = "security"
144    part_name = "device_auth"
145    include_dirs = hals_inc_path
146
147    sources = hal_common_files
148    sources += [
149      "${key_management_adapter_path}/impl/src/common/mbedtls_ec_adapter.c",
150      "${key_management_adapter_path}/impl/src/huks_adapter.c",
151      "${key_management_adapter_path}/impl/src/huks_adapter_utils.c",
152      "${key_management_adapter_path}/impl/src/standard/crypto_hash_to_point.c",
153      "${key_management_adapter_path}/impl/src/standard/huks_adapter_diff_impl.c",
154      "${os_adapter_path}/impl/src/hc_log.c",
155      "${os_adapter_path}/impl/src/linux/hc_condition.c",
156      "${os_adapter_path}/impl/src/linux/hc_dev_info.c",
157      "${os_adapter_path}/impl/src/linux/hc_file.c",
158      "${os_adapter_path}/impl/src/linux/hc_init_protection.c",
159      "${os_adapter_path}/impl/src/linux/hc_thread.c",
160      "${os_adapter_path}/impl/src/linux/hc_types.c",
161    ]
162
163    defines = []
164    defines += [ "DEV_AUTH_ENABLE_CE" ]
165    if (enable_extend_plugin) {
166      defines += [ "DEV_AUTH_PLUGIN_ENABLE" ]
167      sources += [ "${os_adapter_path}/impl/src/linux/dev_auth_dynamic_load.c" ]
168    }
169
170    cflags = build_flags
171    cflags += [
172      "-DHILOG_ENABLE",
173      "-DSET_THREAD_NAME",
174    ]
175    branch_protector_ret = "pac_ret"
176    sanitize = {
177      cfi = true
178      cfi_cross_dso = true
179      integer_overflow = true
180      boundary_sanitize = true
181      ubsan = true
182      debug = false
183    }
184    external_deps = [
185      "bounds_checking_function:libsec_shared",
186      "cJSON:cjson",
187      "c_utils:utils",
188      "hilog:libhilog",
189      "huks:libhukssdk",
190      "init:libbegetutil",
191      "mbedtls:mbedtls_shared",
192      "openssl:libcrypto_shared",
193    ]
194  }
195
196  ohos_static_library("deviceauth_hal_linux_test") {
197    subsystem_name = "security"
198    part_name = "device_auth"
199    include_dirs = hals_inc_path
200
201    sources = hal_common_files
202    sources += [
203      "${key_management_adapter_path}/impl/src/common/mbedtls_ec_adapter.c",
204      "${key_management_adapter_path}/impl/src/huks_adapter.c",
205      "${key_management_adapter_path}/impl/src/huks_adapter_utils.c",
206      "${key_management_adapter_path}/impl/src/standard/crypto_hash_to_point.c",
207      "${key_management_adapter_path}/impl/src/standard/huks_adapter_diff_impl.c",
208      "${os_adapter_path}/impl/src/hc_log.c",
209      "${os_adapter_path}/impl/src/linux/hc_condition.c",
210      "${os_adapter_path}/impl/src/linux/hc_dev_info.c",
211      "${os_adapter_path}/impl/src/linux/hc_file.c",
212      "${os_adapter_path}/impl/src/linux/hc_init_protection.c",
213      "${os_adapter_path}/impl/src/linux/hc_thread.c",
214      "${os_adapter_path}/impl/src/linux/hc_types.c",
215    ]
216
217    defines = []
218    if (enable_extend_plugin) {
219      defines += [ "DEV_AUTH_PLUGIN_ENABLE" ]
220      sources += [ "${os_adapter_path}/impl/src/linux/dev_auth_dynamic_load.c" ]
221    }
222
223    cflags = build_flags
224    cflags += [
225      "-DHILOG_ENABLE",
226      "-DSET_THREAD_NAME",
227    ]
228    branch_protector_ret = "pac_ret"
229    sanitize = {
230      cfi = true
231      cfi_cross_dso = true
232      integer_overflow = true
233      boundary_sanitize = true
234      ubsan = true
235      debug = false
236    }
237    external_deps = [
238      "bounds_checking_function:libsec_shared",
239      "cJSON:cjson",
240      "c_utils:utils",
241      "hilog:libhilog",
242      "huks:libhukssdk",
243      "init:libbegetutil",
244      "mbedtls:mbedtls_shared",
245      "openssl:libcrypto_shared",
246    ]
247  }
248}
249