• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 * Copyright (c) 2022-2025 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 
16 #ifndef AUTH_SESSION_STRUCT_H
17 #define AUTH_SESSION_STRUCT_H
18 
19 #include <stdint.h>
20 #include <stdbool.h>
21 
22 #include "auth_interface_struct.h"
23 #include "auth_session_key_struct.h"
24 
25 #include "common_list.h"
26 #include "lnn_node_info_struct.h"
27 #include "lnn_p2p_info_struct.h"
28 #include "lnn_state_machine_struct.h"
29 #include "softbus_hisysevt_bus_center.h"
30 
31 #ifdef __cplusplus
32 #if __cplusplus
33 extern "C" {
34 #endif
35 #endif
36 
37 #define AUTH_FSM_NAME_LEN 32
38 
39 typedef enum {
40    STATE_SYNC_NEGOTIATION,
41    STATE_SYNC_DEVICE_ID,
42    STATE_DEVICE_AUTH,
43    STATE_SYNC_DEVICE_INFO,
44    STATE_NUM_MAX
45 } AuthFsmStateIndex;
46 
47 typedef enum {
48    EXCHANGE_UDID = 0,
49    EXCHANGE_NETWORKID,
50    EXCHANGE_FAIL,
51    EXCHANGE_TYPE_MAX
52 } ExchangeDataType;
53 
54 typedef enum {
55    NORMALIZED_NOT_SUPPORT,
56    NORMALIZED_KEY_ERROR,
57    NORMALIZED_SUPPORT,
58 } NormalizedType;
59 
60 typedef enum {
61    AUTH_STATE_WAIT = 1,
62    AUTH_STATE_START,
63    AUTH_STATE_UNKNOW,
64    AUTH_STATE_ACK,
65    AUTH_STATE_COMPATIBLE,
66 } AuthStartState;
67 
68 typedef struct {
69    bool isServer;
70    uint32_t requestId;
71    int64_t authSeq;
72    uint64_t connId;
73    DeviceKeyId deviceKeyId;
74 } AuthFsmParam;
75 
76 typedef struct {
77    uint32_t requestId;
78    bool isServer;
79    bool isConnectServer;
80    uint64_t connId;
81    AuthConnInfo connInfo;
82    uint8_t *deviceInfoData;
83    uint32_t deviceInfoDataLen;
84    NodeInfo nodeInfo;
85    bool isNodeInfoReceived;
86    bool isCloseAckReceived;
87    bool isAuthFinished;
88    char udid[UDID_BUF_LEN];
89    char uuid[UUID_BUF_LEN];
90    char udidHash[SHA_256_HEX_HASH_LEN];
91    SoftBusVersion version;
92    AuthVersion authVersion;
93    bool isSupportCompress;
94    bool isSupportFastAuth;
95    bool isNeedFastAuth;
96    bool isSupportDmDeviceKey;
97    DeviceKeyId deviceKeyId;
98    int64_t oldIndex;
99    int32_t idType;
100    int32_t userId;
101    bool isNeedPackCert;
102    bool isSameAccount;
103    uint64_t sessionKeyRandomNum;
104    AuthVerifyModule module;
105    NormalizedType normalizedType;
106    SessionKey *normalizedKey;
107    int64_t normalizedIndex;
108    bool isOldKey;
109    bool isSavedSessionKey;
110    AuthStartState localState;
111    AuthStartState peerState;
112    char udidShortHash[SHA_256_HEX_HASH_LEN];
113    char accountHash[SHA_256_HEX_HASH_LEN];
114    char *credId;
115    int64_t headSeq;
116 } AuthSessionInfo;
117 
118 typedef struct {
119    ListNode node;
120    uint32_t id;
121    int64_t authSeq;
122    char fsmName[AUTH_FSM_NAME_LEN];
123    FsmStateMachine fsm;
124    AuthSessionInfo info;
125    AuthFsmStateIndex curState;
126    AuthStatisticData statisticData;
127    bool isDead;
128 } AuthFsm;
129 
130 typedef struct {
131    int64_t authSeq;
132    uint32_t requestId;
133    uint64_t connId;
134    bool isServer;
135    bool isFastAuth;
136 } AuthParam;
137 
138 #ifdef __cplusplus
139 #if __cplusplus
140 }
141 #endif
142 #endif
143 #endif /* AUTH_SESSION_STRUCT_H */