1# Copyright (c) 2025 Huawei Device Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14import("//base/security/device_auth/deps_adapter/deviceauth_hals.gni") 15import("//base/security/device_auth/services/deviceauth.gni") 16import("../../unittest/tdd_framework/tdd_framework.gni") 17 18#####################hydra-fuzz################### 19import("//build/config/features.gni") 20import("//build/ohos.gni") 21import("//build/test.gni") 22module_output_path = "device_auth/device_auth" 23 24##############################fuzztest########################################## 25ohos_fuzztest("IdentityServiceFuzzTest") { 26 module_out_path = module_output_path 27 fuzz_config_file = "${deviceauth_path}/test/fuzztest/identityservice_fuzzer" 28 29 include_dirs = inc_path 30 include_dirs += hals_inc_path 31 32 include_dirs += [ 33 ".", 34 "./include", 35 "./unit_test/include", 36 "../../unittest/deviceauth/include", 37 "${tdd_framework_path}/common/inc", 38 "${dev_frameworks_path}/inc/permission_adapter", 39 "${dev_frameworks_path}/inc/hiview_adapter", 40 ] 41 42 sources = hal_common_files 43 sources += [ 44 "${key_management_adapter_path}/impl/src/common/mbedtls_ec_adapter.c", 45 "${key_management_adapter_path}/impl/src/huks_adapter.c", 46 "${key_management_adapter_path}/impl/src/huks_adapter_utils.c", 47 "${key_management_adapter_path}/impl/src/standard/crypto_hash_to_point.c", 48 "${key_management_adapter_path}/impl/src/standard/huks_adapter_diff_impl.c", 49 "${os_adapter_path}/impl/src/hc_log.c", 50 "${os_adapter_path}/impl/src/linux/hc_condition.c", 51 "${os_adapter_path}/impl/src/linux/hc_file.c", 52 "${os_adapter_path}/impl/src/linux/hc_init_protection.c", 53 "${os_adapter_path}/impl/src/linux/hc_thread.c", 54 "${os_adapter_path}/impl/src/linux/hc_types.c", 55 "../../unittest/deviceauth/source/hc_dev_info_mock.c", 56 ] 57 58 sources += dev_frameworks_files 59 sources += deviceauth_common_files 60 sources += group_database_manager_files 61 sources += ext_plugin_manager_files 62 sources += session_manager_files 63 sources += identity_service_files 64 sources += session_v1_files 65 sources += session_v2_files 66 sources += session_mini_files 67 sources += iso_protocol_files 68 sources += ec_speke_protocol_files 69 sources += auth_code_import_files 70 sources += pub_key_exchange_files 71 sources += save_trusted_info_files 72 sources += creds_manager_files 73 sources += broadcast_manager_files 74 sources += soft_bus_channel_mock_files 75 sources += permission_adapter_files 76 sources += sa_load_on_demand_mock_files 77 78 sources += group_auth_files 79 sources += group_auth_account_unrelated_files 80 81 sources += group_manager_files 82 sources += group_manager_peer_to_peer_files 83 84 sources += authenticators_p2p_files 85 sources += authenticators_p2p_iso_files 86 sources += authenticators_p2p_pake_files 87 sources += authenticators_standard_exchange_task_files 88 89 sources += account_related_files 90 91 sources += privacy_enhancement_files 92 sources += mk_agree_files 93 94 sources += security_label_adapter_files 95 96 sources += hiview_adapter_files 97 98 sources -= [ 99 "${authenticators_path}/src/account_unrelated/iso_task/iso_task_main.c", 100 "${authenticators_path}/src/account_unrelated/pake_task/pake_v1_task/pake_v1_task_main.c", 101 "${identity_service_path}/src/identity_service.c", 102 "${identity_service_path}/src/identity_operation.c", 103 "${identity_service_path}/src/identity_service_impl.c", 104 "${cred_data_manager_path}/src/credential_data_manager.c", 105 ] 106 107 sources += [ 108 "${dev_frameworks_path}/src/account_task_manager_mock/account_task_manager_mock.c", 109 "${dev_frameworks_path}/src/plugin_adapter_mock/account_auth_plugin_proxy_mock.c", 110 "../../unittest/deviceauth/source/device_auth_ext_mock.c", 111 "../../unittest/deviceauth/source/os_account_adapter_mock.c", 112 "../../unittest/deviceauth/source/protocol_task_main_mock.c", 113 ] 114 sources += [ "identityservice_fuzzer.cpp" ] 115 116 defines = [ 117 "P2P_PAKE_DL_PRIME_LEN_384", 118 "P2P_PAKE_EC_TYPE", 119 "ENABLE_EC_SPEKE", 120 "ENABLE_ISO", 121 "ENABLE_AUTH_CODE_IMPORT", 122 "ENABLE_PUB_KEY_EXCHANGE", 123 "ENABLE_SAVE_TRUSTED_INFO", 124 "ENABLE_ACCOUNT_AUTH_ISO", 125 "ENABLE_ACCOUNT_AUTH_EC_SPEKE", 126 "ENABLE_P2P_BIND_ISO", 127 "ENABLE_P2P_BIND_EC_SPEKE", 128 "ENABLE_P2P_AUTH_ISO", 129 "ENABLE_P2P_AUTH_EC_SPEKE", 130 "DEV_AUTH_FUNC_TEST", 131 "ENABLE_PSEUDONYM", 132 "DEV_AUTH_HIVIEW_ENABLE", 133 "DEV_AUTH_IS_ENABLE", 134 ] 135 136 sources += identity_manager_files 137 include_dirs += identity_manager_inc 138 139 cflags = [ "-DHILOG_ENABLE" ] 140 cflags += [ 141 "-DDEV_AUTH_WORK_THREAD_STACK_SIZE=${device_auth_hichain_thread_stack_size}", 142 "-DMAX_AUTH_SESSION_COUNT=${max_auth_session_count}", 143 ] 144 145 deps = [] 146 147 external_deps = [ 148 "access_token:libaccesstoken_sdk", 149 "cJSON:cjson", 150 "c_utils:utils", 151 "hilog:libhilog", 152 "hisysevent:libhisysevent", 153 "hitrace:hitrace_meter", 154 "huks:libhukssdk", 155 "ipc:ipc_single", 156 "mbedtls:mbedtls_shared", 157 "openssl:libcrypto_static", 158 ] 159} 160 161############################################################################### 162group("fuzztest") { 163 testonly = true 164 deps = [] 165 deps += [ 166 # deps file 167 ":IdentityServiceFuzzTest", 168 ] 169} 170############################################################################### 171