1 /* 2 * Copyright (C) 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 IDENTITY_OPERATION_H 17 #define IDENTITY_OPERATION_H 18 19 #include "cred_listener.h" 20 #include "credential_data_manager.h" 21 #include "uint8buff_utils.h" 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 int32_t AddCredAndSaveDb(int32_t osAccountId, Credential *credential); 28 int32_t AddKeyValueToHuks(int32_t osAccountId, Uint8Buff *credIdByte, Credential *credential, uint8_t method, 29 Uint8Buff *publicKey); 30 int32_t AddKeyValueToReturn(Uint8Buff keyValue, char **returnData); 31 int32_t AddUpdateInfoToJson(QueryCredentialParams *queryParams, CJson *baseInfoJson); 32 int32_t GetValidKeyAlias(int32_t osAccountId, const char *credId, Uint8Buff *credIdHashBuff); 33 int32_t CheckOwnerUidPermission(Credential *credential); 34 int32_t CheckAndDelInvalidCred(int32_t osAccountId, const char *selfCredId, Uint8Buff *selfCredIdByte); 35 int32_t ComputePskAndDelInvalidKey(int32_t osAccountId, uint8_t credAlgo, 36 Uint8Buff *selfCredIdByte, Uint8Buff *peerKeyAlias, Uint8Buff *agreeCredIdByte); 37 int32_t DelCredById(int32_t osAccountId, const char *credId); 38 int32_t EraseUpdateCredIdInSelfVec(CredentialVec *updateCredVec, CredentialVec *selfCredVec); 39 40 int32_t GenerateCredId(int32_t osAccountId, Credential *credential, Uint8Buff *credIdByte); 41 int32_t GenerateCredKeyAlias(const char *credId, const char *deviceId, Uint8Buff *alias); 42 int32_t GenerateReturnEmptyArrayStr(char **returnVec); 43 int32_t GetCredentialById(int32_t osAccountId, const char *credId, Credential **returnEntry); 44 int32_t GetCredIdsFromCredVec(int32_t osAccountId, CJson *reqJson, CredentialVec *credentialVec, CJson *credIdJson); 45 int32_t GetQueryJsonStr(CJson *baseInfoJson, char **queryJsonStr); 46 int32_t GetUpdateCredVec(int32_t osAccountId, CJson *updateInfo, 47 QueryCredentialParams *queryParams, CredentialVec *updateCredVec); 48 int32_t ImportAgreeKeyValue(int32_t osAccountId, Credential *agreeCredential, Uint8Buff *keyValue, 49 Uint8Buff *peerKeyAlias); 50 bool IsCredHashMatch(Credential *credential, CJson *reqJson); 51 52 int32_t CheckAndSetCredInfo(int32_t osAccountId, Credential *credential, CJson *json, uint8_t *method, 53 Uint8Buff *publicKey); 54 int32_t SetAgreeCredInfo(int32_t osAccountId, CJson *reqJson, 55 Credential *agreeCredential, Uint8Buff *keyValue, Uint8Buff *agreeCredIdByte); 56 int32_t SetQueryParamsFromJson(QueryCredentialParams *queryParams, CJson *json); 57 int32_t SetRequiredParamsFromJson(QueryCredentialParams *queryParams, CJson *baseInfoJson); 58 int32_t SetUpdateToQueryParams(CJson *json, QueryCredentialParams *queryParams); 59 int32_t UpdateInfoFromJson(Credential *credential, CJson *json); 60 61 #ifdef __cplusplus 62 } 63 #endif 64 65 #endif // IDENTITY_OPERATION_H 66