1 /* 2 * Copyright (c) 2023-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 permission and 13 * limitations under the License. 14 */ 15 16 #ifndef AUTH_DEVICEPROFILE_H 17 #define AUTH_DEVICEPROFILE_H 18 19 #include <stdint.h> 20 21 #include "auth_session_key.h" 22 #include "auth_uk_manager.h" 23 #include "auth_user_common_key.h" 24 #include "lnn_node_info.h" 25 26 #ifdef __cplusplus 27 #if __cplusplus 28 extern "C" { 29 #endif 30 #endif 31 32 typedef enum { 33 UPDATE_ACL_SUCC = 0, 34 UPDATE_ACL_NOT_MATCH, 35 GET_ALL_ACL_FAIL, 36 GET_ALL_ACL_IS_EMPTY, 37 MATCH_ONE_ACL, 38 } UpdateDpAclResult; 39 40 typedef struct { 41 char udid[UDID_BUF_LEN]; 42 int32_t userId; 43 } TrustedInfo; 44 45 typedef struct { 46 int64_t accountId; 47 const char *deviceId; 48 int32_t peerUserId; 49 } UpdateDpAclParams; 50 51 bool IsPotentialTrustedDeviceDp(const char *deviceIdHash, bool isOnlyPointToPoint); 52 bool DpHasAccessControlProfile(const char *udid, bool isNeedUserId, int32_t localUserId); 53 void UpdateDpSameAccount(UpdateDpAclParams *aclParams, SessionKey sessionKey, bool isNeedUpdateDk, 54 AclWriteState aclState); 55 void DelNotTrustDevice(const char *udid); 56 void DelSessionKeyProfile(int32_t sessionKeyId); 57 bool GetSessionKeyProfile(int32_t sessionKeyId, uint8_t *sessionKey, uint32_t *length); 58 int32_t GetAccessUkIdSameAccount(const AuthACLInfo *acl, int32_t *ukId, uint64_t *time); 59 int32_t GetAccessUkIdDiffAccountWithUserLevel(const AuthACLInfo *acl, int32_t *ukId, uint64_t *time); 60 int32_t GetAccessUkIdDiffAccount(const AuthACLInfo *acl, int32_t *ukId, uint64_t *time); 61 int32_t GetAccessUkByUkId(int32_t sessionKeyId, uint8_t *uk, uint32_t ukLen); 62 void UpdateAssetSessionKeyByAcl( 63 AuthACLInfo *info, const uint8_t *sessionKey, uint32_t sessionKeyLen, int32_t *sessionKeyId, bool isSameAccount); 64 bool IsSKIdInvalid(int32_t sessionKeyId, const char *accountHash, const char *udidShortHash, int32_t userId); 65 int32_t SelectAllAcl(TrustedInfo **trustedInfoArray, uint32_t *num); 66 bool IsTrustedDeviceFromAccess(const char *peerAccountHash, const char *peerUdid, int32_t peerUserId); 67 68 #ifdef __cplusplus 69 #if __cplusplus 70 } 71 #endif 72 #endif 73 #endif /* AUTH_DEVICEPROFILE_H */ 74 75