• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024-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 /**
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 #define HKS_PROCESS_INFO_INIT_VALUE { {0, NULL}, {0, NULL}, 0, 0, 0, 0 }
28 
29 #include "hks_type.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 /**
36  * @brief hks process info
37  */
38 struct HksProcessInfo {
39     struct HksBlob userId;
40     struct HksBlob processName;
41     int32_t userIdInt;
42     uint32_t uidInt;
43     uint64_t accessTokenId;
44     int32_t pid;
45 };
46 
47 enum LocalRequestCode {
48     CODE_UPGRADE = 1,
49     CODE_FAULT_METRICS = 2,
50     CODE_STATISTICS_METRICS = 3,
51     CODE_SA_WRAP_KEY = 4,
52     CODE_SA_UNWRAP_KEY = 5,
53 };
54 
55 /**
56  * @brief hks base ability interface
57  */
58 struct HksBasicInterface {
59     int32_t (*hksManageStoreKeyBlob)(const struct HksProcessInfo *processInfo, const struct HksParamSet *paramSet,
60         const struct HksBlob *keyAlias, const struct HksBlob *keyBlob, uint32_t storageType);
61     int32_t (*hksManageStoreDeleteKeyBlob)(const struct HksProcessInfo *processInfo, const struct HksParamSet *paramSet,
62         const struct HksBlob *keyAlias, uint32_t storageType);
63     int32_t (*hksManageStoreIsKeyBlobExist)(const struct HksProcessInfo *processInfo,
64         const struct HksParamSet *paramSet, const struct HksBlob *keyAlias, uint32_t storageType);
65     int32_t (*hksManageStoreGetKeyBlob)(const struct HksProcessInfo *processInfo, const struct HksParamSet *paramSet,
66         const struct HksBlob *keyAlias, struct HksBlob *keyBlob, uint32_t storageType);
67     int32_t (*hksManageStoreGetKeyBlobSize)(const struct HksProcessInfo *processInfo,
68         const struct HksParamSet *paramSet, const struct HksBlob *keyAlias,
69         uint32_t *keyBlobSize, uint32_t storageType);
70     int32_t (*hksManageGetKeyCountByProcessName)(const struct HksProcessInfo *processInfo,
71         const struct HksParamSet *paramSet, uint32_t *fileCount);
72 
73     int32_t (*hksGetProcessInfoForIPC)(const uint8_t *context, struct HksProcessInfo *processInfo);
74 
75     int32_t (*appendStorageParamsForGen)(const struct HksProcessInfo *processInfo,
76         const struct HksParamSet *paramSet, struct HksParamSet **outParamSet);
77     int32_t (*appendStorageParamsForUse)(const struct HksParamSet *paramSet,
78         const struct HksProcessInfo *processInfo, struct HksParamSet **outParamSet);
79     int32_t (*appendStorageParamsForQuery)(const struct HksParamSet *paramSet, struct HksParamSet **outParamSet);
80 };
81 
82 /**
83  * @brief hks plugin proxy
84  */
85 struct HksPluginProxy {
86     int32_t (*hksPluginInit)(struct HksBasicInterface *interfaceInst);
87     void (*hksPluginDestory)(void);
88     int32_t (*hksPluginOnRemoteRequest)(uint32_t code, void *data, void *reply, void *option);
89     int32_t (*hksPluginOnLocalRequest)(uint32_t code, const void *data, void *reply);
90     void (*hksPluginOnReceiveEvent)(const void *eventData);
91 };
92 
93 #ifdef __cplusplus
94 }
95 #endif
96 
97 #endif // HKS_PLUGIN_DEF_H