1 /* Copyright 2018 Intel Corporation, Inc
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
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include <sys/types.h>
22 #include "hwpluginif.h"
24 #if defined(__cplusplus)
28 #ifndef __SSHSM_HW_INFRA_UTIL_H__
29 #define __SSHSM_HW_INFRA_UTIL_H__
31 #define MAX_KEY_DIRS_SUPPORTED 64
33 typedef struct hwpluginentries_s {
34 char so_full_path[256+1];
35 char activate_dir_full_path[256+1];
37 char key_dir_full_path[MAX_KEY_DIRS_SUPPORTED][256+1];
40 int prepareHWPlugin();
41 int loadHWPlugin(char *parent_dir, char *pluginsubdir);
42 int HwPlugin_Initiate_Activate_and_load_keys( hwpluginentries_t *);
43 int load_hw_plugin_and_get_function_pointers(char *,
44 SSHSM_HW_FUNCTIONS_t *funcs);
45 int init_hw_plugin(SSHSM_HW_FUNCTIONS_t *funcs);
46 int activate_hw_plugin(hwpluginentries_t *entries, SSHSM_HW_FUNCTIONS_t *funcs);
47 int load_keys_in_hw_plugin(hwpluginentries_t *entries,
48 SSHSM_HW_FUNCTIONS_t *funcs);
49 int get_all_file_contents(char *dirpath, char starting_char,
50 SSHSM_HW_PLUGIN_ACTIVATE_LOAD_IN_INFO_t *c_buffers );
52 void free_buffers ( SSHSM_HW_PLUGIN_ACTIVATE_LOAD_IN_INFO_t *c_buffers );
53 int program_pkcs11_info (char *dirpath, void *key_handle, SSHSM_HW_PLUGIN_IMPORT_PUBLIC_KEY_INFO_t* ik);
54 int PrepareKeyInSoftHSM(unsigned int slot_id,
55 unsigned char *upin, int upin_len,
56 unsigned char *key_id, int key_id_len,
57 unsigned char *key_label, void *key_handle,
58 SSHSM_HW_PLUGIN_IMPORT_PUBLIC_KEY_INFO_t* ik);
60 int HwInfraSignInit(void *keyHandle, unsigned long mechanism,
61 void* param, int paramLen, void **hwCryptoOpaque);
62 int HwInfraSign(void *keyHandle, unsigned long mechanism,
63 unsigned char *msg, int msg_len, void *hwCryptoOpaque,
64 unsigned char *outsig, int *outsiglen);
65 int HwInfraSignUpdate(void *keyHandle, unsigned long mechanism,
66 unsigned char *msg, int msg_len, void *hwCryptoOpaque);
67 int HwInfraSignFinal(void *keyHandle, unsigned long mechanism,
69 unsigned char *outsig, int *outsiglen);
70 int HwInfraSignCleanup(void *keyHandle, unsigned long mechanism,
71 void *hwCryptoOpaque);
74 #define MAX_PARENT_PATH_NAME 256
77 #define SSHSM_HW_PLUGIN_ERROR_BASE (10000)
79 #define ENVIRONMENT_TOO_LONG (01)
80 #define PLUGIN_PATH_TOO_LONG (02)
81 #define PLUGIN_PATH_OPEN_ERROR (03)
82 #define INCOMPLETE_PLUGIN_DIR (04)
83 #define ALLOCATION_ERROR (05)
84 #define PLUGIN_DL_OPEN_ERROR (06)
85 #define PLUGIN_DL_SYM_ERROR (07)
86 #define PLUGIN_INIT_ERROR (10)
87 #define INVALID_KEY_ERROR (11)
89 #if defined(__cplusplus)
94 #endif /* __SSHSM_HW_INFRA_UTIL_H__ */