• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     CODE_FAULT_METRICS = 2,
47     CODE_STATISTICS_METRICS = 3
48 };
49 
50 /**
51  * @brief hks base ability interface
52  */
53 struct HksBasicInterface {
54     int32_t (*hksManageStoreKeyBlob)(const struct HksProcessInfo *processInfo, const struct HksParamSet *paramSet,
55         const struct HksBlob *keyAlias, const struct HksBlob *keyBlob, uint32_t storageType);
56     int32_t (*hksManageStoreDeleteKeyBlob)(const struct HksProcessInfo *processInfo, const struct HksParamSet *paramSet,
57         const struct HksBlob *keyAlias, uint32_t storageType);
58     int32_t (*hksManageStoreIsKeyBlobExist)(const struct HksProcessInfo *processInfo,
59         const struct HksParamSet *paramSet, const struct HksBlob *keyAlias, uint32_t storageType);
60     int32_t (*hksManageStoreGetKeyBlob)(const struct HksProcessInfo *processInfo, const struct HksParamSet *paramSet,
61         const struct HksBlob *keyAlias, struct HksBlob *keyBlob, uint32_t storageType);
62     int32_t (*hksManageStoreGetKeyBlobSize)(const struct HksProcessInfo *processInfo,
63         const struct HksParamSet *paramSet, const struct HksBlob *keyAlias,
64         uint32_t *keyBlobSize, uint32_t storageType);
65     int32_t (*hksManageGetKeyCountByProcessName)(const struct HksProcessInfo *processInfo,
66         const struct HksParamSet *paramSet, uint32_t *fileCount);
67 
68     int32_t (*hksGetProcessInfoForIPC)(const uint8_t *context, struct HksProcessInfo *processInfo);
69 
70     int32_t (*appendStorageParamsForGen)(const struct HksProcessInfo *processInfo,
71         const struct HksParamSet *paramSet, struct HksParamSet **outParamSet);
72     int32_t (*appendStorageParamsForUse)(const struct HksParamSet *paramSet,
73         const struct HksProcessInfo *processInfo, struct HksParamSet **outParamSet);
74     int32_t (*appendStorageParamsForQuery)(const struct HksParamSet *paramSet, struct HksParamSet **outParamSet);
75 };
76 
77 /**
78  * @brief hks plugin proxy
79  */
80 struct HksPluginProxy {
81     int32_t (*hksPluginInit)(struct HksBasicInterface *interfaceInst);
82     void (*hksPluginDestory)(void);
83     int32_t (*hksPluginOnRemoteRequest)(uint32_t code, void *data, void *reply, void *option);
84     int32_t (*hksPluginOnLocalRequest)(uint32_t code, const void *data, void *reply);
85     void (*hksPluginOnReceiveEvent)(const void *eventData);
86 };
87 
88 #ifdef __cplusplus
89 }
90 #endif
91 
92 #endif // HKS_PLUGIN_DEF_H