• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef HKS_MESSAGE_HANDLER_H
17 #define HKS_MESSAGE_HANDLER_H
18 
19 #include "huks_service_ipc_interface_code.h"
20 
21 #include "hks_ipc_service.h"
22 #include "hks_type.h"
23 
24 typedef void (*HksIpcHandlerFuncProc)(const struct HksBlob *msg, const uint8_t *context);
25 
26 struct HksIpcEntryPoint {
27     enum HksIpcInterfaceCode msgId;
28     HksIpcHandlerFuncProc handler;
29 };
30 
31 const struct HksIpcEntryPoint HKS_IPC_MESSAGE_HANDLER[] = {
32     { HKS_MSG_GEN_KEY, HksIpcServiceGenerateKey },
33     { HKS_MSG_IMPORT_KEY, HksIpcServiceImportKey },
34     { HKS_MSG_EXPORT_PUBLIC_KEY, HksIpcServiceExportPublicKey },
35     { HKS_MSG_IMPORT_WRAPPED_KEY, HksIpcServiceImportWrappedKey },
36     { HKS_MSG_DELETE_KEY, HksIpcServiceDeleteKey },
37     { HKS_MSG_GET_KEY_PARAMSET, HksIpcServiceGetKeyParamSet },
38     { HKS_MSG_KEY_EXIST, HksIpcServiceKeyExist },
39     { HKS_MSG_GENERATE_RANDOM, HksIpcServiceGenerateRandom },
40     { HKS_MSG_SIGN, HksIpcServiceSign },
41     { HKS_MSG_VERIFY, HksIpcServiceVerify },
42     { HKS_MSG_ENCRYPT, HksIpcServiceEncrypt },
43     { HKS_MSG_DECRYPT, HksIpcServiceDecrypt },
44     { HKS_MSG_AGREE_KEY, HksIpcServiceAgreeKey },
45     { HKS_MSG_DERIVE_KEY, HksIpcServiceDeriveKey },
46     { HKS_MSG_MAC, HksIpcServiceMac },
47     { HKS_MSG_GET_KEY_INFO_LIST, HksIpcServiceGetKeyInfoList },
48     { HKS_MSG_LIST_ALIASES, HksIpcServiceListAliases },
49     { HKS_MSG_RENAME_KEY_ALIAS, HksIpcServiceRenameKeyAlias },
50     { HKS_MSG_CHANGE_STORAGE_LEVEL, HksIpcChangeStorageLevel },
51     { HKS_MSG_WRAP_KEY, HksIpcWrapKey },
52     { HKS_MSG_UNWRAP_KEY, HksIpcUnwrapKey },
53 };
54 
55 typedef void (*HksIpcThreeStageHandlerFuncProc)(const struct HksBlob *msg, struct HksBlob *outData,
56     const uint8_t *context);
57 
58 struct HksIpcThreeStagePoint {
59     enum HksIpcInterfaceCode msgId;
60     HksIpcThreeStageHandlerFuncProc handler;
61 };
62 
63 const struct HksIpcThreeStagePoint HKS_IPC_THREE_STAGE_HANDLER[] = {
64     { HKS_MSG_INIT, HksIpcServiceInit },
65     { HKS_MSG_UPDATE, HksIpcServiceUpdate },
66     { HKS_MSG_FINISH, HksIpcServiceFinish },
67     { HKS_MSG_ABORT, HksIpcServiceAbort },
68 };
69 
70 void HksIpcErrorResponse(const uint8_t *context);
71 
72 #endif