1 /*
2  * Copyright (c) 2022 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_META_MANAGER_H
17 #define AUTH_META_MANAGER_H
18 
19 #include <stdint.h>
20 #include <stdbool.h>
21 #include "auth_common.h"
22 #include "auth_interface.h"
23 
24 #ifdef __cplusplus
25 #if __cplusplus
26 extern "C" {
27 #endif
28 #endif
29 
30 int32_t AuthMetaInit(const AuthTransCallback *callback);
31 void AuthMetaDeinit(void);
32 
33 int32_t AuthMetaStartVerify(uint32_t connectionId, const AuthKeyInfo *authKeyInfo, uint32_t requestId,
34     int32_t callingPid, const AuthVerifyCallback *callBack);
35 void AuthMetaReleaseVerify(int64_t authId);
36 
37 int32_t AuthMetaEncrypt(int64_t authId, const uint8_t *inData, uint32_t inLen,
38     uint8_t *outData, uint32_t *outLen);
39 int32_t AuthMetaDecrypt(int64_t authId, const uint8_t *inData, uint32_t inLen,
40     uint8_t *outData, uint32_t *outLen);
41 
42 int32_t AuthMetaGetPreferConnInfo(const char *uuid, AuthConnInfo *connInfo);
43 int32_t AuthMetaOpenConn(const AuthConnInfo *info, uint32_t requestId, const AuthConnCallback *callback);
44 void AuthMetaNotifyDataReceived(uint32_t connectionId, const SocketPktHead *pktHead, const uint8_t *data);
45 void AuthMetaCloseConn(int64_t authId);
46 
47 int32_t AuthMetaPostTransData(int64_t authId, const AuthTransData *dataInfo);
48 int64_t AuthMetaGetIdByConnInfo(const AuthConnInfo *connInfo, bool isServer);
49 int64_t AuthMetaGetIdByUuid(const char *uuid, AuthLinkType type, bool isServer);
50 int32_t AuthMetaSetP2pMac(int64_t authId, const char *p2pMac);
51 int32_t AuthMetaGetConnInfo(int64_t authId, AuthConnInfo *connInfo);
52 int32_t AuthMetaGetServerSide(int64_t authId, bool *isServer);
53 int32_t AuthMetaGetDeviceUuid(int64_t authId, char *uuid, uint16_t size);
54 int32_t AuthMetaGetConnIdByInfo(const AuthConnInfo *connInfo, uint32_t *connectionId);
55 void DelAuthMetaManagerByPid(const char *pkgName, int32_t pid);
56 void AuthMetaCheckMetaExist(const AuthConnInfo *connInfo, bool *isExist);
57 void DelAuthMetaManagerByConnectionId(uint32_t connectionId);
58 
59 #ifdef __cplusplus
60 #if __cplusplus
61 }
62 #endif
63 #endif
64 #endif /* AUTH_META_MANAGER_H */
65