• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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_INTERFACE_H
17 #define AUTH_INTERFACE_H
18 
19 #include <stdbool.h>
20 #include <stdint.h>
21 #include "lnn_node_info.h"
22 #include "softbus_common.h"
23 #include "softbus_conn_interface.h"
24 #include "softbus_def.h"
25 #include "auth_interface_struct.h"
26 
27 #ifdef __cplusplus
28 #if __cplusplus
29 extern "C" {
30 #endif
31 #endif
32 
33 int32_t RegAuthVerifyListener(const AuthVerifyListener *listener);
34 void UnregAuthVerifyListener(void);
35 uint32_t AuthGenRequestId(void);
36 int32_t AuthStartVerify(const AuthConnInfo *connInfo, const AuthVerifyParam *authVerifyParam,
37     const AuthVerifyCallback *callback);
38 int32_t AuthStartConnVerify(const AuthConnInfo *connInfo, uint32_t requestId, const AuthConnCallback *connCallback,
39     AuthVerifyModule module, bool isFastAuth);
40 void AuthHandleLeaveLNN(AuthHandle authHandle);
41 int32_t AuthFlushDevice(const char *uuid);
42 int32_t AuthSendKeepaliveOption(const char *uuid, ModeCycle cycle);
43 
44 int32_t AuthMetaStartVerify(uint32_t connectionId, const AuthKeyInfo *authKeyInfo, uint32_t requestId,
45     int32_t callingPid, const AuthVerifyCallback *callBack);
46 void AuthMetaReleaseVerify(int64_t authId);
47 void AuthServerDeathCallback(const char *pkgName, int32_t pid);
48 
49 int32_t RegGroupChangeListener(const GroupChangeListener *listener);
50 void UnregGroupChangeListener(void);
51 
52 TrustedReturnType AuthHasTrustedRelation(void);
53 bool AuthIsPotentialTrusted(const DeviceInfo *device, bool isOnlyPointToPoint);
54 bool IsAuthHasTrustedRelation(void);
55 bool IsSameAccountDevice(const DeviceInfo *device);
56 bool AuthHasSameAccountGroup(void);
57 bool IsSameAccountId(int64_t accountId);
58 
59 int32_t AuthStartListening(AuthLinkType type, const char *ip, int32_t port);
60 void AuthStopListening(AuthLinkType type);
61 
62 int32_t AuthStartListeningForWifiDirect(AuthLinkType type, const char *ip, int32_t port, ListenerModule *moduleId);
63 void AuthStopListeningForWifiDirect(AuthLinkType type, ListenerModule moduleId);
64 
65 int32_t RegAuthTransListener(int32_t module, const AuthTransListener *listener);
66 void UnregAuthTransListener(int32_t module);
67 
68 int32_t AuthOpenConn(const AuthConnInfo *info, uint32_t requestId, const AuthConnCallback *callback, bool isMeta);
69 int32_t AuthPostTransData(AuthHandle authHandle, const AuthTransData *dataInfo);
70 void AuthCloseConn(AuthHandle authHandle);
71 int32_t AuthGetPreferConnInfo(const char *uuid, AuthConnInfo *connInfo, bool isMeta);
72 int32_t AuthGetConnInfoByType(const char *uuid, AuthLinkType type, AuthConnInfo *connInfo, bool isMeta);
73 int32_t AuthGetConnInfoBySide(const char *uuid, AuthConnInfo *connInfo, bool isMeta, bool isClient);
74 int32_t AuthGetP2pConnInfo(const char *uuid, AuthConnInfo *connInfo, bool isMeta);
75 int32_t AuthGetHmlConnInfo(const char *uuid, AuthConnInfo *connInfo, bool isMeta);
76 int32_t AuthGetUsbConnInfo(const char *uuid, AuthConnInfo *connInfo, bool isMeta);
77 int32_t AuthGetLatestAuthSeqList(const char *udid, int64_t *seqList, uint32_t num);
78 int32_t AuthGetLatestAuthSeqListByType(const char *udid, int64_t *seqList, uint64_t *authVerifyTime,
79     DiscoveryType type);
80 /* for ProxyChannel & P2P TcpDirectchannel */
81 void AuthGetLatestIdByUuid(const char *uuid, AuthLinkType type, bool isMeta, AuthHandle *authHandle);
82 int32_t AuthGetAuthHandleByIndex(const AuthConnInfo *connInfo, bool isServer, int32_t index, AuthHandle *authHandle);
83 int32_t AuthGetAuthHandleByIndexForBle(const AuthConnInfo *connInfo, char *networkId, NodeInfo *info);
84 int64_t AuthGetIdByConnInfo(const AuthConnInfo *connInfo, bool isServer, bool isMeta);
85 int64_t AuthGetIdByUuid(const char *uuid, AuthLinkType type, bool isServer, bool isMeta);
86 
87 uint32_t AuthGetEncryptSize(int64_t authId, uint32_t inLen);
88 uint32_t AuthGetDecryptSize(uint32_t inLen);
89 int32_t AuthEncrypt(AuthHandle *authHandle, const uint8_t *inData, uint32_t inLen, uint8_t *outData, uint32_t *outLen);
90 int32_t AuthDecrypt(AuthHandle *authHandle, const uint8_t *inData, uint32_t inLen, uint8_t *outData, uint32_t *outLen);
91 int32_t AuthSetP2pMac(int64_t authId, const char *p2pMac);
92 
93 int32_t AuthGetConnInfo(AuthHandle authHandle, AuthConnInfo *connInfo);
94 int32_t AuthGetServerSide(int64_t authId, bool *isServer);
95 int32_t AuthGetDeviceUuid(int64_t authId, char *uuid, uint16_t size);
96 int32_t AuthGetVersion(int64_t authId, SoftBusVersion *version);
97 int32_t AuthGetMetaType(int64_t authId, bool *isMetaAuth);
98 uint32_t AuthGetGroupType(const char *udid, const char *uuid);
99 bool IsSupportFeatureByCapaBit(uint32_t feature, AuthCapability capaBit);
100 void AuthRemoveAuthManagerByAuthHandle(AuthHandle authHandle);
101 
102 int32_t AuthCheckSessionKeyValidByConnInfo(const char *networkId, const AuthConnInfo *connInfo);
103 int32_t AuthCheckSessionKeyValidByAuthHandle(const AuthHandle *authHandle);
104 int32_t AuthInit(void);
105 void AuthDeinit(void);
106 int32_t AuthRestoreAuthManager(const char *udidHash,
107     const AuthConnInfo *connInfo, uint32_t requestId, NodeInfo *nodeInfo, int64_t *authId);
108 int32_t AuthCheckMetaExist(const AuthConnInfo *connInfo, bool *isExist);
109 
110 
111 #ifdef __cplusplus
112 #if __cplusplus
113 }
114 #endif
115 #endif
116 #endif /* AUTH_INTERFACE_H */
117