1# Copyright (c) 2021 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("../../dsoftbus.gni")
15import("../common/dfx/dsoftbus_dfx.gni")
16AUTH_SERVER_DEFINES = []
17if (dsoftbus_feature_auth_account == true) {
18  AUTH_SERVER_DEFINES += [ "AUTH_ACCOUNT" ]
19}
20
21authentication_path = "$dsoftbus_root_path/core/authentication"
22native_source_path = rebase_path("$dsoftbus_root_path")
23auth_dir = "dsoftbus_enhance/core/authentication/"
24enhanced = exec_script("$dsoftbus_root_path/check_sub_module.py",
25                       [
26                         "$native_source_path",
27                         "$auth_dir",
28                       ],
29                       "value")
30
31auth_server_inc = [
32  "$dsoftbus_root_path/core/authentication/include",
33  "$dsoftbus_root_path/core/authentication/interface",
34  "$dsoftbus_root_path/core/common/dfx/hisysevent_adapter/include",
35  "$dsoftbus_root_path/core/common/dfx/interface/include",
36  "$dsoftbus_root_path/core/adapter/authentication/include",
37  "$dsoftbus_root_path/core/bus_center/lnn/lane_hub/heartbeat/include",
38  "$dsoftbus_root_path/core/bus_center/lnn/net_ledger/distributed_ledger/include",
39  "$dsoftbus_root_path/core/adapter/bus_center/include",
40  "$dsoftbus_root_path/core/bus_center/utils/include/",
41]
42if (dsoftbus_feature_lnn_net) {
43  auth_server_src = [
44    "$authentication_path/src/auth_common.c",
45    "$authentication_path/src/auth_connection.c",
46    "$authentication_path/src/auth_device.c",
47    "$authentication_path/src/auth_hichain.c",
48    "$authentication_path/src/auth_hichain_adapter.c",
49    "$authentication_path/src/auth_lane.c",
50    "$authentication_path/src/auth_manager.c",
51    "$authentication_path/src/auth_normalize_request.c",
52    "$authentication_path/src/auth_request.c",
53    "$authentication_path/src/auth_session_fsm.c",
54    "$authentication_path/src/auth_session_key.c",
55    "$authentication_path/src/auth_session_json.c",
56    "$authentication_path/src/auth_session_message.c",
57    "$authentication_path/src/auth_interface.c",
58  ]
59  if (enhanced) {
60    auth_server_src += [
61      "$dsoftbus_root_path/dsoftbus_enhance/core/authentication/auth_device_common_key.c",
62      "$dsoftbus_root_path/dsoftbus_enhance/core/authentication/auth_meta_manager.c",
63      "$dsoftbus_root_path/dsoftbus_enhance/core/authentication/auth_meta_ptk_proc.c",
64      "$dsoftbus_root_path/dsoftbus_enhance/core/authentication/ccmp/src/ccmp_instance.c",
65      "$dsoftbus_root_path/dsoftbus_enhance/core/authentication/ccmp/src/ccmp_key.c",
66      "$dsoftbus_root_path/dsoftbus_enhance/core/authentication/ccmp/src/ccmp_manager.c",
67      "$dsoftbus_root_path/dsoftbus_enhance/core/authentication/ccmp/src/ccmp_message_hml.c",
68      "$dsoftbus_root_path/dsoftbus_enhance/core/authentication/ccmp/src/ccmp_message.c",
69      "$dsoftbus_root_path/dsoftbus_enhance/core/authentication/ccmp/src/ccmp_utils.c",
70      "$dsoftbus_root_path/dsoftbus_enhance/core/authentication/auth_generate_attest.c",
71      "$dsoftbus_root_path/dsoftbus_enhance/core/authentication/auth_validate_attest.c",
72    ]
73    auth_server_inc += [
74      "$dsoftbus_root_path/adapter/common/include/",
75      "$dsoftbus_root_path/core/adapter/huks/include/",
76      "$dsoftbus_root_path/dsoftbus_enhance/core/authentication/ccmp/include/",
77    ]
78  } else {
79    auth_server_src += [
80      "$authentication_path/src/virtual/auth_attest_virtual.c",
81      "$authentication_path/src/virtual/auth_device_common_key_virtual.c",
82      "$authentication_path/src/virtual/auth_meta_manager_virtual.c",
83      "$authentication_path/src/virtual/customized_security_protocol_virtual.c",
84      "$authentication_path/src/virtual/auth_meta_ptk_proc_virtual.c",
85    ]
86  }
87  if (dsoftbus_feature_ip_auth) {
88    auth_server_src +=
89        [ "$dsoftbus_root_path/core/authentication/src/auth_tcp_connection.c" ]
90  } else {
91    auth_server_src += [ "$dsoftbus_root_path/core/authentication/src/virtual/auth_tcp_connection_virtual.c" ]
92  }
93} else {
94  auth_server_src = [
95    "$authentication_path/src/virtual/auth_interface_virtual.c",
96    "$authentication_path/src/virtual/auth_tcp_connection_virtual.c",
97    "$authentication_path/src/virtual/auth_meta_manager_virtual.c",
98    "$authentication_path/src/virtual/auth_meta_ptk_proc_virtual.c",
99  ]
100}
101auth_server_deps = [
102  "$dsoftbus_dfx_path/anonymize:softbus_dfx_anonymizer",
103  "$dsoftbus_dfx_path/log:softbus_dfx_log",
104]
105auth_server_ex_deps = []
106if (defined(ohos_lite)) {
107  if (ohos_kernel_type == "liteos_m") {
108    auth_server_inc += [ "//base/security/device_auth/interfaces/inner_api" ]
109    if (dsoftbus_feature_lnn_net) {
110      auth_server_deps += [ "//base/security/device_auth/services:deviceauth" ]
111    }
112  } else {
113    auth_server_inc += [ "//third_party/cJSON" ]
114    if (dsoftbus_feature_lnn_net) {
115      auth_server_deps +=
116          [ "//base/security/device_auth/services:deviceauth_sdk" ]
117    }
118  }
119  auth_server_src += [ "$authentication_path/src/virtual/auth_hichain_system_ability_monitor_virtual.c" ]
120} else {
121  auth_server_ex_deps += [ "device_auth:deviceauth_sdk" ]
122  auth_server_src +=
123      [ "$authentication_path/src/auth_hichain_system_ability_monitor.cpp" ]
124}
125
126if (!defined(global_parts_info) ||
127    defined(global_parts_info.deviceprofile_device_info_manager)) {
128  auth_server_src += [
129    "$authentication_path/bind/auth_device_profile_listener.cpp",
130    "$authentication_path/src/auth_deviceprofile.cpp",
131  ]
132} else {
133  auth_server_src += [
134    "$authentication_path/bind/auth_device_profile_listener_virtual.cpp",
135    "$authentication_path/src/auth_deviceprofile_virtual.cpp",
136  ]
137}
138