diff --git a/0001-adapt-compilation-tailor-dependencies.patch b/0001-adapt-compilation-tailor-dependencies.patch new file mode 100644 index 0000000000000000000000000000000000000000..281c99d852c1792929cc1560a3cb4faa05d65f91 --- /dev/null +++ b/0001-adapt-compilation-tailor-dependencies.patch @@ -0,0 +1,1080 @@ +From d226e71e438514a6923a69c03f8920fe6bde89cb Mon Sep 17 00:00:00 2001 +From: heppen +Date: Sat, 7 Oct 2023 17:17:03 +0800 +Subject: [PATCH] adapt compilation, tailor dependencies on hitrace and + hisysevent + +--- + bundle.json | 4 +- + frameworks/crypto_lite/js/napi/BUILD.gn | 2 +- + frameworks/huks_standard/main/common/BUILD.gn | 12 ++-- + .../main/common/include/hks_config.h | 10 +-- + frameworks/huks_standard/main/core/BUILD.gn | 12 ++-- + .../huks_standard/main/crypto_engine/BUILD.gn | 12 ++-- + .../main/crypto_engine/mbedtls/BUILD.gn | 12 ++-- + .../main/crypto_engine/openssl/BUILD.gn | 12 ++-- + .../huks_standard/main/os_dependency/BUILD.gn | 12 ++-- + .../innerkits/huks_standard/main/BUILD.gn | 12 ++-- + interfaces/kits/c/BUILD.gn | 2 +- + interfaces/kits/napi/BUILD.gn | 12 ++-- + services/huks_standard/BUILD.gn | 12 ++-- + .../huks_engine/main/core/BUILD.gn | 12 ++-- + .../huks_engine/main/core_dependency/BUILD.gn | 13 ++-- + .../huks_standard/huks_service/main/BUILD.gn | 12 ++-- + .../huks_service/main/core/BUILD.gn | 16 ++--- + .../huks_service/main/os_dependency/BUILD.gn | 16 ++--- + .../main/os_dependency/idl/BUILD.gn | 14 ++-- + .../huks_service/main/systemapi_mock/BUILD.gn | 10 +-- + .../hisysevent_wrapper/BUILD.gn | 12 ++-- + .../src/hisysevent_wrapper.cpp | 65 ++++++++++--------- + .../hitrace_meter_wrapper/BUILD.gn | 12 ++-- + .../src/hitrace_meter_wrapper.cpp | 10 +-- + .../main/systemapi_wrap/useridm/BUILD.gn | 14 ++-- + test/reliability/BUILD.gn | 2 +- + .../huks_standard_test/module_test/BUILD.gn | 4 +- + .../inner_kits_passthrough/BUILD.gn | 8 +-- + .../module_test/mock/BUILD.gn | 2 +- + .../os_dependency/idl/ipc/BUILD.gn | 2 +- + .../systemapi_wrap/useridm_test/BUILD.gn | 2 +- + .../storage_multithread_test/BUILD.gn | 2 +- + .../three_stage_test/BUILD.gn | 2 +- + utils/condition/BUILD.gn | 12 ++-- + utils/crypto_adapter/BUILD.gn | 12 ++-- + utils/file_operator/BUILD.gn | 12 ++-- + utils/list/BUILD.gn | 10 +-- + utils/mutex/BUILD.gn | 12 ++-- + 38 files changed, 210 insertions(+), 204 deletions(-) + +diff --git a/bundle.json b/bundle.json +index 324383a..b261207 100644 +--- a/bundle.json ++++ b/bundle.json +@@ -69,7 +69,9 @@ + "name": "//base/security/huks/interfaces/innerkits/huks_standard/main:libhukssdk", + "header": { + "header_files": [ +- "hks_api.h" ++ "hks_api.h", ++ "hks_type.h", ++ "hks_param.h" + ], + "header_base": "//base/security/huks/interfaces/innerkits/huks_standard/main/include" + } +diff --git a/frameworks/crypto_lite/js/napi/BUILD.gn b/frameworks/crypto_lite/js/napi/BUILD.gn +index 5cc2e51..fe01944 100644 +--- a/frameworks/crypto_lite/js/napi/BUILD.gn ++++ b/frameworks/crypto_lite/js/napi/BUILD.gn +@@ -17,7 +17,7 @@ import("//build/ohos.gni") + + ohos_shared_library("cipher_napi") { + defines = [ +- "L2_STANDARD", ++ # "L2_STANDARD", + "_HARDWARE_ROOT_KEY_", + "_HUKS_LOG_ENABLE_", + ] +diff --git a/frameworks/huks_standard/main/common/BUILD.gn b/frameworks/huks_standard/main/common/BUILD.gn +index 536d4cc..bfb4277 100644 +--- a/frameworks/huks_standard/main/common/BUILD.gn ++++ b/frameworks/huks_standard/main/common/BUILD.gn +@@ -21,15 +21,15 @@ config("huks_config") { + } + + ohos_static_library("libhuks_common_standard_static") { +- sanitize = { +- integer_overflow = true +- cfi = true +- debug = false +- } ++ # sanitize = { ++ # integer_overflow = true ++ # cfi = true ++ # debug = false ++ # } + subsystem_name = "security" + part_name = "huks" + defines = [ +- "L2_STANDARD", ++ # "L2_STANDARD", + "_HARDWARE_ROOT_KEY_", + "_HUKS_LOG_ENABLE_", + ] +diff --git a/frameworks/huks_standard/main/common/include/hks_config.h b/frameworks/huks_standard/main/common/include/hks_config.h +index 398f871..10847af 100644 +--- a/frameworks/huks_standard/main/common/include/hks_config.h ++++ b/frameworks/huks_standard/main/common/include/hks_config.h +@@ -25,7 +25,7 @@ + + #define HKS_SUPPORT_API_ATTEST_KEY + +-#define HKS_SUPPORT_ACCESS_TOKEN ++// #define HKS_SUPPORT_ACCESS_TOKEN + + /* AES */ + #define HKS_SUPPORT_AES_C +@@ -220,9 +220,9 @@ + #endif + + /* Key user auth access control */ +-#if defined(HKS_SUPPORT_HMAC_C) && defined(HKS_SUPPORT_API_GENERATE_KEY) && (defined(HKS_SUPPORT_API_IMPORT) || \ +- defined(HKS_SUPPORT_API_GENERATE_KEY) || defined(HKS_SUPPORT_API_IMPORT_WRAPPED_KEY)) +-#define HKS_SUPPORT_USER_AUTH_ACCESS_CONTROL +-#endif ++// #if defined(HKS_SUPPORT_HMAC_C) && defined(HKS_SUPPORT_API_GENERATE_KEY) && (defined(HKS_SUPPORT_API_IMPORT) || \ ++// defined(HKS_SUPPORT_API_GENERATE_KEY) || defined(HKS_SUPPORT_API_IMPORT_WRAPPED_KEY)) ++// #define HKS_SUPPORT_USER_AUTH_ACCESS_CONTROL ++// #endif + + #endif /* HKS_CONFIG_H */ +diff --git a/frameworks/huks_standard/main/core/BUILD.gn b/frameworks/huks_standard/main/core/BUILD.gn +index 5108a6a..675829a 100644 +--- a/frameworks/huks_standard/main/core/BUILD.gn ++++ b/frameworks/huks_standard/main/core/BUILD.gn +@@ -18,11 +18,11 @@ config("huks_config") { + } + + ohos_static_library("libhuks_core_standard_static") { +- sanitize = { +- integer_overflow = true +- cfi = true +- debug = false +- } ++ # sanitize = { ++ # integer_overflow = true ++ # cfi = true ++ # debug = false ++ # } + subsystem_name = "security" + part_name = "huks" + public_configs = [ ":huks_config" ] +@@ -32,7 +32,7 @@ ohos_static_library("libhuks_core_standard_static") { + "//third_party/openssl/include/", + ] + defines = [ +- "L2_STANDARD", ++ # "L2_STANDARD", + "_HARDWARE_ROOT_KEY_", + "_HUKS_LOG_ENABLE_", + ] +diff --git a/frameworks/huks_standard/main/crypto_engine/BUILD.gn b/frameworks/huks_standard/main/crypto_engine/BUILD.gn +index 598b3fd..a19a8fa 100644 +--- a/frameworks/huks_standard/main/crypto_engine/BUILD.gn ++++ b/frameworks/huks_standard/main/crypto_engine/BUILD.gn +@@ -15,13 +15,13 @@ import("//base/security/huks/huks.gni") + import("//build/ohos.gni") + + ohos_static_library("libhuks_crypto_engine_standard_static") { +- sanitize = { +- integer_overflow = true +- cfi = true +- debug = false +- } ++ # sanitize = { ++ # integer_overflow = true ++ # cfi = true ++ # debug = false ++ # } + defines = [ +- "L2_STANDARD", ++ # "L2_STANDARD", + "_HARDWARE_ROOT_KEY_", + "_HUKS_LOG_ENABLE_", + ] +diff --git a/frameworks/huks_standard/main/crypto_engine/mbedtls/BUILD.gn b/frameworks/huks_standard/main/crypto_engine/mbedtls/BUILD.gn +index ddd5267..47b07c8 100644 +--- a/frameworks/huks_standard/main/crypto_engine/mbedtls/BUILD.gn ++++ b/frameworks/huks_standard/main/crypto_engine/mbedtls/BUILD.gn +@@ -19,11 +19,11 @@ config("huks_config") { + } + + ohos_static_library("libhuks_mbedtls_standard_static") { +- sanitize = { +- integer_overflow = true +- cfi = true +- debug = false +- } ++ # sanitize = { ++ # integer_overflow = true ++ # cfi = true ++ # debug = false ++ # } + subsystem_name = "security" + part_name = "huks" + public_configs = [ ":huks_config" ] +@@ -31,7 +31,7 @@ ohos_static_library("libhuks_mbedtls_standard_static") { + include_dirs = [ "//commonlibrary/c_utils/base/include" ] + + defines = [ +- "L2_STANDARD", ++ # "L2_STANDARD", + "_HARDWARE_ROOT_KEY_", + "_HUKS_LOG_ENABLE_", + ] +diff --git a/frameworks/huks_standard/main/crypto_engine/openssl/BUILD.gn b/frameworks/huks_standard/main/crypto_engine/openssl/BUILD.gn +index 82e2d18..e5e7fac 100644 +--- a/frameworks/huks_standard/main/crypto_engine/openssl/BUILD.gn ++++ b/frameworks/huks_standard/main/crypto_engine/openssl/BUILD.gn +@@ -19,17 +19,17 @@ config("huks_config") { + } + + ohos_static_library("libhuks_openssl_standard_static") { +- sanitize = { +- integer_overflow = true +- cfi = true +- debug = false +- } ++ # sanitize = { ++ # integer_overflow = true ++ # cfi = true ++ # debug = false ++ # } + subsystem_name = "security" + part_name = "huks" + public_configs = [ ":huks_config" ] + + defines = [ +- "L2_STANDARD", ++ # "L2_STANDARD", + "_HARDWARE_ROOT_KEY_", + "_HUKS_LOG_ENABLE_", + ] +diff --git a/frameworks/huks_standard/main/os_dependency/BUILD.gn b/frameworks/huks_standard/main/os_dependency/BUILD.gn +index fa5d8be..d0e4bde 100644 +--- a/frameworks/huks_standard/main/os_dependency/BUILD.gn ++++ b/frameworks/huks_standard/main/os_dependency/BUILD.gn +@@ -21,18 +21,18 @@ config("huks_config") { + } + + ohos_static_library("libhuks_os_dependency_standard_static") { +- sanitize = { +- integer_overflow = true +- cfi = true +- debug = false +- } ++ # sanitize = { ++ # integer_overflow = true ++ # cfi = true ++ # debug = false ++ # } + subsystem_name = "security" + part_name = "huks" + public_configs = [ ":huks_config" ] + configs = [ "//base/security/huks/frameworks/config/build:coverage_flag" ] + include_dirs = [ "log" ] + defines = [ +- "L2_STANDARD", ++ # "L2_STANDARD", + "_HARDWARE_ROOT_KEY_", + "_HUKS_LOG_ENABLE_", + ] +diff --git a/interfaces/innerkits/huks_standard/main/BUILD.gn b/interfaces/innerkits/huks_standard/main/BUILD.gn +index 29c855d..42da762 100644 +--- a/interfaces/innerkits/huks_standard/main/BUILD.gn ++++ b/interfaces/innerkits/huks_standard/main/BUILD.gn +@@ -19,17 +19,17 @@ config("huks_config") { + + if (os_level == "standard") { + ohos_shared_library("libhukssdk") { +- sanitize = { +- integer_overflow = true +- cfi = true +- debug = false +- } ++ # sanitize = { ++ # integer_overflow = true ++ # cfi = true ++ # debug = false ++ # } + subsystem_name = "security" + part_name = "huks" + public_configs = [ ":huks_config" ] + configs = [ "//base/security/huks/frameworks/config/build:coverage_flag" ] + defines = [ +- "L2_STANDARD", ++ # "L2_STANDARD", + "_HARDWARE_ROOT_KEY_", + "_HUKS_LOG_ENABLE_", + ] +diff --git a/interfaces/kits/c/BUILD.gn b/interfaces/kits/c/BUILD.gn +index 0b5f676..18f546c 100755 +--- a/interfaces/kits/c/BUILD.gn ++++ b/interfaces/kits/c/BUILD.gn +@@ -38,7 +38,7 @@ config("huks_config") { + ohos_shared_library("huks_ndk") { + public_configs = [ ":huks_config" ] + defines = [ +- "L2_STANDARD", ++ # "L2_STANDARD", + "_HARDWARE_ROOT_KEY_", + "_HUKS_LOG_ENABLE_", + ] +diff --git a/interfaces/kits/napi/BUILD.gn b/interfaces/kits/napi/BUILD.gn +index 64812f7..bcd972a 100644 +--- a/interfaces/kits/napi/BUILD.gn ++++ b/interfaces/kits/napi/BUILD.gn +@@ -14,14 +14,14 @@ + import("//build/ohos.gni") + + ohos_shared_library("huks") { +- sanitize = { +- integer_overflow = true +- cfi = true +- debug = false +- } ++ # sanitize = { ++ # integer_overflow = true ++ # cfi = true ++ # debug = false ++ # } + defines = [ + "HUKS_NAPI_ERRORCODE_WITH_MESSAGE", +- "L2_STANDARD", ++ # "L2_STANDARD", + "_HARDWARE_ROOT_KEY_", + "_HUKS_LOG_ENABLE_", + ] +diff --git a/services/huks_standard/BUILD.gn b/services/huks_standard/BUILD.gn +index 9d15449..b5d9192 100644 +--- a/services/huks_standard/BUILD.gn ++++ b/services/huks_standard/BUILD.gn +@@ -21,15 +21,15 @@ ohos_prebuilt_etc("huks_service.rc") { + } + + ohos_shared_library("huks_service") { +- sanitize = { +- integer_overflow = true +- cfi = true +- debug = false +- } ++ # sanitize = { ++ # integer_overflow = true ++ # cfi = true ++ # debug = false ++ # } + subsystem_name = "security" + part_name = "huks" + defines = [ +- "L2_STANDARD", ++ # "L2_STANDARD", + "_HARDWARE_ROOT_KEY_", + "_HUKS_LOG_ENABLE_", + ] +diff --git a/services/huks_standard/huks_engine/main/core/BUILD.gn b/services/huks_standard/huks_engine/main/core/BUILD.gn +index b234c6c..c0c8e08 100644 +--- a/services/huks_standard/huks_engine/main/core/BUILD.gn ++++ b/services/huks_standard/huks_engine/main/core/BUILD.gn +@@ -19,17 +19,17 @@ config("huks_config") { + } + + ohos_shared_library("huks_engine_core_standard") { +- sanitize = { +- integer_overflow = true +- cfi = true +- debug = false +- } ++ # sanitize = { ++ # integer_overflow = true ++ # cfi = true ++ # debug = false ++ # } + subsystem_name = "security" + part_name = "huks" + public_configs = [ ":huks_config" ] + configs = [ "//base/security/huks/frameworks/config/build:coverage_flag" ] + defines = [ +- "L2_STANDARD", ++ # "L2_STANDARD", + "_HARDWARE_ROOT_KEY_", + "_HUKS_LOG_ENABLE_", + ] +diff --git a/services/huks_standard/huks_engine/main/core_dependency/BUILD.gn b/services/huks_standard/huks_engine/main/core_dependency/BUILD.gn +index d9c5040..6a765fd 100644 +--- a/services/huks_standard/huks_engine/main/core_dependency/BUILD.gn ++++ b/services/huks_standard/huks_engine/main/core_dependency/BUILD.gn +@@ -18,17 +18,17 @@ config("huks_config") { + } + + ohos_static_library("libhuks_core_hal_api_static") { +- sanitize = { +- integer_overflow = true +- cfi = true +- debug = false +- } ++ # sanitize = { ++ # integer_overflow = true ++ # cfi = true ++ # debug = false ++ # } + subsystem_name = "security" + part_name = "huks" + public_configs = [ ":huks_config" ] + configs = [ "//base/security/huks/frameworks/config/build:coverage_flag" ] + defines = [ +- "L2_STANDARD", ++ # "L2_STANDARD", + "_HARDWARE_ROOT_KEY_", + "_HUKS_LOG_ENABLE_", + ] +@@ -39,6 +39,7 @@ ohos_static_library("libhuks_core_hal_api_static") { + "-Werror", + ] + cflags = cflags_cc ++ cflags_c = [ "-Wno-sign-compare" ] + complete_static_lib = true + external_deps = [ "hiviewdfx_hilog_native:libhilog" ] + } +diff --git a/services/huks_standard/huks_service/main/BUILD.gn b/services/huks_standard/huks_service/main/BUILD.gn +index 710a937..2ef2925 100644 +--- a/services/huks_standard/huks_service/main/BUILD.gn ++++ b/services/huks_standard/huks_service/main/BUILD.gn +@@ -14,15 +14,15 @@ + import("//build/ohos.gni") + + ohos_static_library("libhuks_service_standard_static") { +- sanitize = { +- integer_overflow = true +- cfi = true +- debug = false +- } ++ # sanitize = { ++ # integer_overflow = true ++ # cfi = true ++ # debug = false ++ # } + subsystem_name = "security" + part_name = "huks" + defines = [ +- "L2_STANDARD", ++ # "L2_STANDARD", + "_HARDWARE_ROOT_KEY_", + "_HUKS_LOG_ENABLE_", + ] +diff --git a/services/huks_standard/huks_service/main/core/BUILD.gn b/services/huks_standard/huks_service/main/core/BUILD.gn +index 12ea145..709dfb9 100644 +--- a/services/huks_standard/huks_service/main/core/BUILD.gn ++++ b/services/huks_standard/huks_service/main/core/BUILD.gn +@@ -19,11 +19,11 @@ config("huks_config") { + } + + ohos_static_library("libhuks_service_core_standard_static") { +- sanitize = { +- integer_overflow = true +- cfi = true +- debug = false +- } ++ # sanitize = { ++ # integer_overflow = true ++ # cfi = true ++ # debug = false ++ # } + subsystem_name = "security" + part_name = "huks" + public_configs = [ ":huks_config" ] +@@ -32,11 +32,11 @@ ohos_static_library("libhuks_service_core_standard_static") { + "//base/security/huks/utils/file_operator", + "//base/security/huks/utils/list", + "//base/security/huks/utils/mutex", +- "//base/security/huks/services/huks_standard/huks_service/main/systemapi_wrap/hisysevent_wrapper", ++ # "//base/security/huks/services/huks_standard/huks_service/main/systemapi_wrap/hisysevent_wrapper", + "//commonlibrary/c_utils/base/include", + ] + defines = [ +- "L2_STANDARD", ++ # "L2_STANDARD", + "_HARDWARE_ROOT_KEY_", + "_HUKS_LOG_ENABLE_", + ] +@@ -74,7 +74,7 @@ ohos_static_library("libhuks_service_core_standard_static") { + } + external_deps = [ + "c_utils:utils", +- "hitrace_native:libhitracechain", ++ # "hitrace_native:libhitracechain", + "hiviewdfx_hilog_native:libhilog", + ] + complete_static_lib = true +diff --git a/services/huks_standard/huks_service/main/os_dependency/BUILD.gn b/services/huks_standard/huks_service/main/os_dependency/BUILD.gn +index d6743dc..be850e8 100644 +--- a/services/huks_standard/huks_service/main/os_dependency/BUILD.gn ++++ b/services/huks_standard/huks_service/main/os_dependency/BUILD.gn +@@ -21,17 +21,17 @@ config("huks_config") { + } + + ohos_static_library("libhuks_service_os_dependency_standard_static") { +- sanitize = { +- integer_overflow = true +- cfi = true +- debug = false +- } ++ # sanitize = { ++ # integer_overflow = true ++ # cfi = true ++ # debug = false ++ # } + subsystem_name = "security" + part_name = "huks" + public_configs = [ ":huks_config" ] + configs = [ "//base/security/huks/frameworks/config/build:coverage_flag" ] + defines = [ +- "L2_STANDARD", ++ # "L2_STANDARD", + "_HARDWARE_ROOT_KEY_", + "_HUKS_LOG_ENABLE_", + ] +@@ -56,8 +56,8 @@ ohos_static_library("libhuks_service_os_dependency_standard_static") { + sources += [ "sa/hks_event_observer.cpp" ] + defines += [ "SUPPORT_COMMON_EVENT" ] + external_deps += [ +- "ability_base:want", +- "common_event_service:cesfwk_innerkits", ++ # "ability_base:want", ++ # "common_event_service:cesfwk_innerkits", + ] + if (has_os_account_part) { + defines += [ "HAS_OS_ACCOUNT_PART" ] +diff --git a/services/huks_standard/huks_service/main/os_dependency/idl/BUILD.gn b/services/huks_standard/huks_service/main/os_dependency/idl/BUILD.gn +index c8c2747..c1f2e20 100644 +--- a/services/huks_standard/huks_service/main/os_dependency/idl/BUILD.gn ++++ b/services/huks_standard/huks_service/main/os_dependency/idl/BUILD.gn +@@ -18,18 +18,18 @@ config("huks_config") { + } + + ohos_static_library("libhuks_service_idl_standard_static") { +- sanitize = { +- integer_overflow = true +- cfi = true +- debug = false +- } ++ # sanitize = { ++ # integer_overflow = true ++ # cfi = true ++ # debug = false ++ # } + subsystem_name = "security" + part_name = "huks" + public_configs = [ ":huks_config" ] + configs = [ "//base/security/huks/frameworks/config/build:coverage_flag" ] + include_dirs = [ "//base/security/huks/services/huks_standard/huks_service/main/os_dependency/idl/passthrough" ] + defines = [ +- "L2_STANDARD", ++ # "L2_STANDARD", + "_HARDWARE_ROOT_KEY_", + "_HUKS_LOG_ENABLE_", + ] +@@ -47,7 +47,7 @@ ohos_static_library("libhuks_service_idl_standard_static") { + external_deps = [ "ipc:ipc_core" ] + + external_deps += [ +- "access_token:libaccesstoken_sdk", ++ # "access_token:libaccesstoken_sdk", + "hiviewdfx_hilog_native:libhilog", + ] + +diff --git a/services/huks_standard/huks_service/main/systemapi_mock/BUILD.gn b/services/huks_standard/huks_service/main/systemapi_mock/BUILD.gn +index 68efeca..66f480f 100644 +--- a/services/huks_standard/huks_service/main/systemapi_mock/BUILD.gn ++++ b/services/huks_standard/huks_service/main/systemapi_mock/BUILD.gn +@@ -18,11 +18,11 @@ config("libhuks_service_systemapi_mock_config") { + } + + ohos_static_library("libhuks_service_systemapi_mock_static") { +- sanitize = { +- integer_overflow = true +- cfi = true +- debug = false +- } ++ # sanitize = { ++ # integer_overflow = true ++ # cfi = true ++ # debug = false ++ # } + subsystem_name = "security" + part_name = "huks" + configs = [ "//base/security/huks/frameworks/config/build:coverage_flag" ] +diff --git a/services/huks_standard/huks_service/main/systemapi_wrap/hisysevent_wrapper/BUILD.gn b/services/huks_standard/huks_service/main/systemapi_wrap/hisysevent_wrapper/BUILD.gn +index 84809fe..faf5331 100644 +--- a/services/huks_standard/huks_service/main/systemapi_wrap/hisysevent_wrapper/BUILD.gn ++++ b/services/huks_standard/huks_service/main/systemapi_wrap/hisysevent_wrapper/BUILD.gn +@@ -19,11 +19,11 @@ config("huks_config") { + } + + ohos_static_library("libhuks_utils_hisysevent_wrapper_static") { +- sanitize = { +- integer_overflow = true +- cfi = true +- debug = false +- } ++ # sanitize = { ++ # integer_overflow = true ++ # cfi = true ++ # debug = false ++ # } + subsystem_name = "security" + part_name = "huks" + public_configs = [ ":huks_config" ] +@@ -41,7 +41,7 @@ ohos_static_library("libhuks_utils_hisysevent_wrapper_static") { + "-Werror", + ] + external_deps = [ +- "hisysevent_native:libhisysevent", ++ # "hisysevent_native:libhisysevent", + "hiviewdfx_hilog_native:libhilog", + ] + complete_static_lib = true +diff --git a/services/huks_standard/huks_service/main/systemapi_wrap/hisysevent_wrapper/src/hisysevent_wrapper.cpp b/services/huks_standard/huks_service/main/systemapi_wrap/hisysevent_wrapper/src/hisysevent_wrapper.cpp +index 2b16337..81e4738 100644 +--- a/services/huks_standard/huks_service/main/systemapi_wrap/hisysevent_wrapper/src/hisysevent_wrapper.cpp ++++ b/services/huks_standard/huks_service/main/systemapi_wrap/hisysevent_wrapper/src/hisysevent_wrapper.cpp +@@ -15,56 +15,57 @@ + + + #include "hisysevent_wrapper.h" +-#include "hisysevent.h" ++// #include "hisysevent.h" + + #include "hks_log.h" + #include "hks_template.h" + +-using namespace OHOS::HiviewDFX; ++// using namespace OHOS::HiviewDFX; + +-static constexpr const char g_eventName[] = "HUKS_FAULT"; +-static constexpr const char g_tagFunction[] = "FUNCTION"; +-static constexpr const char g_tagUserId[] = "USER_ID"; +-static constexpr const char g_tagProcessUID[] = "PROCESS_UID"; +-static constexpr const char g_tagKeyType[] = "KEY_TYPE"; +-static constexpr const char g_tagErrorCode[] = "ERROR_CODE"; +-static constexpr const char g_tagExtra[] = "EXTRA"; ++// static constexpr const char g_eventName[] = "HUKS_FAULT"; ++// static constexpr const char g_tagFunction[] = "FUNCTION"; ++// static constexpr const char g_tagUserId[] = "USER_ID"; ++// static constexpr const char g_tagProcessUID[] = "PROCESS_UID"; ++// static constexpr const char g_tagKeyType[] = "KEY_TYPE"; ++// static constexpr const char g_tagErrorCode[] = "ERROR_CODE"; ++// static constexpr const char g_tagExtra[] = "EXTRA"; + + static int32_t ConvertToHiSysEventType(enum EventType inEventType, + int32_t *outEventTypeInt) + { +- switch (inEventType) { +- case FAULT: +- *outEventTypeInt = HiSysEvent::EventType::FAULT; +- break; +- case STATISTIC: +- *outEventTypeInt = HiSysEvent::EventType::STATISTIC; +- break; +- case SECURITY: +- *outEventTypeInt = HiSysEvent::EventType::SECURITY; +- break; +- case BEHAVIOR: +- *outEventTypeInt = HiSysEvent::EventType::BEHAVIOR; +- break; +- default: +- HKS_LOG_E("Invalid inEventType!"); +- return HKS_ERROR_INVALID_ARGUMENT; +- } ++ // switch (inEventType) { ++ // case FAULT: ++ // *outEventTypeInt = HiSysEvent::EventType::FAULT; ++ // break; ++ // case STATISTIC: ++ // *outEventTypeInt = HiSysEvent::EventType::STATISTIC; ++ // break; ++ // case SECURITY: ++ // *outEventTypeInt = HiSysEvent::EventType::SECURITY; ++ // break; ++ // case BEHAVIOR: ++ // *outEventTypeInt = HiSysEvent::EventType::BEHAVIOR; ++ // break; ++ // default: ++ // HKS_LOG_E("Invalid inEventType!"); ++ // return HKS_ERROR_INVALID_ARGUMENT; ++ // } + return HKS_SUCCESS; + } + + int WriteEvent(enum EventType eventType, const char *functionName, const struct EventValues *eventValues, + const char *extra) + { ++ return 0; + int32_t outEventTypeInt = 0; + int32_t ret = ConvertToHiSysEventType(eventType, &outEventTypeInt); + HKS_IF_NOT_SUCC_LOGE_RETURN(ret, ret, "convert to hiSysEvent event type failed!") + +- enum HiSysEvent::EventType outEventType = static_cast(outEventTypeInt); ++ // enum HiSysEvent::EventType outEventType = static_cast(outEventTypeInt); + +- ret = HiSysEventWrite(HiSysEvent::Domain::HUKS, g_eventName, +- outEventType, g_tagFunction, functionName, g_tagUserId, eventValues->userId, g_tagProcessUID, +- eventValues->processName, g_tagKeyType, eventValues->keyType, g_tagErrorCode, eventValues->errorCode, +- g_tagExtra, extra); +- return ret; ++ // ret = HiSysEventWrite(HiSysEvent::Domain::HUKS, g_eventName, ++ // outEventType, g_tagFunction, functionName, g_tagUserId, eventValues->userId, g_tagProcessUID, ++ // eventValues->processName, g_tagKeyType, eventValues->keyType, g_tagErrorCode, eventValues->errorCode, ++ // g_tagExtra, extra); ++ // return ret; + } +diff --git a/services/huks_standard/huks_service/main/systemapi_wrap/hitrace_meter_wrapper/BUILD.gn b/services/huks_standard/huks_service/main/systemapi_wrap/hitrace_meter_wrapper/BUILD.gn +index ee9d940..3fc2ef4 100644 +--- a/services/huks_standard/huks_service/main/systemapi_wrap/hitrace_meter_wrapper/BUILD.gn ++++ b/services/huks_standard/huks_service/main/systemapi_wrap/hitrace_meter_wrapper/BUILD.gn +@@ -19,11 +19,11 @@ config("huks_config") { + } + + ohos_static_library("libhuks_utils_hitrace_meter_wrapper_static") { +- sanitize = { +- integer_overflow = true +- cfi = true +- debug = false +- } ++ # sanitize = { ++ # integer_overflow = true ++ # cfi = true ++ # debug = false ++ # } + subsystem_name = "security" + part_name = "huks" + public_configs = [ ":huks_config" ] +@@ -36,6 +36,6 @@ ohos_static_library("libhuks_utils_hitrace_meter_wrapper_static") { + "-Wall", + "-Werror", + ] +- external_deps = [ "hitrace_native:hitrace_meter" ] ++ # external_deps = [ "hitrace_native:hitrace_meter" ] + complete_static_lib = true + } +diff --git a/services/huks_standard/huks_service/main/systemapi_wrap/hitrace_meter_wrapper/src/hitrace_meter_wrapper.cpp b/services/huks_standard/huks_service/main/systemapi_wrap/hitrace_meter_wrapper/src/hitrace_meter_wrapper.cpp +index 89dc408..2872b4c 100644 +--- a/services/huks_standard/huks_service/main/systemapi_wrap/hitrace_meter_wrapper/src/hitrace_meter_wrapper.cpp ++++ b/services/huks_standard/huks_service/main/systemapi_wrap/hitrace_meter_wrapper/src/hitrace_meter_wrapper.cpp +@@ -16,17 +16,19 @@ + #include "hitrace_meter_wrapper.h" + + #include "hks_log.h" +-#include "hitrace_meter.h" ++// #include "hitrace_meter.h" + + #include + + void HksTraceMeterStart(uint64_t label, const char *value, float limit) + { +- const std::string valueString(value); +- StartTrace(label, valueString, limit); ++ return; ++ // const std::string valueString(value); ++ // StartTrace(label, valueString, limit); + } + + void HksTraceMeterFinish(uint64_t label) + { +- FinishTrace(label); ++ return; ++ // FinishTrace(label); + } +\ No newline at end of file +diff --git a/services/huks_standard/huks_service/main/systemapi_wrap/useridm/BUILD.gn b/services/huks_standard/huks_service/main/systemapi_wrap/useridm/BUILD.gn +index c7b42fd..36359b4 100644 +--- a/services/huks_standard/huks_service/main/systemapi_wrap/useridm/BUILD.gn ++++ b/services/huks_standard/huks_service/main/systemapi_wrap/useridm/BUILD.gn +@@ -18,17 +18,17 @@ config("huks_config") { + } + + ohos_static_library("libhuks_service_systemapi_wrap_static") { +- sanitize = { +- integer_overflow = true +- cfi = true +- debug = false +- } ++ # sanitize = { ++ # integer_overflow = true ++ # cfi = true ++ # debug = false ++ # } + subsystem_name = "security" + part_name = "huks" + public_configs = [ ":huks_config" ] + + defines = [ +- "L2_STANDARD", ++ # "L2_STANDARD", + "_HARDWARE_ROOT_KEY_", + "_HUKS_LOG_ENABLE_", + ] +@@ -36,7 +36,7 @@ ohos_static_library("libhuks_service_systemapi_wrap_static") { + deps = [ + "//base/security/huks/frameworks/huks_standard/main/common:libhuks_common_standard_static", + "//base/security/huks/utils/condition:libhuks_utils_condition_static", +- "//base/useriam/user_auth_framework/frameworks/native/client:userauth_client", ++ # "//base/useriam/user_auth_framework/frameworks/native/client:userauth_client", + ] + + external_deps = [ +diff --git a/test/reliability/BUILD.gn b/test/reliability/BUILD.gn +index 5e0c4be..26005ad 100644 +--- a/test/reliability/BUILD.gn ++++ b/test/reliability/BUILD.gn +@@ -29,7 +29,7 @@ ohos_reliabilitytest("huks_stability_test") { + ] + + defines = [ +- "L2_STANDARD", ++ # "L2_STANDARD", + "_HARDWARE_ROOT_KEY_", + "_HUKS_LOG_ENABLE_", + ] +diff --git a/test/unittest/huks_standard_test/module_test/BUILD.gn b/test/unittest/huks_standard_test/module_test/BUILD.gn +index 72a30bb..9bc1a0a 100644 +--- a/test/unittest/huks_standard_test/module_test/BUILD.gn ++++ b/test/unittest/huks_standard_test/module_test/BUILD.gn +@@ -170,7 +170,7 @@ ohos_unittest("huks_module_test") { + ] + + defines = [ +- "L2_STANDARD", ++ # "L2_STANDARD", + "_HUKS_LOG_ENABLE_", + ] + +@@ -197,7 +197,7 @@ ohos_unittest("huks_module_test") { + if (support_jsapi) { + sources += [ "//base/security/huks/test/unittest/huks_standard_test/module_test/service_test/huks_service/os_dependency/sa/src/huks_event_observer_test.cpp" ] + external_deps += [ +- "ability_base:want", ++ # "ability_base:want", + "common_event_service:cesfwk_innerkits", + ] + } +diff --git a/test/unittest/huks_standard_test/module_test/inner_kits_passthrough/BUILD.gn b/test/unittest/huks_standard_test/module_test/inner_kits_passthrough/BUILD.gn +index 0bfdb0d..210dc0e 100644 +--- a/test/unittest/huks_standard_test/module_test/inner_kits_passthrough/BUILD.gn ++++ b/test/unittest/huks_standard_test/module_test/inner_kits_passthrough/BUILD.gn +@@ -124,9 +124,9 @@ config("hilog_dir") { + [ "//base/hiviewdfx/hilog/interfaces/native/innerkits/include" ] + } + ohos_static_library("libhukssdk_static") { +- sanitize = { +- integer_overflow = true +- } ++ # sanitize = { ++ # integer_overflow = true ++ # } + subsystem_name = "security" + part_name = "huks" + public_configs = [ ":public_huks_config" ] +@@ -180,7 +180,7 @@ ohos_static_library("libhukssdk_static") { + if (support_jsapi) { + external_deps += [ "os_account:os_account_innerkits" ] + external_deps += [ +- "ability_base:want", ++ # "ability_base:want", + "common_event_service:cesfwk_innerkits", + "ipc:ipc_core", + ] +diff --git a/test/unittest/huks_standard_test/module_test/mock/BUILD.gn b/test/unittest/huks_standard_test/module_test/mock/BUILD.gn +index 5d80576..c2c2a60 100644 +--- a/test/unittest/huks_standard_test/module_test/mock/BUILD.gn ++++ b/test/unittest/huks_standard_test/module_test/mock/BUILD.gn +@@ -34,7 +34,7 @@ ohos_unittest("huks_mock_test") { + sources += [ "//base/security/huks/test/unittest/huks_standard_test/module_test/mock/ipc/src/huks_access_test.cpp" ] + + defines = [ +- "L2_STANDARD", ++ # "L2_STANDARD", + "_HUKS_LOG_ENABLE_", + ] + configs = [ "//base/security/huks/frameworks/config/build:coverage_flag" ] +diff --git a/test/unittest/huks_standard_test/module_test/service_test/huks_service/os_dependency/idl/ipc/BUILD.gn b/test/unittest/huks_standard_test/module_test/service_test/huks_service/os_dependency/idl/ipc/BUILD.gn +index c670243..6a855a5 100644 +--- a/test/unittest/huks_standard_test/module_test/service_test/huks_service/os_dependency/idl/ipc/BUILD.gn ++++ b/test/unittest/huks_standard_test/module_test/service_test/huks_service/os_dependency/idl/ipc/BUILD.gn +@@ -23,7 +23,7 @@ ohos_unittest("service_ipc_test") { + sources = [ "src/huks_ipc_serialization_test.cpp" ] + + defines = [ +- "L2_STANDARD", ++ # "L2_STANDARD", + "_HUKS_LOG_ENABLE_", + ] + configs = [ "//base/security/huks/frameworks/config/build:coverage_flag" ] +diff --git a/test/unittest/huks_standard_test/module_test/service_test/huks_service/systemapi_wrap/useridm_test/BUILD.gn b/test/unittest/huks_standard_test/module_test/service_test/huks_service/systemapi_wrap/useridm_test/BUILD.gn +index 082e4d0..aaeee54 100644 +--- a/test/unittest/huks_standard_test/module_test/service_test/huks_service/systemapi_wrap/useridm_test/BUILD.gn ++++ b/test/unittest/huks_standard_test/module_test/service_test/huks_service/systemapi_wrap/useridm_test/BUILD.gn +@@ -23,7 +23,7 @@ ohos_unittest("huks_useridm_wrap_test") { + sources = [ "src/hks_useridm_api_wrap_test.cpp" ] + + defines = [ +- "L2_STANDARD", ++ # "L2_STANDARD", + "_HUKS_LOG_ENABLE_", + ] + configs = [ "//base/security/huks/frameworks/config/build:coverage_flag" ] +diff --git a/test/unittest/huks_standard_test/storage_multithread_test/BUILD.gn b/test/unittest/huks_standard_test/storage_multithread_test/BUILD.gn +index c8a9b7a..5ba8f0a 100644 +--- a/test/unittest/huks_standard_test/storage_multithread_test/BUILD.gn ++++ b/test/unittest/huks_standard_test/storage_multithread_test/BUILD.gn +@@ -19,7 +19,7 @@ ohos_unittest("huks_multithread_test") { + module_out_path = module_output_path + + defines = [ +- "L2_STANDARD", ++ # "L2_STANDARD", + "_HARDWARE_ROOT_KEY_", + "_HUKS_LOG_ENABLE_", + ] +diff --git a/test/unittest/huks_standard_test/three_stage_test/BUILD.gn b/test/unittest/huks_standard_test/three_stage_test/BUILD.gn +index 2ef2fa7..0395c1e 100644 +--- a/test/unittest/huks_standard_test/three_stage_test/BUILD.gn ++++ b/test/unittest/huks_standard_test/three_stage_test/BUILD.gn +@@ -79,7 +79,7 @@ ohos_unittest("huks_UT_test") { + ] + + defines = [ +- "L2_STANDARD", ++ # "L2_STANDARD", + "_HUKS_LOG_ENABLE_", + ] + +diff --git a/utils/condition/BUILD.gn b/utils/condition/BUILD.gn +index da41ca0..2c8e879 100644 +--- a/utils/condition/BUILD.gn ++++ b/utils/condition/BUILD.gn +@@ -19,11 +19,11 @@ config("huks_config") { + } + + ohos_static_library("libhuks_utils_condition_static") { +- sanitize = { +- integer_overflow = true +- cfi = true +- debug = false +- } ++ # sanitize = { ++ # integer_overflow = true ++ # cfi = true ++ # debug = false ++ # } + subsystem_name = "security" + part_name = "huks" + public_configs = [ ":huks_config" ] +@@ -33,7 +33,7 @@ ohos_static_library("libhuks_utils_condition_static") { + ] + configs = [ "//base/security/huks/frameworks/config/build:coverage_flag" ] + defines = [ +- "L2_STANDARD", ++ # "L2_STANDARD", + "_HARDWARE_ROOT_KEY_", + "_HUKS_LOG_ENABLE_", + ] +diff --git a/utils/crypto_adapter/BUILD.gn b/utils/crypto_adapter/BUILD.gn +index 381f5b8..8a067f0 100644 +--- a/utils/crypto_adapter/BUILD.gn ++++ b/utils/crypto_adapter/BUILD.gn +@@ -19,17 +19,17 @@ config("huks_config") { + } + + ohos_static_library("libhuks_utils_client_service_adapter_static") { +- sanitize = { +- integer_overflow = true +- cfi = true +- debug = false +- } ++ # sanitize = { ++ # integer_overflow = true ++ # cfi = true ++ # debug = false ++ # } + subsystem_name = "security" + part_name = "huks" + public_configs = [ ":huks_config" ] + include_dirs = [ "//third_party/openssl/include/" ] + defines = [ +- "L2_STANDARD", ++ # "L2_STANDARD", + "_HARDWARE_ROOT_KEY_", + "_HUKS_LOG_ENABLE_", + ] +diff --git a/utils/file_operator/BUILD.gn b/utils/file_operator/BUILD.gn +index 5864fdf..8666d7f 100644 +--- a/utils/file_operator/BUILD.gn ++++ b/utils/file_operator/BUILD.gn +@@ -19,11 +19,11 @@ config("huks_config") { + } + + ohos_static_library("libhuks_utils_file_operator_static") { +- sanitize = { +- integer_overflow = true +- cfi = true +- debug = false +- } ++ # sanitize = { ++ # integer_overflow = true ++ # cfi = true ++ # debug = false ++ # } + subsystem_name = "security" + part_name = "huks" + public_configs = [ ":huks_config" ] +@@ -33,7 +33,7 @@ ohos_static_library("libhuks_utils_file_operator_static") { + ] + configs = [ "//base/security/huks/frameworks/config/build:coverage_flag" ] + defines = [ +- "L2_STANDARD", ++ # "L2_STANDARD", + "_HARDWARE_ROOT_KEY_", + "_HUKS_LOG_ENABLE_", + ] +diff --git a/utils/list/BUILD.gn b/utils/list/BUILD.gn +index ba8d149..95c65d5 100644 +--- a/utils/list/BUILD.gn ++++ b/utils/list/BUILD.gn +@@ -19,11 +19,11 @@ config("huks_config") { + } + + ohos_static_library("libhuks_utils_list_static") { +- sanitize = { +- integer_overflow = true +- cfi = true +- debug = false +- } ++ # sanitize = { ++ # integer_overflow = true ++ # cfi = true ++ # debug = false ++ # } + subsystem_name = "security" + part_name = "huks" + public_configs = [ ":huks_config" ] +diff --git a/utils/mutex/BUILD.gn b/utils/mutex/BUILD.gn +index f4db213..94b5a90 100644 +--- a/utils/mutex/BUILD.gn ++++ b/utils/mutex/BUILD.gn +@@ -19,11 +19,11 @@ config("huks_config") { + } + + ohos_static_library("libhuks_utils_mutex_static") { +- sanitize = { +- integer_overflow = true +- cfi = true +- debug = false +- } ++ # sanitize = { ++ # integer_overflow = true ++ # cfi = true ++ # debug = false ++ # } + subsystem_name = "security" + part_name = "huks" + public_configs = [ ":huks_config" ] +@@ -33,7 +33,7 @@ ohos_static_library("libhuks_utils_mutex_static") { + "//base/security/huks/interfaces/innerkits/huks_standard/main/include", + ] + defines = [ +- "L2_STANDARD", ++ # "L2_STANDARD", + "_HARDWARE_ROOT_KEY_", + "_HUKS_LOG_ENABLE_", + ] +-- +2.33.0 + diff --git a/0002-feat-for-embedded-fix-huks-compile-errors.patch b/0002-feat-for-embedded-fix-huks-compile-errors.patch new file mode 100644 index 0000000000000000000000000000000000000000..98ffd7ec6b74b0b3a2c205fa5985827115446cd5 --- /dev/null +++ b/0002-feat-for-embedded-fix-huks-compile-errors.patch @@ -0,0 +1,111 @@ +From b8a21d565f44303187ade8245e637c261906451f Mon Sep 17 00:00:00 2001 +From: s_c_c +Date: Tue, 2 Apr 2024 16:59:34 +0800 +Subject: [PATCH] feat for embedded fix huks compile errors + +--- + frameworks/huks_standard/main/core/src/hks_verifier.c | 1 + + .../main/crypto_engine/openssl/src/hks_openssl_sm2.c | 4 ++-- + .../huks_service/main/os_dependency/idl/BUILD.gn | 1 + + utils/crypto_adapter/hks_client_service_adapter.c | 8 ++++---- + utils/file_operator/BUILD.gn | 1 + + 5 files changed, 9 insertions(+), 6 deletions(-) + +diff --git a/frameworks/huks_standard/main/core/src/hks_verifier.c b/frameworks/huks_standard/main/core/src/hks_verifier.c +index c9bf5ae..5e3d1a4 100644 +--- a/frameworks/huks_standard/main/core/src/hks_verifier.c ++++ b/frameworks/huks_standard/main/core/src/hks_verifier.c +@@ -253,6 +253,7 @@ static int32_t EncodeTlvAndGetLength(uint8_t **buf, uint32_t *outLength, uint32_ + + uint32_t tmp; + HKS_ASN1_DECODE_BYTE(*buf, tmp); /* get type */ ++ (void)tmp; + if ((*buf)[0] < ASN_1_MIN_VAL_1_EXTRA_LEN_BYTE) { + /* Current byte tells the length */ + HKS_ASN1_DECODE_BYTE(*buf, length); +diff --git a/frameworks/huks_standard/main/crypto_engine/openssl/src/hks_openssl_sm2.c b/frameworks/huks_standard/main/crypto_engine/openssl/src/hks_openssl_sm2.c +index 0dbe0d5..3451d17 100644 +--- a/frameworks/huks_standard/main/crypto_engine/openssl/src/hks_openssl_sm2.c ++++ b/frameworks/huks_standard/main/crypto_engine/openssl/src/hks_openssl_sm2.c +@@ -163,12 +163,12 @@ static EVP_PKEY_CTX *InitSm2Ctx(const struct HksBlob *mainKey, uint32_t digest, + HKS_LOG_E("assign ec key failed"); + break; + } +- ++#if OPENSSL_VERSION_MAJOR < 3 + if (EVP_PKEY_set_alias_type(key, EVP_PKEY_SM2) != HKS_OPENSSL_SUCCESS) { + HKS_LOG_E("set alias type failed"); + break; + } +- ++#endif + ctx = EVP_PKEY_CTX_new(key, NULL); + HKS_IF_NULL_LOGE_BREAK(ctx, "new ctx failed") + +diff --git a/services/huks_standard/huks_service/main/os_dependency/idl/BUILD.gn b/services/huks_standard/huks_service/main/os_dependency/idl/BUILD.gn +index c1f2e20..c7f2283 100644 +--- a/services/huks_standard/huks_service/main/os_dependency/idl/BUILD.gn ++++ b/services/huks_standard/huks_service/main/os_dependency/idl/BUILD.gn +@@ -60,6 +60,7 @@ ohos_static_library("libhuks_service_idl_standard_static") { + "-DHILOG_ENABLE", + "-Wall", + "-Werror", ++ "-Wno-attributes", + ] + cflags = cflags_cc + complete_static_lib = true +diff --git a/utils/crypto_adapter/hks_client_service_adapter.c b/utils/crypto_adapter/hks_client_service_adapter.c +index ae9f94d..ee2c303 100644 +--- a/utils/crypto_adapter/hks_client_service_adapter.c ++++ b/utils/crypto_adapter/hks_client_service_adapter.c +@@ -428,7 +428,7 @@ int32_t TranslateToX509PublicKey(const struct HksBlob *publicKey, struct HksBlob + #ifdef HKS_SUPPORT_RSA_C + static int32_t X509PublicKeyToRsa(EVP_PKEY *pkey, struct HksBlob *rsaPublicKey) + { +- RSA *rsa = EVP_PKEY_get0_RSA(pkey); ++ RSA *rsa = (RSA *)EVP_PKEY_get0_RSA(pkey); + HKS_IF_NULL_LOGE_RETURN(rsa, HKS_ERROR_NULL_POINTER, + "EVP_PKEY_get1_RSA error %" LOG_PUBLIC "s", ERR_reason_error_string(ERR_get_error())) + +@@ -521,7 +521,7 @@ static int32_t EcKeyToPublicKey(const uint32_t alg, EC_KEY *ecKey, struct HksBlo + + static int32_t X509PublicKeyToEcc(const uint32_t alg, EVP_PKEY *pkey, struct HksBlob *eccPublicKey) + { +- EC_KEY *ecKey = EVP_PKEY_get0_EC_KEY(pkey); ++ EC_KEY *ecKey = (EC_KEY *)EVP_PKEY_get0_EC_KEY(pkey); + HKS_IF_NULL_LOGE_RETURN(ecKey, HKS_ERROR_NULL_POINTER, + "EVP_PKEY_get1_EC_KEY error %" LOG_PUBLIC "s", ERR_reason_error_string(ERR_get_error())) + +@@ -547,7 +547,7 @@ static int32_t GetDsaKeyInfo(const DSA *dsa, const BIGNUM **info, uint32_t *info + + static int32_t X509PublicKeyToDsa(EVP_PKEY *pkey, struct HksBlob *dsaPublicKey) + { +- DSA *dsa = EVP_PKEY_get0_DSA(pkey); ++ DSA *dsa = (DSA *)EVP_PKEY_get0_DSA(pkey); + HKS_IF_NULL_LOGE_RETURN(dsa, HKS_ERROR_NULL_POINTER, + "EVP_PKEY_get1_DSA error %" LOG_PUBLIC "s", ERR_reason_error_string(ERR_get_error())) + +@@ -604,7 +604,7 @@ static int32_t X509PublicKeyToDsa(EVP_PKEY *pkey, struct HksBlob *dsaPublicKey) + #ifdef HKS_SUPPORT_DH_C + static int32_t X509PublicKeyToDh(EVP_PKEY *pkey, struct HksBlob *dhPublicKey) + { +- DH *dh = EVP_PKEY_get0_DH(pkey); ++ DH *dh = (DH *)EVP_PKEY_get0_DH(pkey); + HKS_IF_NULL_LOGE_RETURN(dh, HKS_ERROR_NULL_POINTER, + "EVP_PKEY_get0_DH error %" LOG_PUBLIC "s", ERR_reason_error_string(ERR_get_error())) + +diff --git a/utils/file_operator/BUILD.gn b/utils/file_operator/BUILD.gn +index 8666d7f..841e3e1 100644 +--- a/utils/file_operator/BUILD.gn ++++ b/utils/file_operator/BUILD.gn +@@ -41,6 +41,7 @@ ohos_static_library("libhuks_utils_file_operator_static") { + cflags = [ + "-Wall", + "-Werror", ++ "-Wno-unused-result", + ] + deps = [ "//base/security/huks/frameworks/huks_standard/main/os_dependency:libhuks_os_dependency_standard_static" ] + external_deps = [ +-- +2.20.1 (Apple Git-117) + diff --git a/huks.BUILD.gn b/huks.BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..7ea873f1e0be28f5fc741e8debd67402edd00f1c --- /dev/null +++ b/huks.BUILD.gn @@ -0,0 +1,32 @@ +# Copyright (C) 2021-2022 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. + +import("//build/ohos.gni") +import("//build/config/sysroot.gni") + +config("huks_config") { + include_dirs = [ "${sysroot}/usr/include/huks" ] + libs = ["hukssdk.z"] +} + +if (os_level == "standard") { + group("libhukssdk") { + public_configs = [ ":huks_config" ] + } +} + +if (os_level == "small" || os_level == "mini") { + group("libhukssdk") { + } +} + diff --git a/huks.bundle.json b/huks.bundle.json new file mode 100644 index 0000000000000000000000000000000000000000..1f4151033bf10cedac1a56649051a61dda1cb734 --- /dev/null +++ b/huks.bundle.json @@ -0,0 +1,78 @@ +{ + "name": "@ohos/huks", + "description": "The provider of key and certificate manangement capbility, which belongs to security subsystem", + "version": "3.1", + "license": "Apache License 2.0", + "publishAs": "code-segment", + "segment": { + "destPath": "base/security/huks" + }, + "dirs":{}, + "scripts": { + "install": "DEST_PATH=${DEP_BUNDLE_BASE}/base/security/huks && mkdir -p $DEST_PATH && cp -r ./* $DEST_PATH" + }, + "author": {}, + "repository": "", + "component": { + "name": "huks", + "subsystem": "security", + "syscap": [ + "SystemCapability.Security.Huks", + "SystemCapability.Security.Cipher" + ], + "features": [], + "adapted_system_type": [ + "standard", + "small", + "mini" + ], + "hisysevent_config": [ + "//base/security/huks/hisysevent.yaml" + ], + "rom": "5000KB", + "ram": "500kB", + "deps": { + "components": [ + "ability_base", + "access_token", + "bundle_framework", + "common", + "common_event_service", + "hisysevent_native", + "hitrace_native", + "hiviewdfx_hilog_native", + "ipc", + "napi", + "os_account", + "safwk", + "samgr", + "thirdparty_bounds_checking_function", + "c_utils" + ], + "third_party": [ + "openssl", + "bounds_checking_function" + ] + }, + "build": { + "group_type": { + }, + "inner_kits": [ + { + "name": "//base/security/huks/interfaces/innerkits/huks_standard/main:libhukssdk", + "header": { + "header_files": [ + "hks_api.h" + ], + "header_base": "//base/security/huks/interfaces/innerkits/huks_standard/main/include" + } + } + ], + "test": [ + "//base/security/huks:huks_sdk_test", + "//base/security/huks/test/fuzz_test:fuzztest" + ] + } + } +} + diff --git a/huks_service.xml b/huks_service.xml new file mode 100755 index 0000000000000000000000000000000000000000..d6321a77d9df778d2302e8e9c7d30329b2414f4c --- /dev/null +++ b/huks_service.xml @@ -0,0 +1,14 @@ + + + huks_service + + libhuks_service.z.so + + + 3510 + libhuks_service.z.so + true + false + 1 + + diff --git a/mbedtls.BUILD.gn b/mbedtls.BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..807966f4e7214317bda60090740562a08e963783 --- /dev/null +++ b/mbedtls.BUILD.gn @@ -0,0 +1,18 @@ +import("//build/ohos.gni") +config("mbedtls_config") { + include_dirs = [ + "include", + ] + libs = [ + "mbedtls.z", + ] +} + +ohos_shared_library("mbedtls_shared") { + public_configs = [ ":mbedtls_config" ] +} + +group("mbedtls") { + public_deps = [ ":mbedtls_shared" ] +} + diff --git a/security_huks-OpenHarmony-v3.2-Release.tar.gz b/security_huks-OpenHarmony-v3.2-Release.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..b1b9424738d2ea1beca524c9e819f25d322c78d4 Binary files /dev/null and b/security_huks-OpenHarmony-v3.2-Release.tar.gz differ diff --git a/security_huks.spec b/security_huks.spec new file mode 100644 index 0000000000000000000000000000000000000000..1f7046231c33fc08c07f7ff65250ab5c8953b98a --- /dev/null +++ b/security_huks.spec @@ -0,0 +1,131 @@ +%define debug_package %{nil} +%global build_opt /opt/distributed-middleware-build +%global oh_version OpenHarmony-v3.2-Release +%global security_path %{_builddir}/base/security +%global third_party_path %{_builddir}/third_party + +Name: security_huks +Version: 1.0.0 +Release: 6%{?dist} +Summary: Key management service +License: Apache-2.0 +URL: https://gitee.com/openharmony/security_huks +Source1: https://gitee.com/openharmony/security_huks/repository/archive/OpenHarmony-v3.2-Release.tar.gz #/security_huks-OpenHarmony-v3.2-Release.tar.gz +Source2: huks.BUILD.gn +Source3: huks.bundle.json +Source4: huks_service.xml + +Patch1: 0001-adapt-compilation-tailor-dependencies.patch +Patch2: 0002-feat-for-embedded-fix-huks-compile-errors.patch + +BuildRequires: gcc, make, hilog +BuildRequires: distributed-build, distributed-beget +BuildRequires: commonlibrary_c_utils +BuildRequires: notification_eventhandler +BuildRequires: communication_ipc +BuildRequires: systemabilitymgr_safwk, systemabilitymgr_samgr +BuildRequires: compat-openssl11-devel + +Requires: distributed-beget +Requires: commonlibrary_c_utils +Requires: notification_eventhandler +Requires: communication_ipc +Requires: systemabilitymgr_safwk, systemabilitymgr_samgr + +%description +OpenHarmony Universal KeyStore (HUKS) provides applications with key library capabilities, such as key management and cryptographic operations on keys. HUKS also provides APIs for applications to import or generate keys. + +# Decompress source code package, make patches to the source code. +%prep +rm -rf %{_builddir}/* + +cp -rf %{build_opt} %{_builddir}/build +[ ! -L "%{_builddir}/build.sh" ] && ln -s %{_builddir}/build/build_scripts/build.sh %{_builddir}/build.sh +[ ! -L "%{_builddir}/.gn" ] && ln -s %{_builddir}/build/core/gn/dotfile.gn %{_builddir}/.gn +[ ! -L "%{_builddir}/build.py" ] && ln -s %{_builddir}/build/lite/build.py %{_builddir}/build.py +cp -rf %{_builddir}/build/openeuler/vendor %{_builddir}/ +cp -rf %{_builddir}/build/openeuler/compiler_gn/* %{_builddir} + +%setup -q -D -T -a 1 -c -n %{security_path} +mv %{security_path}/%{name}-%{oh_version} %{security_path}/huks +%patch -P1 -p1 -d %{security_path}/huks +%patch -P2 -p1 -d %{security_path}/huks + +%build + + +%ifarch x86_64 +%{_builddir}/build.sh --product-name openeuler --target-cpu x86_64 +%endif + +%ifarch aarch64 +%{_builddir}/build.sh --product-name openeuler --target-cpu arm64 +%endif + +%install +install -d -m 0755 %{buildroot}/%{_includedir}/huks +install -d -m 0755 %{buildroot}/%{_libdir} +install -d -m 0755 %{buildroot}/system/lib64 +install -d -m 0755 %{buildroot}/system/profile +install -d -m 0755 %{buildroot}%{build_opt}/openeuler/compiler_gn/base/security/huks/interfaces/innerkits/huks_standard/main/ + +%ifarch aarch64 +%define module_out_path out/openeuler/linux_clang_arm64/security/huks +%define header_out_path out/openeuler/innerkits/linux-arm64/huks +%endif + +%ifarch x86_64 +%define module_out_path out/openeuler/linux_clang_x86_64/security/huks +%define header_out_path out/openeuler/innerkits/linux-x86_64/huks +%endif +# prepare head files +find %{_builddir}/%{header_out_path} -name *.h -print0 | xargs -0 -i cp -rf {} %{buildroot}%{_includedir}/huks/ +install -m 0755 %{_builddir}/base/security/huks/frameworks/huks_standard/main/common/include/*.h %{buildroot}%{_includedir}/huks/ + +# copy executable file. +install -m 0755 %{_builddir}/%{module_out_path}/*.so %{buildroot}%{_libdir} +install -m 0755 %{_builddir}/%{module_out_path}/*.so %{buildroot}/system/lib64 + +#cp json file +install -m 0755 %{SOURCE3} %{buildroot}%{build_opt}/openeuler/compiler_gn/base/security/huks/bundle.json + +#cp gn file +install -m 0755 %{SOURCE2} %{buildroot}%{build_opt}/openeuler/compiler_gn/base/security/huks/interfaces/innerkits/huks_standard/main/BUILD.gn + +# cp profile file +install -m 0755 %{SOURCE4} %{buildroot}/system/profile + +#cp yaml file +install -m 0755 %{_builddir}/base/security/huks/hisysevent.yaml %{buildroot}%{build_opt}/openeuler/compiler_gn/base/security/huks + +#create soft link +ln -s /usr/include/huks %{buildroot}%{build_opt}/openeuler/compiler_gn/base/security/huks/include + +# copy ko file to the certain path on deployment environment. +%files +%{_libdir}/*.so +%{_includedir}/huks/* +# %{bundle_dir}/* +/system/* +%{build_opt}/* + +%changelog +* Wed Apr 3 2024 s_c_c - 1.0.0-6 +- Fix huks sysroot patch for embedded + +* Tue Apr 2 2024 s_c_c - 1.0.0-5 +- Fix header_out_path variable error + +* Tue Apr 2 2024 s_c_c - 1.0.0-4 +- Fix huks compile errors for embedded + +* Fri Dec 15 2023 Peng He - 1.0.0-3 +- add sa profile file + +* Mon Oct 30 2023 Yuying Mu - 1.0.0-2 +- add gn file + +* Sat Oct 07 2023 Peng He - 1.0.0-1 +* Tue Nov 21 2023 JiaQi Zhao - 1.0.0-1 +- adapt compilation, tailor dependencies on hitrace and hisysevent +