# 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("//build/ohos.gni") if (os_level == "standard") { config("huks_config") { include_dirs = [ "include", "../crypto_common/include", "//base/security/huks/frameworks/huks_standard/main/crypto_engine/rkc/include", ] } ohos_static_library("libhuks_mbedtls_standard_static") { subsystem_name = "security" part_name = "huks" public_configs = [ ":huks_config" ] sources = [ "src/hks_crypto_ed25519.c", "src/hks_mbedtls_ability.c", "src/hks_mbedtls_aes.c", "src/hks_mbedtls_bn.c", "src/hks_mbedtls_common.c", "src/hks_mbedtls_dh.c", "src/hks_mbedtls_dsa.c", "src/hks_mbedtls_ecc.c", "src/hks_mbedtls_ecdh.c", "src/hks_mbedtls_ecdsa.c", "src/hks_mbedtls_engine.c", "src/hks_mbedtls_hash.c", "src/hks_mbedtls_hmac.c", "src/hks_mbedtls_kdf.c", "src/hks_mbedtls_rsa.c", "src/hks_mbedtls_x25519.c", ] deps = [ "//base/security/huks/frameworks/huks_standard/main/common:libhuks_common_standard_static" ] if (huks_dependency_mbedtls_path != "") { deps += [ huks_dependency_mbedtls_path ] } else { deps += [ "//third_party/mbedtls" ] } if (huks_dependency_openssl_path != "") { deps += [ huks_dependency_openssl_path ] } else { deps += [ "//third_party/openssl:libcrypto_shared" ] } 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 } configs = [ "//base/security/huks/frameworks/config/build:l2_standard_common_config", ] external_deps = [ "hilog:libhilog" ] } } else { config("huks_config") { include_dirs = [ "include", "//base/security/huks/services/huks_standard/huks_service/main/core/include", "//base/security/huks/services/huks_standard/huks_service/main/hks_storage/include", "//base/security/huks/frameworks/huks_standard/main/crypto_engine/rkc/include", ] } ohos_static_library("libhuks_mbedtls_small_static") { public_configs = [ ":huks_config" ] include_dirs = [ "//base/security/huks/frameworks/huks_standard/main/crypto_engine/rkc/include", "../crypto_common/include", ] defines = [] sources = [ "../rkc/src/hks_rkc.c", "../rkc/src/hks_rkc_rw.c", "src/hks_crypto_ed25519.c", "src/hks_mbedtls_ability.c", "src/hks_mbedtls_aes.c", "src/hks_mbedtls_bn.c", "src/hks_mbedtls_common.c", "src/hks_mbedtls_dh.c", "src/hks_mbedtls_dsa.c", "src/hks_mbedtls_ecc.c", "src/hks_mbedtls_ecdh.c", "src/hks_mbedtls_ecdsa.c", "src/hks_mbedtls_engine.c", "src/hks_mbedtls_hash.c", "src/hks_mbedtls_hmac.c", "src/hks_mbedtls_kdf.c", "src/hks_mbedtls_rsa.c", "src/hks_mbedtls_x25519.c", ] sources += [ "//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_manager.c", "//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage_utils.c", ] if (huks_enable_upgrade_rkc_v1tov2) { # enable upgrade rkc derivation algorithm from PBKDF2 to HKDF defines += [ "HKS_ENABLE_UPGRADE_RKC_DERIVE_ALG" ] # compile code of old version sources += [ "../rkc/src/hks_rkc_v1.c" ] } deps = [ "//base/security/huks/frameworks/huks_standard/main/common:libhuks_common_small_static" ] if (huks_dependency_mbedtls_path != "") { deps += [ huks_dependency_mbedtls_path ] } else { deps += [ "//third_party/mbedtls:mbedtls_shared" ] } if (huks_dependency_openssl_path != "") { deps += [ huks_dependency_openssl_path ] } else { if (ohos_kernel_type == "liteos_a" && ohos_kernel_type != "linux") { deps += [ "//third_party/openssl/ohos_lite:openssl_shared" ] } else { deps += [ "//third_party/openssl:libcrypto_shared" ] } } complete_static_lib = true deps += [ "//base/security/huks/frameworks/huks_standard/main/os_dependency:libhuks_os_dependency_small_static", "//base/security/huks/utils/file_operator:libhuks_utils_file_operator_static", ] configs = [ "//base/security/huks/frameworks/config/build:l1_small_common_config", ] external_deps = [ "hilog_lite:hilog_shared" ] } }