# Copyright (C) 2021-2024 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("//base/security/huks/build/config.gni") import("//base/security/huks/huks.gni") import("//build/ohos.gni") if (os_level == "standard") { config("huks_config") { include_dirs = [ "include", "../crypto_common/include", ] if (huks_use_rkc_in_standard) { include_dirs += [ "//base/security/huks/frameworks/huks_standard/main/crypto_engine/rkc/include" ] } defines = [ "OPENSSL_SUPPRESS_DEPRECATED" ] } ohos_static_library("libhuks_openssl_standard_static") { subsystem_name = "security" part_name = "huks" public_configs = [ ":huks_config" ] sources = [ "src/hks_openssl_ability.c", "src/hks_openssl_aes.c", "src/hks_openssl_bn.c", "src/hks_openssl_common.c", "src/hks_openssl_curve25519.c", "src/hks_openssl_dh.c", "src/hks_openssl_dsa.c", "src/hks_openssl_ecc.c", "src/hks_openssl_ed25519tox25519.c", "src/hks_openssl_engine.c", "src/hks_openssl_hash.c", "src/hks_openssl_hmac.c", "src/hks_openssl_kdf.c", "src/hks_openssl_rsa.c", "src/hks_openssl_sm2.c", "src/hks_openssl_sm3.c", "src/hks_openssl_sm4.c", ] deps = [] defines = [] include_dirs = [] if (huks_use_rkc_in_standard) { defines += [ "HKS_USE_RKC_IN_STANDARD" ] include_dirs += [ "//base/security/huks/services/huks_standard/huks_service/main/core/include", "//base/security/huks/services/huks_standard/huks_service/main/hks_storage/include", ] sources += [ "../rkc/src/hks_rkc.c", "../rkc/src/hks_rkc_rw.c", "//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_lock.c", "//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage.c", "//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage_file_lock.c", "//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage_manager.c", "//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage_utils.c", "//base/security/huks/services/huks_standard/huks_service/main/os_dependency/posix/hks_rwlock.c", ] # when uks_use_rkc_in_standard and HKS_ENABLE_CLEAN_FILE are enabled at the same time, add the dependency of HDI to the engine if (huks_enable_hdi_in_standard) { sources += [ "//base/security/huks/services/huks_standard/huks_service/main/os_dependency/idl/passthrough/huks_hdi_access.c" ] external_deps += [ "drivers_interface_huks:libhuks_proxy_1.0" ] } else { sources += [ "//base/security/huks/services/huks_standard/huks_service/main/os_dependency/idl/passthrough/huks_access.c", "//base/security/huks/services/huks_standard/huks_service/main/os_dependency/idl/passthrough/huks_core_dynamic_hal.c", ] } deps += [ "//base/security/huks/frameworks/huks_standard/main/os_dependency:libhuks_os_dependency_standard_static", "//base/security/huks/utils/file_operator:libhuks_utils_file_operator_static", "//base/security/huks/utils/mutex:libhuks_utils_mutex_static", ] if (huks_enable_upgrade_rkc_v1tov2) { defines += [ "HKS_ENABLE_UPGRADE_RKC_DERIVE_ALG" ] sources += [ "../rkc/src/hks_rkc_v1.c" ] } } deps += [ "//base/security/huks/frameworks/huks_standard/main/common:libhuks_common_standard_static" ] complete_static_lib = true branch_protector_ret = "pac_ret" sanitize = { integer_overflow = true cfi = true debug = false cfi_cross_dso = true boundary_sanitize = true ubsan = true } external_deps = [ "c_utils:utils", "hilog:libhilog", ] if (huks_dependency_openssl_path != "") { deps += [ huks_dependency_openssl_path ] } else { external_deps += [ "openssl:libcrypto_shared" ] } configs = [ "//base/security/huks/frameworks/config/build:l2_standard_common_config", ] } } else { ohos_static_library("libhuks_openssl_small_static") { include_dirs = [ "../crypto_common/include" ] sources = [ "src/hks_openssl_ability.c", "src/hks_openssl_aes.c", "src/hks_openssl_bn.c", "src/hks_openssl_common.c", "src/hks_openssl_curve25519.c", "src/hks_openssl_dh.c", "src/hks_openssl_dsa.c", "src/hks_openssl_ecc.c", "src/hks_openssl_ed25519tox25519.c", "src/hks_openssl_engine.c", "src/hks_openssl_hash.c", "src/hks_openssl_hmac.c", "src/hks_openssl_kdf.c", "src/hks_openssl_rsa.c", "src/hks_openssl_sm2.c", "src/hks_openssl_sm3.c", "src/hks_openssl_sm4.c", ] deps = [ "//base/security/huks/frameworks/huks_standard/main/common:libhuks_common_small_static" ] complete_static_lib = true external_deps = [ "hilog_lite:hilog_shared" ] if (huks_dependency_openssl_path != "") { deps += [ huks_dependency_openssl_path ] } else { deps += [ "//build/lite/config/component/openssl:openssl_shared" ] } configs = [ "//base/security/huks/frameworks/config/build:l1_small_common_config", ] } }