1 /* 2 * Copyright (c) 2022-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_HICHAIN_H 17 #define AUTH_HICHAIN_H 18 19 #include <stdbool.h> 20 #include <stdint.h> 21 22 #include "device_auth.h" 23 #include "softbus_common.h" 24 25 #ifdef __cplusplus 26 #if __cplusplus 27 extern "C" { 28 #endif 29 #endif 30 31 #define GROUP_TYPE_ACCOUNT (1 << 0) 32 #define GROUP_TYPE_P2P (1 << 1) 33 #define GROUP_TYPE_MESH (1 << 2) 34 #define GROUP_TYPE_COMPATIBLE (1 << 3) 35 #define PC_PROOF_NON_CONSISTENT_ERRCODE 2046820418 36 #define MAX_CRED_ID_SIZE 300 37 38 typedef struct { 39 char udid[UDID_BUF_LEN]; 40 char uid[MAX_ACCOUNT_HASH_LEN]; 41 char credId[MAX_CRED_ID_SIZE]; 42 int32_t userId; 43 DeviceAuthCallback *cb; 44 uint16_t deviceTypeId; 45 } HiChainAuthParam; 46 47 typedef enum { 48 HICHAIN_AUTH_DEVICE = 0, 49 HICHAIN_AUTH_IDENTITY_SERVICE, 50 HICHAIN_AUTH_BUTT 51 } HiChainAuthMode; 52 53 typedef struct { 54 void (*onGroupCreated)(const char *groupId, int32_t groupType); 55 void (*onGroupDeleted)(const char *groupId, int32_t groupType); 56 void (*onDeviceNotTrusted)(const char *udid, int32_t localUserId); 57 void (*onDeviceBound)(const char *udid, const char *groupInfo); 58 } TrustDataChangeListener; 59 int32_t RegTrustDataChangeListener(const TrustDataChangeListener *listener); 60 void UnregTrustDataChangeListener(void); 61 62 int32_t HichainStartAuth(int64_t authSeq, HiChainAuthParam *hiChainParam, HiChainAuthMode authMode); 63 int32_t HichainProcessData(int64_t authSeq, const uint8_t *data, uint32_t len, HiChainAuthMode authMode); 64 int32_t HichainProcessUkNegoData( 65 int64_t authSeq, const uint8_t *data, uint32_t len, HiChainAuthMode authMode, DeviceAuthCallback *cb); 66 uint32_t HichainGetJoinedGroups(int32_t groupType); 67 int32_t RegHichainSaStatusListener(void); 68 int32_t UnRegHichainSaStatusListener(void); 69 void GetSoftbusHichainAuthErrorCode(uint32_t hichainErrCode, uint32_t *softbusErrCode); 70 71 void HichainCancelRequest(int64_t authReqId); 72 void HichainDestroy(void); 73 74 #ifdef __cplusplus 75 #if __cplusplus 76 } 77 #endif 78 #endif 79 #endif /* AUTH_HICHAIN_H */ 80