1 /*
2  * Copyright (c) 2024 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_DEVICE_H
17 #define AUTH_DEVICE_H
18 
19 #include <stdbool.h>
20 #include <stdint.h>
21 
22 #include "auth_interface.h"
23 #include "auth_session_fsm.h"
24 #include "softbus_common.h"
25 
26 #ifdef __cplusplus
27 #if __cplusplus
28 extern "C" {
29 #endif
30 #endif
31 
32 #define RETRY_REGDATA_TIMES                3
33 #define RETRY_REGDATA_MILLSECONDS          300
34 #define UDID_SHORT_HASH_LEN_TEMP           8
35 #define SHORT_UDID_HASH_HEX_LEN            16
36 
37 int32_t AuthDevicePostTransData(AuthHandle authHandle, const AuthTransData *dataInfo);
38 int32_t AuthDeviceEncrypt(AuthHandle *authHandle, const uint8_t *inData, uint32_t inLen, uint8_t *outData,
39     uint32_t *outLen);
40 int32_t AuthDeviceDecrypt(AuthHandle *authHandle, const uint8_t *inData, uint32_t inLen, uint8_t *outData,
41     uint32_t *outLen);
42 int32_t AuthDeviceGetConnInfo(AuthHandle authHandle, AuthConnInfo *connInfo);
43 int32_t AuthDeviceGetServerSide(int64_t authId, bool *isServer);
44 int32_t AuthDeviceGetDeviceUuid(int64_t authId, char *uuid, uint16_t size);
45 int32_t AuthDeviceGetVersion(int64_t authId, SoftBusVersion *version);
46 void AuthDeviceNotTrust(const char *udid);
47 int32_t AuthDirectOnlineCreateAuthManager(int64_t authSeq, const AuthSessionInfo *info);
48 int32_t AuthDeviceOpenConn(const AuthConnInfo *info, uint32_t requestId, const AuthConnCallback *callback);
49 void AuthDeviceCloseConn(AuthHandle authHandle);
50 int32_t AuthStartReconnectDevice(
51     AuthHandle authHandle, const AuthConnInfo *connInfo, uint32_t requestId, const AuthConnCallback *connCb);
52 void AuthNotifyDeviceVerifyPassed(AuthHandle authHandle, const NodeInfo *nodeInfo);
53 void AuthNotifyDeviceDisconnect(AuthHandle authHandle);
54 void AuthAddNodeToLimitMap(const char *udid, int32_t reason);
55 void AuthDeleteLimitMap(const char *udidHash);
56 void AuthRegisterToDpDelay(void *para);
57 
58 #ifdef __cplusplus
59 #if __cplusplus
60 }
61 #endif
62 #endif
63 #endif /* AUTH_DEVICE_H */
64