1 /* 2 * Copyright (c) 2024-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 /** 17 * @file hks_plugin_def.h 18 * 19 * @brief Declares huks plugin struct and enum. 20 * 21 * @since 12 22 */ 23 24 #ifndef HKS_PLUGIN_DEF_H 25 #define HKS_PLUGIN_DEF_H 26 27 #include "hks_type.h" 28 29 #ifdef __cplusplus 30 extern "C" { 31 #endif 32 33 /** 34 * @brief hks process info 35 */ 36 struct HksProcessInfo { 37 struct HksBlob userId; 38 struct HksBlob processName; 39 int32_t userIdInt; 40 uint32_t uidInt; 41 uint64_t accessTokenId; 42 }; 43 44 enum LocalRequestCode { 45 CODE_UPGRADE = 1, 46 }; 47 48 /** 49 * @brief hks base ability interface 50 */ 51 struct HksBasicInterface { 52 int32_t (*hksManageStoreKeyBlob)(const struct HksProcessInfo *processInfo, const struct HksParamSet *paramSet, 53 const struct HksBlob *keyAlias, const struct HksBlob *keyBlob, uint32_t storageType); 54 int32_t (*hksManageStoreDeleteKeyBlob)(const struct HksProcessInfo *processInfo, const struct HksParamSet *paramSet, 55 const struct HksBlob *keyAlias, uint32_t storageType); 56 int32_t (*hksManageStoreIsKeyBlobExist)(const struct HksProcessInfo *processInfo, 57 const struct HksParamSet *paramSet, const struct HksBlob *keyAlias, uint32_t storageType); 58 int32_t (*hksManageStoreGetKeyBlob)(const struct HksProcessInfo *processInfo, const struct HksParamSet *paramSet, 59 const struct HksBlob *keyAlias, struct HksBlob *keyBlob, uint32_t storageType); 60 int32_t (*hksManageStoreGetKeyBlobSize)(const struct HksProcessInfo *processInfo, 61 const struct HksParamSet *paramSet, const struct HksBlob *keyAlias, 62 uint32_t *keyBlobSize, uint32_t storageType); 63 int32_t (*hksManageGetKeyCountByProcessName)(const struct HksProcessInfo *processInfo, 64 const struct HksParamSet *paramSet, uint32_t *fileCount); 65 66 int32_t (*hksGetProcessInfoForIPC)(const uint8_t *context, struct HksProcessInfo *processInfo); 67 68 int32_t (*appendStorageParamsForGen)(const struct HksProcessInfo *processInfo, 69 const struct HksParamSet *paramSet, struct HksParamSet **outParamSet); 70 int32_t (*appendStorageParamsForUse)(const struct HksParamSet *paramSet, 71 const struct HksProcessInfo *processInfo, struct HksParamSet **outParamSet); 72 int32_t (*appendStorageParamsForQuery)(const struct HksParamSet *paramSet, struct HksParamSet **outParamSet); 73 }; 74 75 /** 76 * @brief hks plugin proxy 77 */ 78 struct HksPluginProxy { 79 int32_t (*hksPluginInit)(struct HksBasicInterface *interfaceInst); 80 void (*hksPluginDestory)(void); 81 int32_t (*hksPluginOnRemoteRequest)(uint32_t code, void *data, void *reply, void *option); 82 int32_t (*hksPluginOnLocalRequest)(uint32_t code, const void *data, void *reply); 83 void (*hksPluginOnReceiveEvent)(const void *eventData); 84 }; 85 86 #ifdef __cplusplus 87 } 88 #endif 89 90 #endif // HKS_PLUGIN_DEF_H