cryptool.cpp
资源名称:pkcs11.rar [点击查看]
上传用户:filter2008
上传日期:2013-02-01
资源大小:101k
文件大小:31k
源码类别:
CA认证
开发平台:
C/C++
- /****************************************************************************
- * library : pkcs_csp.dll
- * Purpose : It is a cryptographic service provider which is an independent
- * software module that actually performs cryptography algorithms for
- * authentication, encoding, and encryption.
- * This DLL can be interfaced on any PKCS#11 module.
- *
- * Copyright (C) 2003 Ilex Syst鑝es Informatiques
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Contact :
- * Ilex
- * 51 boulevard Voltaire
- * 92600 Asni鑢es-sur-Seine
- * pkizy@ilex.fr
- *
- * Author: Delouvrier Antoine
- *
- *******************************************************************************/
- /*
- %----------------------------------------------------------------------------
- % PROJECT : CSP_PKCS
- %
- % MODULE : cryptool
- %
- % VERSION : 1.00
- %
- % FILE : cryptool.cpp
- %
- % cryptool: Functions allowing various accesses to the PKCS#11
- %----------------------------------------------------------------------------
- % Version 1.00
- %
- % CPX-31/03/2003-Creation
- %----------------------------------------------------------------------------
- */
- /*
- % Libraries ANSI or system
- %------------------------------
- */
- #include<windows.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- /*
- % HEADER Files include
- %-----------------------
- */
- #include "cryptool.h"
- #define CK_API __stdcall
- typedef void * SYS_HANDLE;
- typedef int ( CK_API *CK_PFUNCTION)();
- SYS_HANDLE dllPtr;
- int traceLevel=0;
- extern bool already_initialized;
- extern int pkcsInitialized;
- /*
- %--------------------------------------------------------------------------
- % init
- %
- % init is used to initialize DLL PKCS
- %
- %
- % Parameters of entry :
- % OUT pFunctionList
- %
- % return : CKR_OK if the operation occurred well, rc if not
- %---------------------------------------------------------------------------
- */
- CK_RV
- init(CK_FUNCTION_LIST_PTR CK_PTR pFunctionList){
- CK_RV rc; // Return Code
- CK_C_GetFunctionList pFuncList;
- TRACE(__LINE__,"Cryptool init BEGIN",NULL);
- /* Open the PKCS11 API shared library*/
- int l = 50;
- char buf[50 + 1];
- int rl;
- rl = GetPrivateProfileString( SECTION_PKCS_NAME, KEY_PKCS_NAME ,"",(char *) buf, 51,CSP_PKCS11_INI);
- if(rl==0){
- TRACE(__LINE__," NO csp_pkcs.ini file found(%d)",rl);
- return CKR_CANCEL;
- }
- dllPtr = LoadLibrary(buf);
- if (!dllPtr) {
- TRACE(__LINE__,"LoadLibrary error, Le Kit Pkcs#11 demand閑 n'est pas install