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 { 72 cflags += build_flags 73 } 74 deps = [ 75 "//base/startup/init/interfaces/innerkits:libbegetutil", 76 "//build/lite/config/component/cJSON:cjson_shared", 77 "//commonlibrary/utils_lite:utils", 78 ] 79 if (device_auth_use_customized_key_adapter == false) { 80 deps += [ 81 "//base/security/huks/interfaces/inner_api/huks_lite:huks_3.0_sdk", 82 "//third_party/mbedtls:mbedtls_shared", 83 ] 84 } 85 } 86 } else { 87 static_library("deviceauth_hal_linux") { 88 include_dirs = hals_inc_path 89 include_dirs += [ 90 "//base/security/device_auth/interfaces/inner_api", 91 "//third_party/cJSON", 92 "//commonlibrary/utils_lite/include", 93 "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog", 94 "//third_party/bounds_checking_function/include", 95 "//base/startup/init/interfaces/innerkits/include/syspara", 96 "//third_party/mbedtls/include", 97 ] 98 99 sources = hal_common_files 100 sources += [ 101 "${key_management_adapter_path}/impl/src/common/mbedtls_ec_adapter.c", 102 "${key_management_adapter_path}/impl/src/huks_adapter.c", 103 "${key_management_adapter_path}/impl/src/huks_adapter_utils.c", 104 "${key_management_adapter_path}/impl/src/small/huks_adapter_diff_impl.c", 105 "${os_adapter_path}/impl/src/hc_log.c", 106 "${os_adapter_path}/impl/src/linux/hc_condition.c", 107 "${os_adapter_path}/impl/src/linux/hc_dev_info.c", 108 "${os_adapter_path}/impl/src/linux/hc_file.c", 109 "${os_adapter_path}/impl/src/linux/hc_init_protection.c", 110 "${os_adapter_path}/impl/src/linux/hc_thread.c", 111 "${os_adapter_path}/impl/src/linux/hc_types.c", 112 ] 113 114 defines = [] 115 if (enable_extend_plugin) { 116 defines += [ "DEV_AUTH_PLUGIN_ENABLE" ] 117 sources += [ 118 "${os_adapter_path}/impl/src/liteos/small/dev_auth_dynamic_load.c", 119 ] 120 } 121 122 cflags = build_flags 123 cflags += [ "-DHILOG_ENABLE" ] 124 defines += [ "LITE_DEVICE" ] 125 deps = [ 126 "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", 127 "//base/security/huks/interfaces/inner_api/huks_lite:huks_3.0_sdk", 128 "//base/startup/init/interfaces/innerkits:libbegetutil", 129 "//build/lite/config/component/cJSON:cjson_shared", 130 "//commonlibrary/utils_lite:utils", 131 "//third_party/bounds_checking_function:libsec_shared", 132 "//third_party/mbedtls:mbedtls_shared", 133 ] 134 } 135 } 136} else { 137 ohos_static_library("deviceauth_hal_linux") { 138 subsystem_name = "security" 139 part_name = "device_auth" 140 include_dirs = hals_inc_path 141 142 sources = hal_common_files 143 sources += [ 144 "${key_management_adapter_path}/impl/src/common/mbedtls_ec_adapter.c", 145 "${key_management_adapter_path}/impl/src/huks_adapter.c", 146 "${key_management_adapter_path}/impl/src/huks_adapter_utils.c", 147 "${key_management_adapter_path}/impl/src/standard/crypto_hash_to_point.c", 148 "${key_management_adapter_path}/impl/src/standard/huks_adapter_diff_impl.c", 149 "${os_adapter_path}/impl/src/hc_log.c", 150 "${os_adapter_path}/impl/src/linux/hc_condition.c", 151 "${os_adapter_path}/impl/src/linux/hc_dev_info.c", 152 "${os_adapter_path}/impl/src/linux/hc_file.c", 153 "${os_adapter_path}/impl/src/linux/hc_init_protection.c", 154 "${os_adapter_path}/impl/src/linux/hc_thread.c", 155 "${os_adapter_path}/impl/src/linux/hc_types.c", 156 ] 157 158 defines = [] 159 defines += [ "DEV_AUTH_ENABLE_CE" ] 160 if (enable_extend_plugin) { 161 defines += [ "DEV_AUTH_PLUGIN_ENABLE" ] 162 sources += [ "${os_adapter_path}/impl/src/linux/dev_auth_dynamic_load.c" ] 163 } 164 165 cflags = build_flags 166 cflags += [ 167 "-DHILOG_ENABLE", 168 "-DSET_THREAD_NAME", 169 ] 170 branch_protector_ret = "pac_ret" 171 sanitize = { 172 cfi = true 173 cfi_cross_dso = true 174 integer_overflow = true 175 boundary_sanitize = true 176 ubsan = true 177 debug = false 178 } 179 external_deps = [ 180 "bounds_checking_function:libsec_shared", 181 "cJSON:cjson", 182 "c_utils:utils", 183 "hilog:libhilog", 184 "huks:libhukssdk", 185 "init:libbegetutil", 186 "mbedtls:mbedtls_shared", 187 "openssl:libcrypto_shared", 188 ] 189 } 190 191 ohos_static_library("deviceauth_hal_linux_test") { 192 subsystem_name = "security" 193 part_name = "device_auth" 194 include_dirs = hals_inc_path 195 196 sources = hal_common_files 197 sources += [ 198 "${key_management_adapter_path}/impl/src/common/mbedtls_ec_adapter.c", 199 "${key_management_adapter_path}/impl/src/huks_adapter.c", 200 "${key_management_adapter_path}/impl/src/huks_adapter_utils.c", 201 "${key_management_adapter_path}/impl/src/standard/crypto_hash_to_point.c", 202 "${key_management_adapter_path}/impl/src/standard/huks_adapter_diff_impl.c", 203 "${os_adapter_path}/impl/src/hc_log.c", 204 "${os_adapter_path}/impl/src/linux/hc_condition.c", 205 "${os_adapter_path}/impl/src/linux/hc_dev_info.c", 206 "${os_adapter_path}/impl/src/linux/hc_file.c", 207 "${os_adapter_path}/impl/src/linux/hc_init_protection.c", 208 "${os_adapter_path}/impl/src/linux/hc_thread.c", 209 "${os_adapter_path}/impl/src/linux/hc_types.c", 210 ] 211 212 defines = [] 213 if (enable_extend_plugin) { 214 defines += [ "DEV_AUTH_PLUGIN_ENABLE" ] 215 sources += [ "${os_adapter_path}/impl/src/linux/dev_auth_dynamic_load.c" ] 216 } 217 218 cflags = build_flags 219 cflags += [ 220 "-DHILOG_ENABLE", 221 "-DSET_THREAD_NAME", 222 ] 223 branch_protector_ret = "pac_ret" 224 sanitize = { 225 cfi = true 226 cfi_cross_dso = true 227 integer_overflow = true 228 boundary_sanitize = true 229 ubsan = true 230 debug = false 231 } 232 external_deps = [ 233 "bounds_checking_function:libsec_shared", 234 "cJSON:cjson", 235 "c_utils:utils", 236 "hilog:libhilog", 237 "huks:libhukssdk", 238 "init:libbegetutil", 239 "mbedtls:mbedtls_shared", 240 "openssl:libcrypto_shared", 241 ] 242 } 243} 244