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

📄 globals.c

📁 IBM的Linux上的PKCS#11实现
💻 C
📖 第 1 页 / 共 3 页
字号:
             lawsuit), then any patent licenses granted by that             Contributor to such Recipient under this Agreement shall             terminate as of the date such litigation is filed. In             addition, If Recipient institutes patent litigation             against any entity (including a cross-claim or             counterclaim in a lawsuit) alleging that the Program             itself (excluding combinations of the Program with other             software or hardware) infringes such Recipient's             patent(s), then such Recipient's rights granted under             Section 2(b) shall terminate as of the date such             litigation is filed.             All Recipient's rights under this Agreement shall             terminate if it fails to comply with any of the material             terms or conditions of this Agreement and does not cure             such failure in a reasonable period of time after becoming             aware of such noncompliance. If all Recipient's rights             under this Agreement terminate, Recipient agrees to cease             use and distribution of the Program as soon as reasonably             practicable. However, Recipient's obligations under this             Agreement and any licenses granted by Recipient relating             to the Program shall continue and survive.              Everyone is permitted to copy and distribute copies of             this Agreement, but in order to avoid inconsistency the             Agreement is copyrighted and may only be modified in the             following manner. The Agreement Steward reserves the right             to publish new versions (including revisions) of this             Agreement from time to time. No one other than the             Agreement Steward has the right to modify this Agreement.             IBM is the initial Agreement Steward. IBM may assign the             responsibility to serve as the Agreement Steward to a             suitable separate entity. Each new version of the             Agreement will be given a distinguishing version number.             The Program (including Contributions) may always be             distributed subject to the version of the Agreement under             which it was received. In addition, after a new version of             the Agreement is published, Contributor may elect to             distribute the Program (including its Contributions) under             the new version. Except as expressly stated in Sections             2(a) and 2(b) above, Recipient receives no rights or             licenses to the intellectual property of any Contributor             under this Agreement, whether expressly, by implication,             estoppel or otherwise. All rights in the Program not             expressly granted under this Agreement are reserved.             This Agreement is governed by the laws of the State of New             York and the intellectual property laws of the United             States of America. No party to this Agreement will bring a             legal action under this Agreement more than one year after             the cause of action arose. Each party waives its rights to             a jury trial in any resulting litigation. *//* (C) COPYRIGHT International Business Machines Corp. 2001,2002          *//***************************************************************************                          Change Log                          ==========       4/25/03    Kapil Sood (kapil@corrent.com)                  Added DH key pair generation and DH shared key derivation                  functions.   ****************************************************************************/#include <pthread.h>#include <stdlib.h>#if (AIX)#include <sys/mman.h>#endif#include "pkcs11types.h"#include "stdll.h"#include "defs.h"#include "host_defs.h"#include "h_extern.h"CK_SLOT_INFO    slot_info;CK_BBOOL        initialized = FALSE;// native_mutex is used to protect C_Initialize.  It gets created when the DLL// is attached, it gets destroyed when the DLL is detached//#ifdef AIXpthread_mutex_t  native_mutex =  PTHREAD_MUTEX_INITIALIZER;MUTEX   pkcs_mutex=PTHREAD_MUTEX_INITIALIZER, obj_list_mutex=PTHREAD_MUTEX_INITIALIZER, sess_list_mutex=PTHREAD_MUTEX_INITIALIZER, login_mutex=PTHREAD_MUTEX_INITIALIZER;#elsepthread_mutex_t  native_mutex ;MUTEX   pkcs_mutex, obj_list_mutex, sess_list_mutex, login_mutex;#if LINUX#if SYSVSEMint   xprocsemid = -1;#endif#endif#endifvoid *xproclock;DL_NODE  *sess_list      = NULL;DL_NODE  *sess_obj_list  = NULL;DL_NODE  *publ_token_obj_list = NULL;DL_NODE  *priv_token_obj_list = NULL;DL_NODE  *object_map     = NULL;CK_STATE  global_login_state = 0;LW_SHM_TYPE *global_shm;CK_ULONG next_session_handle = 1;CK_ULONG next_object_handle = 1;TOKEN_DATA  *nv_token_data = NULL;struct ST_FCN_LIST function_list ;  extern CK_RV LW_Initialize();                                 /* extern CK_RV SC_Initialize             */  extern CK_RV SC_GetFunctionList();                            /* extern CK_RV SC_GetFunctionList        */  extern CK_RV SC_GetTokenInfo();                               /* extern CK_RV SC_GetTokenInfo           */  extern CK_RV SC_GetMechanismList();                           /* extern CK_RV SC_GetMechanismList       */  extern CK_RV SC_GetMechanismInfo();                           /* extern CK_RV SC_GetMechanismInfo       */  extern CK_RV SC_InitToken();                                  /* extern CK_RV SC_InitToken              */  extern CK_RV SC_InitPIN();                                    /* extern CK_RV SC_InitPIN                */  extern CK_RV SC_SetPIN();                                     /* extern CK_RV SC_SetPIN                 */  extern CK_RV SC_OpenSession();                                /* extern CK_RV SC_OpenSession            */  extern CK_RV SC_CloseSession();                               /* extern CK_RV SC_CloseSession           */  extern CK_RV SC_CloseAllSessions();                           /* extern CK_RV SC_CloseAllSessions       */  extern CK_RV SC_GetSessionInfo();                             /* extern CK_RV SC_GetSessionInfo         */  extern CK_RV SC_GetOperationState();                          /* extern CK_RV SC_GetOperationState      */  extern CK_RV SC_SetOperationState();                          /* extern CK_RV SC_SetOperationState      */  extern CK_RV SC_Login();                                      /* extern CK_RV SC_Login                  */  extern CK_RV SC_Logout();                                     /* extern CK_RV SC_Logout                 */  extern CK_RV SC_CreateObject();                               /* extern CK_RV SC_CreateObject           */  extern CK_RV SC_CopyObject();                                 /* extern CK_RV SC_CopyObject             */  extern CK_RV SC_DestroyObject();                              /* extern CK_RV SC_DestroyObject          */  extern CK_RV SC_GetObjectSize();                              /* extern CK_RV SC_GetObjectSize          */  extern CK_RV SC_GetAttributeValue();                          /* extern CK_RV SC_GetAttributeValue      */  extern CK_RV SC_SetAttributeValue();                          /* extern CK_RV SC_SetAttributeValue      */  extern CK_RV SC_FindObjectsInit();                            /* extern CK_RV SC_FindObjectsInit        */  extern CK_RV SC_FindObjects();                                /* extern CK_RV SC_FindObjects            */  extern CK_RV SC_FindObjectsFinal();                           /* extern CK_RV SC_FindObjectsFinal       */  extern CK_RV SC_EncryptInit();                                /* extern CK_RV SC_EncryptInit            */  extern CK_RV SC_Encrypt();                                    /* extern CK_RV SC_Encrypt                */  extern CK_RV SC_EncryptUpdate();                              /* extern CK_RV SC_EncryptUpdate          */  extern CK_RV SC_EncryptFinal();                               /* extern CK_RV SC_EncryptFinal           */  extern CK_RV SC_DecryptInit();                                /* extern CK_RV SC_DecryptInit            */  extern CK_RV SC_Decrypt();                                    /* extern CK_RV SC_Decrypt                */  extern CK_RV SC_DecryptUpdate();                              /* extern CK_RV SC_DecryptUpdate          */  extern CK_RV SC_DecryptFinal();                               /* extern CK_RV SC_DecryptFinal           */  extern CK_RV SC_DigestInit();                                 /* extern CK_RV SC_DigestInit             */  extern CK_RV SC_Digest();                                     /* extern CK_RV SC_Digest                 */  extern CK_RV SC_DigestUpdate();                               /* extern CK_RV SC_DigestUpdate           */  extern CK_RV SC_DigestKey();                                  /* extern CK_RV SC_DigestKey              */  extern CK_RV SC_DigestFinal();                                /* extern CK_RV SC_DigestFinal            */  extern CK_RV SC_SignInit();                                   /* extern CK_RV SC_SignInit               */  extern CK_RV SC_Sign();                                       /* extern CK_RV SC_Sign                   */  extern CK_RV SC_SignUpdate();                                 /* extern CK_RV SC_SignUpdate             */  extern CK_RV SC_SignFinal();                                  /* extern CK_RV SC_SignFinal              */  extern CK_RV SC_SignRecoverInit();                            /* extern CK_RV SC_SignRecoverInit        */  extern CK_RV SC_SignRecover();                                /* extern CK_RV SC_SignRecover            */  extern CK_RV SC_VerifyInit();                                 /* extern CK_RV SC_VerifyInit             */  extern CK_RV SC_Verify();                                     /* extern CK_RV SC_Verify                 */  extern CK_RV SC_VerifyUpdate();                               /* extern CK_RV SC_VerifyUpdate           */  extern CK_RV SC_VerifyFinal();                                /* extern CK_RV SC_VerifyFinal            */  extern CK_RV SC_VerifyRecoverInit();                          /* extern CK_RV SC_VerifyRecoverInit      */  extern CK_RV SC_VerifyRecover();                              /* extern CK_RV SC_VerifyRecover          */  extern CK_RV SC_DigestEncryptUpdate();                        /* extern CK_RV SC_DigestEncryptUpdate    */  extern CK_RV SC_DecryptDigestUpdate();                        /* extern CK_RV SC_DecryptDigestUpdate    */  extern CK_RV SC_SignEncryptUpdate();                          /* extern CK_RV SC_SignEncryptUpdate      */  extern CK_RV SC_DecryptVerifyUpdate();                        /* extern CK_RV SC_DecryptVerifyUpdate    */  extern CK_RV SC_GenerateKey();                                /* extern CK_RV SC_GenerateKey            */  extern CK_RV SC_GenerateKeyPair();                            /* extern CK_RV SC_GenerateKeyPair        */  extern CK_RV SC_WrapKey();                                    /* extern CK_RV SC_WrapKey                */  extern CK_RV SC_UnwrapKey();                                  /* extern CK_RV SC_UnwrapKey              */  extern CK_RV SC_DeriveKey();                                  /* extern CK_RV SC_DeriveKey              */  extern CK_RV SC_SeedRandom();                                 /* extern CK_RV SC_SeedRandom             */  extern CK_RV SC_GenerateRandom();                             /* extern CK_RV SC_GenerateRandom         */  extern CK_RV SC_GetFunctionStatus();                          /* extern CK_RV SC_GetFunctionStatus      */  extern CK_RV SC_CancelFunction();                             /* extern CK_RV SC_CancelFunction         */  extern CK_RV SC_WaitForSlotEvent();                           /* extern CK_RV SC_WaitForSlotEvent       */// ber_rsaEncryption is the AlgorithmIdentifier for RSA including the// NULL parameter (0x05 0x00)//CK_BYTE  ber_AlgIdRSAEncryption[] = { 0x30, 0x0D, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00 };// OBJECT IDENTIFIERs//CK_BYTE  ber_idDSA[]         = { 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x38, 0x04, 0x01 };CK_BYTE  ber_rsaEncryption[] = { 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01 };CK_BYTE  ber_md2WithRSAEncryption[] = { 0x30, 0x0c, 0x06, 0x08, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x02, 0x02, 0x05, 0x00 };CK_BYTE  ber_md4WithRSAEncryption[] = { 0x30, 0x0c, 0x06, 0x08, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x02, 0x04, 0x05, 0x00 };CK_BYTE  ber_md5WithRSAEncryption[] = { 0x30, 0x0c, 0x06, 0x08, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x02, 0x05, 0x05, 0x00 };CK_BYTE  ber_sha1WithRSAEncryption[] = { 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1a, 0x05, 0x00 };CK_ULONG ber_AlgIdRSAEncryptionLen = sizeof(ber_AlgIdRSAEncryption);CK_ULONG ber_rsaEncryptionLen = sizeof(ber_rsaEncryption);CK_ULONG ber_idDSALen = sizeof(ber_idDSA);CK_ULONG ber_md2WithRSAEncryptionLen = sizeof(ber_md2WithRSAEncryption);CK_ULONG ber_md4WithRSAEncryptionLen = sizeof(ber_md4WithRSAEncryption);CK_ULONG ber_md5WithRSAEncryptionLen = sizeof(ber_md5WithRSAEncryption);CK_ULONG ber_sha1WithRSAEncryptionLen= sizeof(ber_sha1WithRSAEncryption);CK_ULONG des_weak_count = 4;CK_ULONG des_semi_weak_count = 12;CK_ULONG des_possibly_weak_count = 48;CK_BYTE  des_weak_keys[4][8] = {   {0x01, 0x01, 0x01, 0x01,  0x01, 0x01, 0x01, 0x01},   {0x1F, 0x1F, 0x1F, 0x1F,  0x0E, 0x0E, 0x0E, 0x0E},   {0xE0, 0xE0, 0xE0, 0xE0,  0xF1, 0xF1, 0xF1, 0xF1},   {0xFE, 0xFE, 0xFE, 0xFE,  0xFE, 0xFE, 0xFE, 0xFE}};CK_BYTE  des_semi_weak_keys[12][8] = {

⌨️ 快捷键说明

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