- Ported pkcs11 module to win32.

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@670 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
fabled 2002-06-20 13:16:22 +00:00
parent e4540f826a
commit e2af6a1c8e
7 changed files with 77 additions and 5 deletions

15
src/pkcs11/Makefile.mak Normal file
View File

@ -0,0 +1,15 @@
TOPDIR = ..\..
TARGET = opensc-pkcs11.dll
OBJECTS = pkcs11-global.obj pkcs11-session.obj pkcs11-object.obj misc.obj slot.obj \
secretkey.obj framework-pkcs15.obj
all: $(TARGET)
!INCLUDE $(TOPDIR)\win32\Make.rules.mak
$(TARGET): $(OBJECTS)
link $(LINKFLAGS) /dll /out:$(TARGET) $(OBJECTS) ..\libopensc\opensc.lib winscard.lib

View File

@ -18,10 +18,16 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifdef HAVE_OPENSSL
#define USE_PKCS15_INIT
#endif
#include <stdlib.h>
#include <string.h>
#include "sc-pkcs11.h"
#ifdef USE_PKCS15_INIT
#include "opensc/pkcs15-init.h"
#endif
#define MAX_CACHE_PIN 32
struct pkcs15_slot_data {
@ -531,6 +537,7 @@ static CK_RV pkcs15_change_pin(struct sc_pkcs11_card *p11card,
return sc_to_cryptoki_error(rc, p11card->reader);
}
#ifdef USE_PKCS15_INIT
static CK_RV pkcs15_init_pin(struct sc_pkcs11_card *p11card,
struct sc_pkcs11_slot *slot,
CK_CHAR_PTR pPin, CK_ULONG ulPinLen)
@ -880,6 +887,7 @@ static CK_RV pkcs15_create_object(struct sc_pkcs11_card *p11card,
sc_pkcs15init_unbind(profile);
return rv;
}
#endif
struct sc_pkcs11_framework_ops framework_pkcs15 = {
pkcs15_bind,
@ -891,9 +899,14 @@ struct sc_pkcs11_framework_ops framework_pkcs15 = {
pkcs15_login,
pkcs15_logout,
pkcs15_change_pin,
NULL, /* init_token */
NULL, /* init_token */
#ifdef USE_PKCS15_INIT
pkcs15_init_pin,
pkcs15_create_object
pkcs15_create_object
#else
NULL,
NULL
#endif
};
/*

View File

@ -18,10 +18,16 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifdef HAVE_OPENSSL
#define USE_PKCS15_INIT
#endif
#include <stdlib.h>
#include <string.h>
#include "sc-pkcs11.h"
#ifdef USE_PKCS15_INIT
#include "pkcs15-init.h"
#endif
/*
* Deal with uninitialized cards

View File

@ -204,7 +204,7 @@ extern "C" {
* #endif
*/
#include "unix.h"
/* #include "unix.h" */
/* All the various Cryptoki types and #define'd values are in the
* file pkcs11t.h. */

24
src/pkcs11/rsaref/win32.h Normal file
View File

@ -0,0 +1,24 @@
#ifndef WIN32_H
#define WIN32_H
#define CK_PTR *
#define CK_DEFINE_FUNCTION(returnType, name) \
returnType __declspec(dllexport) name
#define CK_DECLARE_FUNCTION(returnType, name) \
returnType __declspec(dllimport) name
#define CK_DECLARE_FUNCTION_POINTER(returnType, name) \
returnType __declspec(dllimport) (* name)
#define CK_CALLBACK_FUNCTION(returnType, name) \
returnType (* name)
#ifndef NULL_PTR
#define NULL_PTR 0
#endif
#endif

View File

@ -30,7 +30,16 @@
#include <opensc/opensc.h>
#include <opensc/pkcs15.h>
#include <opensc/log.h>
#ifndef _WIN32
#include "rsaref/unix.h"
#include "rsaref/pkcs11.h"
#else
#include "rsaref/win32.h"
#pragma pack(push, cryptoki, 1)
#include "rsaref/pkcs11.h"
#pragma pack(pop, cryptoki)
#endif
#ifdef __cplusplus
extern "C" {

View File

@ -18,15 +18,20 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifdef HAVE_OPENSSL
#define USE_PKCS15_INIT
#endif
#include <string.h>
#include "sc-pkcs11.h"
static struct sc_pkcs11_framework_ops *frameworks[] = {
&framework_pkcs15,
#ifdef USE_PKCS15_INIT
/* This should be the last framework, because it
* will assume the card is blank and try to initialize it */
&framework_pkcs15init,
&framework_pkcs15init,
#endif
NULL
};