# Copyright (C) 2021-2023 Huawei Device Co., Ltd. # 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://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. if (defined(ohos_lite)) { import("//build/lite/config/component/lite_component.gni") } else { import("//build/ohos.gni") } import("deviceauth_hals.gni") if (defined(ohos_lite)) { if (ohos_kernel_type == "liteos_m") { static_library("deviceauth_hal_liteos") { include_dirs = hals_inc_path include_dirs += [ "//base/security/device_auth/interfaces/inner_api", "//third_party/cJSON", "//commonlibrary/utils_lite/include", "//base/hiviewdfx/hilog_lite/interfaces/native/kits/hilog_lite", "//commonlibrary/utils_lite/memory/include", "//base/startup/init/interfaces/innerkits/include/syspara", "//third_party/mbedtls/include", ] sources = hal_common_files sources += [ "${key_management_adapter_path}/impl/src/common/mbedtls_ec_adapter.c", "${key_management_adapter_path}/impl/src/huks_adapter.c", "${key_management_adapter_path}/impl/src/mini/huks_adapter_diff_impl.c", "${os_adapter_path}/impl/src/liteos/hc_condition.c", "${os_adapter_path}/impl/src/liteos/hc_dev_info.c", "${os_adapter_path}/impl/src/liteos/hc_thread.c", "${os_adapter_path}/impl/src/liteos/hc_types.c", "${os_adapter_path}/impl/src/liteos/mini/hc_init_protection.c", ] if (device_auth_enable_posix_interface) { sources += [ "${os_adapter_path}/impl/src/liteos/mini/hc_file_posix.c" ] } else { sources += [ "${os_adapter_path}/impl/src/liteos/mini/hc_file.c" ] } cflags = [ "-DHILOG_ENABLE" ] cflags += [ "-DAUTH_STORAGE_PATH=\"${device_auth_storage_path}\"" ] if (board_toolchain_type == "iccarm") { cflags += [ "--diag_suppress", "Pe223,Pe226", "-DOHOS_MEM", "-DSET_THREAD_NAME", ] } else { cflags += build_flags } deps = [ "//base/security/huks/interfaces/inner_api/huks_lite:huks_3.0_sdk", "//base/startup/init/interfaces/innerkits:libbegetutil", "//build/lite/config/component/cJSON:cjson_shared", "//commonlibrary/utils_lite:utils", "//third_party/mbedtls:mbedtls_shared", ] } } else { static_library("deviceauth_hal_linux") { include_dirs = hals_inc_path include_dirs += [ "//base/security/device_auth/interfaces/inner_api", "//third_party/cJSON", "//commonlibrary/utils_lite/include", "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog", "//third_party/bounds_checking_function/include", "//base/startup/init/interfaces/innerkits/include/syspara", "//third_party/mbedtls/include", ] sources = hal_common_files sources += [ "${key_management_adapter_path}/impl/src/common/mbedtls_ec_adapter.c", "${key_management_adapter_path}/impl/src/huks_adapter.c", "${key_management_adapter_path}/impl/src/small/huks_adapter_diff_impl.c", "${os_adapter_path}/impl/src/hc_log.c", "${os_adapter_path}/impl/src/linux/hc_condition.c", "${os_adapter_path}/impl/src/linux/hc_dev_info.c", "${os_adapter_path}/impl/src/linux/hc_file.c", "${os_adapter_path}/impl/src/linux/hc_init_protection.c", "${os_adapter_path}/impl/src/linux/hc_thread.c", "${os_adapter_path}/impl/src/linux/hc_types.c", ] defines = [] if (enable_extend_plugin) { defines += [ "DEV_AUTH_PLUGIN_ENABLE" ] sources += [ "${os_adapter_path}/impl/src/liteos/small/dev_auth_dynamic_load.c", ] } cflags = build_flags cflags += [ "-DHILOG_ENABLE" ] defines += [ "LITE_DEVICE" ] deps = [ "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", "//base/security/huks/interfaces/inner_api/huks_lite:huks_3.0_sdk", "//base/startup/init/interfaces/innerkits:libbegetutil", "//build/lite/config/component/cJSON:cjson_shared", "//commonlibrary/utils_lite:utils", "//third_party/bounds_checking_function:libsec_shared", "//third_party/mbedtls:mbedtls_shared", "//third_party/openssl/ohos_lite:openssl_shared", ] } } } else { ohos_static_library("deviceauth_hal_linux") { subsystem_name = "security" part_name = "device_auth" include_dirs = hals_inc_path sources = hal_common_files sources += [ "${key_management_adapter_path}/impl/src/common/mbedtls_ec_adapter.c", "${key_management_adapter_path}/impl/src/huks_adapter.c", "${key_management_adapter_path}/impl/src/standard/crypto_hash_to_point.c", "${key_management_adapter_path}/impl/src/standard/huks_adapter_diff_impl.c", "${os_adapter_path}/impl/src/hc_log.c", "${os_adapter_path}/impl/src/linux/hc_condition.c", "${os_adapter_path}/impl/src/linux/hc_dev_info.c", "${os_adapter_path}/impl/src/linux/hc_file.c", "${os_adapter_path}/impl/src/linux/hc_init_protection.c", "${os_adapter_path}/impl/src/linux/hc_thread.c", "${os_adapter_path}/impl/src/linux/hc_types.c", ] defines = [] defines += [ "DEV_AUTH_ENABLE_CE" ] if (enable_extend_plugin) { defines += [ "DEV_AUTH_PLUGIN_ENABLE" ] sources += [ "${os_adapter_path}/impl/src/linux/dev_auth_dynamic_load.c" ] } cflags = build_flags cflags += [ "-DHILOG_ENABLE", "-DSET_THREAD_NAME", ] branch_protector_ret = "pac_ret" sanitize = { cfi = true cfi_cross_dso = true integer_overflow = true boundary_sanitize = true ubsan = true debug = false } external_deps = [ "bounds_checking_function:libsec_shared", "cJSON:cjson", "c_utils:utils", "hilog:libhilog", "huks:libhukssdk", "init:libbegetutil", "mbedtls:mbedtls_shared", "openssl:libcrypto_shared", ] } ohos_static_library("deviceauth_hal_linux_test") { subsystem_name = "security" part_name = "device_auth" include_dirs = hals_inc_path sources = hal_common_files sources += [ "${key_management_adapter_path}/impl/src/common/mbedtls_ec_adapter.c", "${key_management_adapter_path}/impl/src/huks_adapter.c", "${key_management_adapter_path}/impl/src/standard/crypto_hash_to_point.c", "${key_management_adapter_path}/impl/src/standard/huks_adapter_diff_impl.c", "${os_adapter_path}/impl/src/hc_log.c", "${os_adapter_path}/impl/src/linux/hc_condition.c", "${os_adapter_path}/impl/src/linux/hc_dev_info.c", "${os_adapter_path}/impl/src/linux/hc_file.c", "${os_adapter_path}/impl/src/linux/hc_init_protection.c", "${os_adapter_path}/impl/src/linux/hc_thread.c", "${os_adapter_path}/impl/src/linux/hc_types.c", ] defines = [] if (enable_extend_plugin) { defines += [ "DEV_AUTH_PLUGIN_ENABLE" ] sources += [ "${os_adapter_path}/impl/src/linux/dev_auth_dynamic_load.c" ] } cflags = build_flags cflags += [ "-DHILOG_ENABLE", "-DSET_THREAD_NAME", ] branch_protector_ret = "pac_ret" sanitize = { cfi = true cfi_cross_dso = true integer_overflow = true boundary_sanitize = true ubsan = true debug = false } external_deps = [ "bounds_checking_function:libsec_shared", "cJSON:cjson", "c_utils:utils", "hilog:libhilog", "huks:libhukssdk", "init:libbegetutil", "mbedtls:mbedtls_shared", "openssl:libcrypto_shared", ] } }