117fd14ceSopenharmony_ci# Copyright (c) 2024 Huawei Device Co., Ltd.
217fd14ceSopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
317fd14ceSopenharmony_ci# you may not use this file except in compliance with the License.
417fd14ceSopenharmony_ci# You may obtain a copy of the License at
517fd14ceSopenharmony_ci#
617fd14ceSopenharmony_ci#     http://www.apache.org/licenses/LICENSE-2.0
717fd14ceSopenharmony_ci#
817fd14ceSopenharmony_ci# Unless required by applicable law or agreed to in writing, software
917fd14ceSopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
1017fd14ceSopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1117fd14ceSopenharmony_ci# See the License for the specific language governing permissions and
1217fd14ceSopenharmony_ci# limitations under the License.
1317fd14ceSopenharmony_ci
1417fd14ceSopenharmony_ciimport("//base/security/device_auth/deps_adapter/deviceauth_hals.gni")
1517fd14ceSopenharmony_ciimport("//base/security/device_auth/services/deviceauth.gni")
1617fd14ceSopenharmony_ci
1717fd14ceSopenharmony_ci#####################hydra-fuzz###################
1817fd14ceSopenharmony_ciimport("//build/config/features.gni")
1917fd14ceSopenharmony_ciimport("//build/ohos.gni")
2017fd14ceSopenharmony_ciimport("//build/test.gni")
2117fd14ceSopenharmony_cimodule_output_path = "device_auth/device_auth"
2217fd14ceSopenharmony_ci
2317fd14ceSopenharmony_ci##############################fuzztest##########################################
2417fd14ceSopenharmony_ciohos_fuzztest("DevAuthFuncFuzzTest") {
2517fd14ceSopenharmony_ci  module_out_path = module_output_path
2617fd14ceSopenharmony_ci  fuzz_config_file = "${deviceauth_path}/test/fuzztest/devauthfunc_fuzzer"
2717fd14ceSopenharmony_ci  include_dirs = inc_path
2817fd14ceSopenharmony_ci  include_dirs += hals_inc_path
2917fd14ceSopenharmony_ci
3017fd14ceSopenharmony_ci  include_dirs += [
3117fd14ceSopenharmony_ci    ".",
3217fd14ceSopenharmony_ci    "../../unittest/deviceauth/include",
3317fd14ceSopenharmony_ci    "../../unittest/deviceauth/unit_test/include",
3417fd14ceSopenharmony_ci    "${dev_frameworks_path}/inc/hiview_adapter",
3517fd14ceSopenharmony_ci  ]
3617fd14ceSopenharmony_ci
3717fd14ceSopenharmony_ci  sources = hal_common_files
3817fd14ceSopenharmony_ci  sources -= [ "${common_lib_path}/impl/src/json_utils.c" ]
3917fd14ceSopenharmony_ci  sources += [
4017fd14ceSopenharmony_ci    "${key_management_adapter_path}/impl/src/common/mbedtls_ec_adapter.c",
4117fd14ceSopenharmony_ci    "${key_management_adapter_path}/impl/src/huks_adapter.c",
4217fd14ceSopenharmony_ci    "${key_management_adapter_path}/impl/src/standard/crypto_hash_to_point.c",
4317fd14ceSopenharmony_ci    "${key_management_adapter_path}/impl/src/standard/huks_adapter_diff_impl.c",
4417fd14ceSopenharmony_ci    "${os_adapter_path}/impl/src/hc_log.c",
4517fd14ceSopenharmony_ci    "${os_adapter_path}/impl/src/linux/hc_condition.c",
4617fd14ceSopenharmony_ci    "${os_adapter_path}/impl/src/linux/hc_file.c",
4717fd14ceSopenharmony_ci    "${os_adapter_path}/impl/src/linux/hc_init_protection.c",
4817fd14ceSopenharmony_ci    "${os_adapter_path}/impl/src/linux/hc_thread.c",
4917fd14ceSopenharmony_ci    "${os_adapter_path}/impl/src/linux/hc_types.c",
5017fd14ceSopenharmony_ci    "../../unittest/deviceauth/source/hc_dev_info_mock.c",
5117fd14ceSopenharmony_ci    "../../unittest/deviceauth/source/json_utils_mock.c",
5217fd14ceSopenharmony_ci  ]
5317fd14ceSopenharmony_ci
5417fd14ceSopenharmony_ci  sources += dev_frameworks_files
5517fd14ceSopenharmony_ci  sources += deviceauth_common_files
5617fd14ceSopenharmony_ci  sources += database_manager_files
5717fd14ceSopenharmony_ci  sources += cred_manager_files
5817fd14ceSopenharmony_ci  sources += session_manager_files
5917fd14ceSopenharmony_ci  sources += session_v1_files
6017fd14ceSopenharmony_ci  sources += session_v2_files
6117fd14ceSopenharmony_ci  sources += iso_protocol_files
6217fd14ceSopenharmony_ci  sources += ec_speke_protocol_files
6317fd14ceSopenharmony_ci  sources += auth_code_import_files
6417fd14ceSopenharmony_ci  sources += pub_key_exchange_files
6517fd14ceSopenharmony_ci  sources += save_trusted_info_files
6617fd14ceSopenharmony_ci  sources += creds_manager_files
6717fd14ceSopenharmony_ci  sources += broadcast_manager_files
6817fd14ceSopenharmony_ci  sources += soft_bus_channel_mock_files
6917fd14ceSopenharmony_ci
7017fd14ceSopenharmony_ci  sources += group_auth_files
7117fd14ceSopenharmony_ci  sources += group_auth_account_unrelated_files
7217fd14ceSopenharmony_ci
7317fd14ceSopenharmony_ci  sources += group_manager_files
7417fd14ceSopenharmony_ci  sources += group_manager_peer_to_peer_files
7517fd14ceSopenharmony_ci
7617fd14ceSopenharmony_ci  sources += authenticators_p2p_files
7717fd14ceSopenharmony_ci  sources += authenticators_p2p_iso_files
7817fd14ceSopenharmony_ci  sources += authenticators_p2p_pake_files
7917fd14ceSopenharmony_ci  sources += authenticators_standard_exchange_task_files
8017fd14ceSopenharmony_ci
8117fd14ceSopenharmony_ci  sources += account_related_files
8217fd14ceSopenharmony_ci
8317fd14ceSopenharmony_ci  sources += privacy_enhancement_files
8417fd14ceSopenharmony_ci  sources += mk_agree_files
8517fd14ceSopenharmony_ci
8617fd14ceSopenharmony_ci  sources += security_label_adapter_files
8717fd14ceSopenharmony_ci
8817fd14ceSopenharmony_ci  sources -= [
8917fd14ceSopenharmony_ci    "${authenticators_path}/src/account_unrelated/iso_task/iso_task_main.c",
9017fd14ceSopenharmony_ci    "${authenticators_path}/src/account_unrelated/pake_task/pake_v1_task/pake_v1_task_main.c",
9117fd14ceSopenharmony_ci  ]
9217fd14ceSopenharmony_ci
9317fd14ceSopenharmony_ci  sources += [
9417fd14ceSopenharmony_ci    "${dev_frameworks_path}/src/plugin_adapter_mock/account_auth_plugin_proxy_mock.c",
9517fd14ceSopenharmony_ci    "../../unittest/deviceauth/source/device_auth_ext_mock.c",
9617fd14ceSopenharmony_ci    "../../unittest/deviceauth/source/os_account_adapter_mock.c",
9717fd14ceSopenharmony_ci    "../../unittest/deviceauth/source/protocol_task_main_mock.c",
9817fd14ceSopenharmony_ci  ]
9917fd14ceSopenharmony_ci  defines = [
10017fd14ceSopenharmony_ci    "P2P_PAKE_DL_PRIME_LEN_384",
10117fd14ceSopenharmony_ci    "P2P_PAKE_EC_TYPE",
10217fd14ceSopenharmony_ci    "ENABLE_EC_SPEKE",
10317fd14ceSopenharmony_ci    "ENABLE_ISO",
10417fd14ceSopenharmony_ci    "ENABLE_AUTH_CODE_IMPORT",
10517fd14ceSopenharmony_ci    "ENABLE_PUB_KEY_EXCHANGE",
10617fd14ceSopenharmony_ci    "ENABLE_SAVE_TRUSTED_INFO",
10717fd14ceSopenharmony_ci    "ENABLE_ACCOUNT_AUTH_ISO",
10817fd14ceSopenharmony_ci    "ENABLE_ACCOUNT_AUTH_EC_SPEKE",
10917fd14ceSopenharmony_ci    "ENABLE_P2P_BIND_ISO",
11017fd14ceSopenharmony_ci    "ENABLE_P2P_BIND_EC_SPEKE",
11117fd14ceSopenharmony_ci    "ENABLE_P2P_AUTH_ISO",
11217fd14ceSopenharmony_ci    "ENABLE_P2P_AUTH_EC_SPEKE",
11317fd14ceSopenharmony_ci    "DEV_AUTH_FUNC_TEST",
11417fd14ceSopenharmony_ci    "ENABLE_PSEUDONYM",
11517fd14ceSopenharmony_ci  ]
11617fd14ceSopenharmony_ci
11717fd14ceSopenharmony_ci  sources += identity_manager_files
11817fd14ceSopenharmony_ci  include_dirs += identity_manager_inc
11917fd14ceSopenharmony_ci  sources += [ "devauthfunc_fuzzer.cpp" ]
12017fd14ceSopenharmony_ci
12117fd14ceSopenharmony_ci  cflags = [ "-DHILOG_ENABLE" ]
12217fd14ceSopenharmony_ci  cflags += [
12317fd14ceSopenharmony_ci    "-DDEV_AUTH_WORK_THREAD_STACK_SIZE=102400",
12417fd14ceSopenharmony_ci    "-DMAX_AUTH_SESSION_COUNT=${max_auth_session_count}",
12517fd14ceSopenharmony_ci  ]
12617fd14ceSopenharmony_ci
12717fd14ceSopenharmony_ci  external_deps = [
12817fd14ceSopenharmony_ci    "cJSON:cjson",
12917fd14ceSopenharmony_ci    "c_utils:utils",
13017fd14ceSopenharmony_ci    "hilog:libhilog",
13117fd14ceSopenharmony_ci    "huks:libhukssdk",
13217fd14ceSopenharmony_ci    "mbedtls:mbedtls_shared",
13317fd14ceSopenharmony_ci    "openssl:libcrypto_static",
13417fd14ceSopenharmony_ci  ]
13517fd14ceSopenharmony_ci}
13617fd14ceSopenharmony_ci
13717fd14ceSopenharmony_ci###############################################################################
13817fd14ceSopenharmony_cigroup("fuzztest") {
13917fd14ceSopenharmony_ci  testonly = true
14017fd14ceSopenharmony_ci  deps = []
14117fd14ceSopenharmony_ci  deps += [
14217fd14ceSopenharmony_ci    # deps file
14317fd14ceSopenharmony_ci    ":DevAuthFuncFuzzTest",
14417fd14ceSopenharmony_ci  ]
14517fd14ceSopenharmony_ci}
14617fd14ceSopenharmony_ci###############################################################################
147