1# Copyright (c) 2023 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("CredsManagerFuzzTest") {
26  module_out_path = module_output_path
27  fuzz_config_file =
28      "${deviceauth_path}/test/fuzztest/creds_manager/credsmanager_fuzzer"
29  include_dirs = inc_path + hals_inc_path
30  include_dirs += [
31    ".",
32    "${inner_api_path}",
33    "${frameworks_path}/inc/standard",
34    "${tdd_framework_path}/common/inc",
35    "${dev_frameworks_path}/inc/hiview_adapter",
36  ]
37  include_dirs += identity_manager_inc
38
39  sources = [ "credsmanager_fuzzer.cpp" ]
40  sources += deviceauth_files
41  sources += hal_common_files
42  sources += hiview_adapter_files
43  if (support_os_account) {
44    sources -= os_account_adapter_files
45  } else {
46    sources -= os_account_adapter_mock_files
47  }
48  if (enable_extend_plugin) {
49    sources -= account_auth_plugin_files
50    sources += account_auth_plugin_mock_files
51  }
52  sources -= soft_bus_channel_files
53  sources += soft_bus_channel_mock_files
54  sources += identity_manager_files
55  sources += [
56    "${key_management_adapter_path}/impl/src/common/mbedtls_ec_adapter.c",
57    "${key_management_adapter_path}/impl/src/huks_adapter.c",
58    "${key_management_adapter_path}/impl/src/standard/crypto_hash_to_point.c",
59    "${key_management_adapter_path}/impl/src/standard/huks_adapter_diff_impl.c",
60    "${os_adapter_path}/impl/src/hc_log.c",
61    "${os_adapter_path}/impl/src/linux/hc_condition.c",
62    "${os_adapter_path}/impl/src/linux/hc_file.c",
63    "${os_adapter_path}/impl/src/linux/hc_init_protection.c",
64    "${os_adapter_path}/impl/src/linux/hc_thread.c",
65    "${os_adapter_path}/impl/src/linux/hc_types.c",
66  ]
67  sources += [
68    "${tdd_framework_path}/common/src/hc_dev_info_mock.c",
69    "${tdd_framework_path}/common/src/os_account_adapter_mock.c",
70  ]
71
72  defines = [
73    "DEV_AUTH_FUZZ_TEST",
74    "DEV_AUTH_HIVIEW_ENABLE",
75  ]
76  cflags = [ "-DHILOG_ENABLE" ]
77  cflags += [
78    "-DDEV_AUTH_WORK_THREAD_STACK_SIZE=${device_auth_hichain_thread_stack_size}",
79    "-DMAX_AUTH_SESSION_COUNT=${max_auth_session_count}",
80  ]
81
82  external_deps = [
83    "cJSON:cjson",
84    "c_utils:utils",
85    "dsoftbus:softbus_client",
86    "hilog:libhilog",
87    "hisysevent:libhisysevent",
88    "hitrace:hitrace_meter",
89    "huks:libhukssdk",
90    "mbedtls:mbedtls_shared",
91    "openssl:libcrypto_static",
92  ]
93}
94
95###############################################################################
96group("fuzztest") {
97  testonly = true
98  deps = []
99  deps += [
100    # deps file
101    ":CredsManagerFuzzTest",
102  ]
103}
104###############################################################################
105