⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 slotmgr.h

📁 IBM的Linux上的PKCS#11实现
💻 H
📖 第 1 页 / 共 2 页
字号:
#include <linux/limits.h>#endif#include <local_types.h>#include <pthread.h>#ifdef PKCS64#include <sys/mman.h>#endif#ifndef _SLOTMGR_H#define _SLOTMGR_H#ifdef DEV    #define TOK_PATH  "/usr/sbin/pkcsslotd"#else    #define TOK_PATH  "/usr/sbin/pkcsslotd"#endif /* DEV */#if (SPINXPL)#define  XPL_FILE  "/tmp/.pkapi_xpk"#endif#define PID_FILE_PATH  "/etc/pkcs11/.slotpid"#ifndef CK_BOOL    #define CK_BOOL  CK_BBOOL#endif /* CK_BOOL */#ifndef TEST_COND_VARS    #define TEST_COND_VARS 0#endif /* TEST_COND_VARS */#define NUMBER_SLOTS_MANAGED  32#define NUMBER_PROCESSES_ALLOWED  1000//// Per Process Data structure// one entry in the table is grabbed by each process// when it attaches to the shared memory and released // when the C_Finalize is called.typedef struct{   pthread_mutex_t  proc_mutex;   pthread_cond_t   proc_slot_cond;    CK_BOOL    inuse;  // flag indicating if the entry is in use   pid_t    proc_id; // This could also be used to indicate inuse. however                     // we will actualy use it to provide a check for a bad                     // process which did not C_finalize and remove itself                     // properly.   uint32   slotmap; // Bit map of the slots with events App uses this                     // in the C_WaitForSlotEvent call     uint8    blocking;  // Flag to use if a thread is blocking on the condition                       // variable Used by C_Finalize to wake up the    uint8    error ;     // indication of an error causing the thread sleeping on the                         // condition variable to wakeup.   uint32   slot_session_count[NUMBER_SLOTS_MANAGED];  // Per process session                        // count for garbage collection clean up of the global                        // session count.   time_t   reg_time; // Time application registered} Slot_Mgr_Proc_t;//// Shared Memory Region of Slot information//// Slot info structure which contains the PKCS11 CK_SLOT_INFO// as well as the local informationtypedef struct{   CK_SLOT_ID          slot_number;   CK_BOOL          present;   CK_SLOT_INFO  pk_slot;   char          dll_location[PATH_MAX+1];   // location of slot management  DLL   char          slot_init_fcn[PATH_MAX+1];  // function to call to initialize the token in the slot   char          correlator[PATH_MAX+1];     // Slot DLL Slotindex to dev correlation string   uint32         global_sessions; // counter of the total sessions on a token in                                   // a slot.  Used for quick check of no                                   // sessions}Slot_Info_t;#ifdef PKCS64/* * Constant size types and structures to allow 32-bit daemon to work with  * 64-bit libraries. *  * Note - ulong long is 8 bytes for both 32-bit and 64-bit applications. * */typedef unsigned long long pid_t_64;typedef unsigned long long time_t_64;typedef unsigned long long CK_SLOT_ID_64;typedef unsigned long long CK_FLAGS_64;typedef struct CK_INFO_64 {  CK_VERSION    cryptokiVersion;     /* Cryptoki interface ver */  CK_CHAR       manufacturerID[32];  /* blank padded */  CK_FLAGS_64   flags;               /* must be zero */  /* libraryDescription and libraryVersion are new for v2.0 */  CK_CHAR       libraryDescription[32];  /* blank padded */  CK_VERSION    libraryVersion;          /* version of library */} CK_INFO_64;  typedef CK_INFO_64 CK_PTR CK_INFO_PTR_64;typedef struct CK_SLOT_INFO_64 {  CK_CHAR       slotDescription[64];  /* blank padded */  CK_CHAR       manufacturerID[32];   /* blank padded */  CK_FLAGS_64   flags;  /* hardwareVersion and firmwareVersion are new for v2.0 */  CK_VERSION    hardwareVersion;  /* version of hardware */  CK_VERSION    firmwareVersion;  /* version of firmware */} CK_SLOT_INFO_64;       typedef struct Slot_Mgr_Proc_t_64 {#if AIX      msemaphore      slt_mutex;#elif SYSVSEM      int                slt_mutex;#elif PTHREADXPL     pthread_mutex_t       slt_mutex;#elif POSIXSEM#error "Need to implement this"#elif NOXPROCLOCK     int       slt_mutex; // unused.#elif SPINXPL     unsigned int   slt_mutex;#endif  // pthread_cond_t   proc_slot_cond;      CK_BOOL    inuse;  // flag indicating if the entry is in use   pid_t_64  proc_id;// This could also be used to indicate inuse. however                     // we will actualy use it to provide a check for a bad                     // process which did not C_finalize and remove itself                     // properly.   uint32   slotmap; // Bit map of the slots with events App uses this                     // in the C_WaitForSlotEvent call     uint8    blocking;  // Flag to use if a thread is blocking on the condition                       // variable Used by C_Finalize to wake up the    uint8    error ;     // indication of an error causing the thread sleeping on the                         // condition variable to wakeup.   uint32   slot_session_count[NUMBER_SLOTS_MANAGED];  // Per process session                        // count for garbage collection clean up of the global                        // session count.   time_t_64   reg_time; // Time application registered} Slot_Mgr_Proc_t_64;//// Shared Memory Region of Slot information//// Slot info structure which contains the PKCS11 CK_SLOT_INFO// as well as the local informationtypedef struct{   CK_SLOT_ID_64    slot_number;   CK_BOOL          present;   CK_SLOT_INFO_64  pk_slot;   char          dll_location[PATH_MAX+1];   // location of slot management  DLL   char          slot_init_fcn[PATH_MAX+1];  // function to call to initialize the token in the slot   char          correlator[PATH_MAX+1];     // Slot DLL Slotindex to dev correlation string   uint32         global_sessions; // counter of the total sessions on a token in                                   // a slot.  Used for quick check of no                                   // sessions}Slot_Info_t_64;typedef struct {     /*************************************************************   *    Mutexes for access and control of the structures.   *    When a process wants to register with the slot mgr   *    it will have to get the mutex on the shared memory region   *    and then finds an empty slot in the process table to use.   *    This simplifies the management capabilities.      *************************************************************/#if AIX      msemaphore      slt_mutex;#elif SYSVSEM      int                slt_mutex;#elif PTHREADXPL     pthread_mutex_t       slt_mutex;#elif POSIXSEM#error "Need to implement this"#elif NOXPROCLOCK     int       slt_mutex; // unused.#elif SPINXPL     unsigned int   slt_mutex;#endif     /* Information that the API calls will use. */  uint8                 num_slots;  CK_INFO_64            ck_info;  Slot_Info_t_64        slot_info[NUMBER_SLOTS_MANAGED];  Slot_Mgr_Proc_t_64    proc_table[NUMBER_PROCESSES_ALLOWED];} Slot_Mgr_Shr_t;#elsetypedef struct {     /*************************************************************   *    Mutexes for access and control of the structures.   *    When a process wants to register with the slot mgr   *    it will have to get the mutex on the shared memory region   *    and then finds an empty slot in the process table to use.   *    This simplifies the management capabilities.      *************************************************************/#if AIX   msemaphore      slt_mutex;#elif SYSVSEM   int                slt_mutex;#elif PTHREADXPL  pthread_mutex_t       slt_mutex;#elif POSIXSEM#error "Need to implement this"#elif NOXPROCLOCK  int       slt_mutex; // unused.#elif SPINXPL  unsigned int   slt_mutex;#endif   /* Information that the API calls will use. */  uint8                 num_slots;  CK_INFO               ck_info;  Slot_Info_t           slot_info[NUMBER_SLOTS_MANAGED];  Slot_Mgr_Proc_t       proc_table[NUMBER_PROCESSES_ALLOWED];} Slot_Mgr_Shr_t;#endif// Loging type constants//#define ERROR 1#define INFO  2//  Call to populate the shared memory#define STR "01234567890123456789012345678901"#define MFG "IBM                             "#define LIB "Meta PKCS11 LIBRARY             "#define MAJOR_V   1#define MINOR_V   2#define CRYPTOKI_API_MAJOR_V 0x2#define CRYPTOKI_API_MINOR_V 0xb#define LIB_MAJOR_V 1#define LIB_MINOR_V 4#define RESTART_SYS_CALLS 1//// Function prototypes///* shmem.c */int                    CreateSharedMemory ( void );int                    AttachToSharedMemeory ( void );int                    InitSharedMemory ( Slot_Mgr_Shr_t *sp );void                   DetachFromSharedMemory ( void );void                   DestroySharedMemory ( void );/* mutex.c */int                    InitializeMutexes ( void );int                    DestroyMutexes ( void );/* signal.c */void                   slotdSIGTERMhandler ( int signum );int                    SetupSignalHandlers ( void );void                   slotdGenericSignalHandler( int Signal );#endif /* _SLOTMGR_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -