From 51ebd81c557ab3e76b0781180c9ecf24104f3f28 Mon Sep 17 00:00:00 2001 From: h30013885 Date: Sun, 2 Mar 2025 15:46:20 +0800 Subject: [PATCH] add customized huks adapter control Signed-off-by: h30013885 --- deps_adapter/BUILD.gn | 28 +++++++++++++------ deps_adapter/deviceauth_hals.gni | 6 +++- .../inc}/huks_adapter_utils.h | 0 deviceauth_env.gni | 3 +- 4 files changed, 27 insertions(+), 10 deletions(-) rename deps_adapter/key_management_adapter/{interfaces => impl/inc}/huks_adapter_utils.h (100%) diff --git a/deps_adapter/BUILD.gn b/deps_adapter/BUILD.gn index 62cdacaf..c84a9d8c 100644 --- a/deps_adapter/BUILD.gn +++ b/deps_adapter/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021-2023 Huawei Device Co., Ltd. +# Copyright (C) 2021-2025 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 @@ -29,15 +29,14 @@ if (defined(ohos_lite)) { "//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", ] + if (device_auth_use_customized_key_adapter == false) { + include_dirs += [ "//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/huks_adapter_utils.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", @@ -45,6 +44,15 @@ if (defined(ohos_lite)) { "${os_adapter_path}/impl/src/liteos/mini/hc_init_protection.c", ] + if (device_auth_use_customized_key_adapter == false) { + 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/huks_adapter_utils.c", + "${key_management_adapter_path}/impl/src/mini/huks_adapter_diff_impl.c", + ] + } + if (device_auth_enable_posix_interface) { sources += [ "${os_adapter_path}/impl/src/liteos/mini/hc_file_posix.c" ] } else { @@ -64,12 +72,16 @@ if (defined(ohos_lite)) { 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", ] + if (device_auth_use_customized_key_adapter == false) { + deps += [ + "//base/security/huks/interfaces/inner_api/huks_lite:huks_3.0_sdk", + "//third_party/mbedtls:mbedtls_shared", + ] + } } } else { static_library("deviceauth_hal_linux") { diff --git a/deps_adapter/deviceauth_hals.gni b/deps_adapter/deviceauth_hals.gni index 492159d6..e0bbe6e2 100644 --- a/deps_adapter/deviceauth_hals.gni +++ b/deps_adapter/deviceauth_hals.gni @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (C) 2021-2025 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 @@ -26,6 +26,10 @@ if (target_os == "liteos" || "${os_adapter_path}/interfaces", "${os_adapter_path}/interfaces/liteos", ] + if (defined(ohos_lite) && ohos_kernel_type == "liteos_m" && + device_auth_use_customized_key_adapter == true) { + hals_inc_path -= [ "${key_management_adapter_path}/impl/inc" ] + } hal_module_name = "deviceauth_hal_liteos" } else { hals_inc_path = [ diff --git a/deps_adapter/key_management_adapter/interfaces/huks_adapter_utils.h b/deps_adapter/key_management_adapter/impl/inc/huks_adapter_utils.h similarity index 100% rename from deps_adapter/key_management_adapter/interfaces/huks_adapter_utils.h rename to deps_adapter/key_management_adapter/impl/inc/huks_adapter_utils.h diff --git a/deviceauth_env.gni b/deviceauth_env.gni index 2e6f115c..73384b88 100644 --- a/deviceauth_env.gni +++ b/deviceauth_env.gni @@ -1,4 +1,4 @@ -# Copyright (C) 2021-2022 Huawei Device Co., Ltd. +# Copyright (C) 2021-2025 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 @@ -25,6 +25,7 @@ services_path = "${deviceauth_path}/services" declare_args() { deviceauth_feature_config = "//base/security/device_auth/default_config" device_auth_enable_soft_bus_channel = true + device_auth_use_customized_key_adapter = false } build_flags = [