core: reanimate the sc_dlopen API for dynamic loading
* shift libpkcs11 from src/pkcs11 to src/common as it is not used to implement the OpenSC PKCS#11 module * invent a "libscdl" mini library that implements either libltdl based dynamic loading or uses native interfaces * drop hard requirement for libltl to build OpenSC * native Windows build does not need libltdl any more * specify CNGSDK include dir to find cardmod.h. CNGSDK only registers with a handful of compilers Deals with #323 git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5201 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
53dd2ceafa
commit
ffb46d2573
11
configure.ac
11
configure.ac
|
@ -264,23 +264,20 @@ AC_CHECK_LIB(
|
|||
]
|
||||
)
|
||||
|
||||
dnl check for libltdl. If libltdl is not found, native dlopen/LoadLibrary is used
|
||||
AC_ARG_VAR([LTLIB_CFLAGS], [C compiler flags for libltdl])
|
||||
AC_ARG_VAR([LTLIB_LIBS], [linker flags for libltdl])
|
||||
if test -z "${LTLIB_LIBS}"; then
|
||||
AC_CHECK_LIB(
|
||||
[ltdl],
|
||||
[lt_dlopen],
|
||||
[LTLIB_LIBS="-lltdl"],
|
||||
[AC_MSG_ERROR([ltdl not found, please install libltdl and/or libtool])]
|
||||
[LTLIB_LIBS="-lltdl"]
|
||||
)
|
||||
fi
|
||||
|
||||
saved_CFLAGS="${CFLAGS}"
|
||||
CFLAGS="${CFLAGS} ${LTLIB_CFLAGS}"
|
||||
AC_CHECK_HEADER(
|
||||
[ltdl.h],
|
||||
,
|
||||
[AC_MSG_ERROR([ltdl.h not found, please install libltdl and/or libtool])]
|
||||
)
|
||||
AC_CHECK_HEADERS([ltdl.h])
|
||||
CFLAGS="${saved_CFLAGS}"
|
||||
|
||||
if test "${WIN32}" = "no"; then
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
|
||||
EXTRA_DIST = Makefile.mak
|
||||
|
||||
noinst_LTLIBRARIES = libcompat.la
|
||||
noinst_LTLIBRARIES = libcompat.la libpkcs11.la libscdl.la
|
||||
noinst_PROGRAMS = compat_getopt_main
|
||||
dist_noinst_DATA = \
|
||||
README.compat_getopt ChangeLog.compat_getopt \
|
||||
|
@ -9,13 +9,18 @@ dist_noinst_DATA = \
|
|||
compat_getopt_main.c \
|
||||
README.compat_strlcpy compat_strlcpy.3
|
||||
|
||||
INCLUDES = -I$(top_builddir)/src
|
||||
|
||||
libcompat_la_SOURCES = \
|
||||
compat_dummy.c \
|
||||
compat_strlcat.h compat_strlcat.c \
|
||||
compat_strlcpy.h compat_strlcpy.c \
|
||||
compat_getpass.h compat_getpass.c \
|
||||
compat_getopt.h compat_getopt.c \
|
||||
simclist.c simclist.h
|
||||
simclist.c simclist.h libscdl.c
|
||||
|
||||
compat_getopt_main_LDADD = libcompat.la
|
||||
|
||||
libpkcs11_la_SOURCES = libpkcs11.c libscdl.c
|
||||
|
||||
libscdl_la_SOURCES = libscdl.c
|
||||
|
|
|
@ -1,12 +1,17 @@
|
|||
TOPDIR = ..\..
|
||||
|
||||
TARGET = common.lib
|
||||
OBJECTS = compat_getpass.obj compat_getopt.obj compat_strlcpy.obj compat_strlcat.obj simclist.obj
|
||||
COMMON_OBJECTS = compat_getpass.obj compat_getopt.obj compat_strlcpy.obj compat_strlcat.obj simclist.obj
|
||||
|
||||
all: $(TARGET)
|
||||
all: common.lib libpkcs11.lib libscdl.lib
|
||||
|
||||
$(TARGET): $(OBJECTS)
|
||||
lib /nologo /machine:ix86 /out:$(TARGET) $(OBJECTS)
|
||||
common.lib: $(COMMON_OBJECTS)
|
||||
lib /nologo /machine:ix86 /out:common.lib $(COMMON_OBJECTS)
|
||||
|
||||
libpkcs11.lib: libpkcs11.obj libscdl.obj
|
||||
lib /nologo /machine:ix86 /out:libpkcs11.lib libpkcs11.obj libscdl.obj
|
||||
|
||||
libscdl.lib: libscdl.obj
|
||||
lib /nologo /machine:ix86 /out:libscdl.lib libscdl.obj
|
||||
|
||||
!INCLUDE $(TOPDIR)\win32\Make.rules.mak
|
||||
|
||||
|
|
|
@ -10,15 +10,17 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ltdl.h>
|
||||
|
||||
#include "sc-pkcs11.h"
|
||||
#include "pkcs11/pkcs11.h"
|
||||
|
||||
#include "common/libscdl.h"
|
||||
#include "common/libpkcs11.h"
|
||||
|
||||
#define MAGIC 0xd00bed00
|
||||
|
||||
struct sc_pkcs11_module {
|
||||
unsigned int _magic;
|
||||
lt_dlhandle handle;
|
||||
void *handle;
|
||||
};
|
||||
typedef struct sc_pkcs11_module sc_pkcs11_module_t;
|
||||
|
||||
|
@ -31,23 +33,23 @@ C_LoadModule(const char *mspec, CK_FUNCTION_LIST_PTR_PTR funcs)
|
|||
{
|
||||
sc_pkcs11_module_t *mod;
|
||||
CK_RV rv, (*c_get_function_list)(CK_FUNCTION_LIST_PTR_PTR);
|
||||
|
||||
#ifdef HAVE_LTDL_H
|
||||
lt_dlinit();
|
||||
|
||||
#endif
|
||||
mod = calloc(1, sizeof(*mod));
|
||||
mod->_magic = MAGIC;
|
||||
|
||||
if (mspec == NULL)
|
||||
mspec = PKCS11_DEFAULT_MODULE_NAME;
|
||||
mod->handle = lt_dlopen(mspec);
|
||||
return NULL;
|
||||
mod->handle = sc_dlopen(mspec);
|
||||
if (mod->handle == NULL) {
|
||||
fprintf(stderr, "lt_dlopen failed: %s\n", lt_dlerror());
|
||||
fprintf(stderr, "sc_dlopen failed: %s\n", sc_dlerror());
|
||||
goto failed;
|
||||
}
|
||||
|
||||
/* Get the list of function pointers */
|
||||
c_get_function_list = (CK_RV (*)(CK_FUNCTION_LIST_PTR_PTR))
|
||||
lt_dlsym(mod->handle, "C_GetFunctionList");
|
||||
sc_dlsym(mod->handle, "C_GetFunctionList");
|
||||
if (!c_get_function_list)
|
||||
goto failed;
|
||||
rv = c_get_function_list(funcs);
|
||||
|
@ -73,7 +75,7 @@ C_UnloadModule(void *module)
|
|||
if (!mod || mod->_magic != MAGIC)
|
||||
return CKR_ARGUMENTS_BAD;
|
||||
|
||||
if (lt_dlclose(mod->handle) < 0)
|
||||
if (sc_dlclose(mod->handle) < 0)
|
||||
return CKR_FUNCTION_FAILED;
|
||||
|
||||
memset(mod, 0, sizeof(*mod));
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* libpkcs11.h: Function definitions for the PKCS#11 module loading minilibrary
|
||||
*
|
||||
* Copyright (C) 2010 Martin Paljak <martin@paljak.pri.ee>
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
void *C_LoadModule(const char *name, CK_FUNCTION_LIST_PTR_PTR);
|
||||
CK_RV C_UnloadModule(void *module);
|
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
* libscdl.c: wrappers for dlfcn() interfaces
|
||||
*
|
||||
* Copyright (C) 2010 Martin Paljak <martin@martinpaljak.net>
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef HAVE_LTDL_H
|
||||
#include <ltdl.h>
|
||||
/* libltdl is present, pass all calls to it */
|
||||
|
||||
void *sc_dlopen(const char *filename)
|
||||
{
|
||||
return (void *)lt_dlopen(filename);
|
||||
}
|
||||
|
||||
void *sc_dlsym(void *handle, const char *symbol)
|
||||
{
|
||||
return lt_dlsym((lt_dlhandle)handle, symbol);
|
||||
}
|
||||
|
||||
const char *sc_dlerror()
|
||||
{
|
||||
return lt_dlerror();
|
||||
}
|
||||
|
||||
int sc_dlclose(void *handle)
|
||||
{
|
||||
return lt_dlclose((lt_dlhandle)handle);
|
||||
}
|
||||
|
||||
#else
|
||||
/* Small wrappers for native functions, bypassing libltdl */
|
||||
#ifdef _WIN32
|
||||
/* Use Windows calls */
|
||||
void *sc_dlopen(const char *filename)
|
||||
{
|
||||
return (void *)LoadLibrary(filename);
|
||||
}
|
||||
|
||||
void *sc_dlsym(void *handle, const char *symbol)
|
||||
{
|
||||
return GetProcAddress(handle, symbol);
|
||||
}
|
||||
|
||||
const char *sc_dlerror()
|
||||
{
|
||||
return "LoadLibrary/GetProcAddress failed";
|
||||
}
|
||||
|
||||
int sc_dlclose(void *handle)
|
||||
{
|
||||
return FreeLibrary(handle);
|
||||
}
|
||||
|
||||
#elif defined(HAVE_DLFCN_H)
|
||||
#include <dlfcn.h>
|
||||
/* Use native interfaces */
|
||||
void *sc_dlopen(const char *filename)
|
||||
{
|
||||
return (void *)dlopen(filename, RTLD_LAZY);
|
||||
}
|
||||
|
||||
void *sc_dlsym(void *handle, const char *symbol)
|
||||
{
|
||||
return dlsym(handle, symbol);
|
||||
}
|
||||
|
||||
const char *sc_dlerror()
|
||||
{
|
||||
return dlerror();
|
||||
}
|
||||
|
||||
int sc_dlclose(void *handle)
|
||||
{
|
||||
return dlclose(handle);
|
||||
}
|
||||
|
||||
#else
|
||||
/* Dynamic loading is not available */
|
||||
void *sc_dlopen(const char *filename)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *sc_dlsym(void *handle, const char *symbol)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *sc_dlerror()
|
||||
{
|
||||
return "dlopen() functionality not available";
|
||||
}
|
||||
|
||||
int sc_dlclose(void *handle)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* libscdl.h: Function definitions for the dynamic loading minilibrary.
|
||||
*
|
||||
* Copyright (C) 2010 Martin Paljak <martin@paljak.pri.ee>
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
void *sc_dlopen(const char *filename);
|
||||
void *sc_dlsym(void *handle, const char *symbol);
|
||||
int sc_dlclose(void *handle);
|
||||
const char *sc_dlerror();
|
|
@ -40,7 +40,7 @@ opensc.dll: $(OBJECTS) ..\scconf\scconf.lib ..\common\common.lib ..\pkcs15init\p
|
|||
echo LIBRARY $* > $*.def
|
||||
echo EXPORTS >> $*.def
|
||||
type lib$*.exports >> $*.def
|
||||
link $(LINKFLAGS) /dll /def:$*.def /implib:$*.lib /out:opensc.dll $(OBJECTS) ..\scconf\scconf.lib ..\common\common.lib ..\pkcs15init\pkcs15init.lib winscard.lib $(OPENSSL_LIB) $(ZLIB_LIB) gdi32.lib $(LIBLTDL_LIB) advapi32.lib ws2_32.lib
|
||||
link $(LINKFLAGS) /dll /def:$*.def /implib:$*.lib /out:opensc.dll $(OBJECTS) ..\scconf\scconf.lib ..\common\common.lib ..\pkcs15init\pkcs15init.lib winscard.lib $(OPENSSL_LIB) $(ZLIB_LIB) gdi32.lib advapi32.lib ws2_32.lib
|
||||
if EXIST opensc.dll.manifest mt -manifest opensc.dll.manifest -outputresource:opensc.dll;2
|
||||
|
||||
opensc_a.lib: $(OBJECTS) ..\scconf\scconf.lib ..\common\common.lib ..\pkcs15init\pkcs15init.lib
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
#include <limits.h>
|
||||
#include <ltdl.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
|
@ -291,7 +290,7 @@ static const char *find_library(sc_context_t *ctx, const char *name)
|
|||
static void *load_dynamic_driver(sc_context_t *ctx, void **dll, const char *name)
|
||||
{
|
||||
const char *version, *libname;
|
||||
lt_dlhandle handle;
|
||||
void *handle;
|
||||
void *(*modinit)(const char *) = NULL;
|
||||
void *(**tmodi)(const char *) = &modinit;
|
||||
const char *(*modversion)(void) = NULL;
|
||||
|
@ -304,18 +303,18 @@ static void *load_dynamic_driver(sc_context_t *ctx, void **dll, const char *name
|
|||
libname = find_library(ctx, name);
|
||||
if (libname == NULL)
|
||||
return NULL;
|
||||
handle = lt_dlopen(libname);
|
||||
handle = sc_dlopen(libname);
|
||||
if (handle == NULL) {
|
||||
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Module %s: cannot load %s library: %s", name, libname, lt_dlerror());
|
||||
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Module %s: cannot load %s library: %s", name, libname, sc_dlerror());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* verify correctness of module */
|
||||
*(void **)tmodi = lt_dlsym(handle, "sc_module_init");
|
||||
*(void **)tmodv = lt_dlsym(handle, "sc_driver_version");
|
||||
*(void **)tmodi = sc_dlsym(handle, "sc_module_init");
|
||||
*(void **)tmodv = sc_dlsym(handle, "sc_driver_version");
|
||||
if (modinit == NULL || modversion == NULL) {
|
||||
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "dynamic library '%s' is not a OpenSC module",libname);
|
||||
lt_dlclose(handle);
|
||||
sc_dlclose(handle);
|
||||
return NULL;
|
||||
}
|
||||
/* verify module version */
|
||||
|
@ -323,7 +322,7 @@ static void *load_dynamic_driver(sc_context_t *ctx, void **dll, const char *name
|
|||
/* XXX: We really need to have ABI version for each interface */
|
||||
if (version == NULL || strncmp(version, PACKAGE_VERSION, strlen(PACKAGE_VERSION)) != 0) {
|
||||
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,"dynamic library '%s': invalid module version",libname);
|
||||
lt_dlclose(handle);
|
||||
sc_dlclose(handle);
|
||||
return NULL;
|
||||
}
|
||||
*dll = handle;
|
||||
|
@ -642,12 +641,14 @@ int sc_context_create(sc_context_t **ctx_out, const sc_context_param_t *parm)
|
|||
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "==================================="); /* first thing in the log */
|
||||
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "opensc version: %s", sc_get_version());
|
||||
|
||||
/* initialize ltdl */
|
||||
#ifdef HAVE_LIBLTL_H
|
||||
/* initialize ltdl, if available. See scdl.c for more information */
|
||||
if (lt_dlinit() != 0) {
|
||||
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "lt_dlinit failed");
|
||||
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "lt_dlinit() failed");
|
||||
sc_release_context(ctx);
|
||||
return SC_ERROR_OUT_OF_MEMORY;
|
||||
return SC_ERROR_INTERNAL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_PCSC
|
||||
ctx->reader_driver = sc_get_pcsc_driver();
|
||||
|
@ -729,7 +730,7 @@ int sc_release_context(sc_context_t *ctx)
|
|||
if (drv->atr_map)
|
||||
_sc_free_atr(ctx, drv);
|
||||
if (drv->dll)
|
||||
lt_dlclose(drv->dll);
|
||||
sc_dlclose(drv->dll);
|
||||
}
|
||||
if (ctx->preferred_language != NULL)
|
||||
free(ctx->preferred_language);
|
||||
|
|
|
@ -36,6 +36,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
#include "common/simclist.h"
|
||||
#include "common/libscdl.h"
|
||||
#include "libopensc/opensc.h"
|
||||
#include "libopensc/log.h"
|
||||
#include "libopensc/cards.h"
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <ltdl.h>
|
||||
|
||||
#include "internal.h"
|
||||
#include "asn1.h"
|
||||
|
@ -209,7 +208,7 @@ static int parse_emu_block(sc_pkcs15_card_t *p15card, scconf_block *conf)
|
|||
sc_card_t *card = p15card->card;
|
||||
sc_context_t *ctx = card->ctx;
|
||||
sc_pkcs15emu_opt_t opts;
|
||||
lt_dlhandle handle = NULL;
|
||||
void *handle = NULL;
|
||||
int (*init_func)(sc_pkcs15_card_t *);
|
||||
int (*init_func_ex)(sc_pkcs15_card_t *, sc_pkcs15emu_opt_t *);
|
||||
int r, force = 0;
|
||||
|
@ -246,14 +245,14 @@ static int parse_emu_block(sc_pkcs15_card_t *p15card, scconf_block *conf)
|
|||
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Loading %s\n", module_name);
|
||||
|
||||
/* try to open dynamic library */
|
||||
handle = lt_dlopen(module_name);
|
||||
handle = sc_dlopen(module_name);
|
||||
if (!handle) {
|
||||
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "unable to open dynamic library '%s': %s\n",
|
||||
module_name, lt_dlerror());
|
||||
module_name, sc_dlerror());
|
||||
return SC_ERROR_INTERNAL;
|
||||
}
|
||||
/* try to get version of the driver/api */
|
||||
get_version = (const char *(*)(void)) lt_dlsym(handle, "sc_driver_version");
|
||||
get_version = (const char *(*)(void)) sc_dlsym(handle, "sc_driver_version");
|
||||
if (!get_version || strcmp(get_version(), "0.9.3") < 0) {
|
||||
/* no sc_driver_version function => assume old style
|
||||
* init function (note: this should later give an error
|
||||
|
@ -261,13 +260,13 @@ static int parse_emu_block(sc_pkcs15_card_t *p15card, scconf_block *conf)
|
|||
/* get the init function name */
|
||||
name = scconf_get_str(conf, "function", func_name);
|
||||
|
||||
address = lt_dlsym(handle, name);
|
||||
address = sc_dlsym(handle, name);
|
||||
if (address)
|
||||
init_func = (int (*)(sc_pkcs15_card_t *)) address;
|
||||
} else {
|
||||
name = scconf_get_str(conf, "function", exfunc_name);
|
||||
|
||||
address = lt_dlsym(handle, name);
|
||||
address = sc_dlsym(handle, name);
|
||||
if (address)
|
||||
init_func_ex = (int (*)(sc_pkcs15_card_t *, sc_pkcs15emu_opt_t *)) address;
|
||||
}
|
||||
|
@ -290,7 +289,7 @@ static int parse_emu_block(sc_pkcs15_card_t *p15card, scconf_block *conf)
|
|||
/* clear pkcs15 card */
|
||||
sc_pkcs15_card_clear(p15card);
|
||||
if (handle)
|
||||
lt_dlclose(handle);
|
||||
sc_dlclose(handle);
|
||||
}
|
||||
|
||||
return r;
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <ltdl.h>
|
||||
|
||||
#include "internal.h"
|
||||
#include "pkcs15.h"
|
||||
|
@ -975,7 +974,7 @@ int sc_pkcs15_unbind(struct sc_pkcs15_card *p15card)
|
|||
assert(p15card != NULL && p15card->magic == SC_PKCS15_CARD_MAGIC);
|
||||
SC_FUNC_CALLED(p15card->card->ctx, SC_LOG_DEBUG_VERBOSE);
|
||||
if (p15card->dll_handle)
|
||||
lt_dlclose(p15card->dll_handle);
|
||||
sc_dlclose(p15card->dll_handle);
|
||||
sc_pkcs15_pincache_clear(p15card);
|
||||
sc_pkcs15_card_free(p15card);
|
||||
return 0;
|
||||
|
|
|
@ -350,19 +350,19 @@ static int ctapi_load_module(sc_context_t *ctx,
|
|||
}
|
||||
|
||||
val = conf->name->data;
|
||||
dlh = lt_dlopen(val);
|
||||
dlh = sc_dlopen(val);
|
||||
if (!dlh) {
|
||||
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Unable to open shared library '%s': %s\n", val, lt_dlerror());
|
||||
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Unable to open shared library '%s': %s\n", val, sc_dlerror());
|
||||
return -1;
|
||||
}
|
||||
|
||||
funcs.CT_init = (CT_INIT_TYPE *) lt_dlsym(dlh, "CT_init");
|
||||
funcs.CT_init = (CT_INIT_TYPE *) sc_dlsym(dlh, "CT_init");
|
||||
if (!funcs.CT_init)
|
||||
goto symerr;
|
||||
funcs.CT_close = (CT_CLOSE_TYPE *) lt_dlsym(dlh, "CT_close");
|
||||
funcs.CT_close = (CT_CLOSE_TYPE *) sc_dlsym(dlh, "CT_close");
|
||||
if (!funcs.CT_close)
|
||||
goto symerr;
|
||||
funcs.CT_data = (CT_DATA_TYPE *) lt_dlsym(dlh, "CT_data");
|
||||
funcs.CT_data = (CT_DATA_TYPE *) sc_dlsym(dlh, "CT_data");
|
||||
if (!funcs.CT_data)
|
||||
goto symerr;
|
||||
|
||||
|
@ -495,7 +495,7 @@ static int ctapi_load_module(sc_context_t *ctx,
|
|||
return 0;
|
||||
symerr:
|
||||
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Unable to resolve CT-API symbols.\n");
|
||||
lt_dlclose(dlh);
|
||||
sc_dlclose(dlh);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -540,7 +540,7 @@ static int ctapi_finish(sc_context_t *ctx)
|
|||
struct ctapi_module *mod = &priv->modules[i];
|
||||
|
||||
free(mod->name);
|
||||
lt_dlclose(mod->dlhandle);
|
||||
sc_dlclose(mod->dlhandle);
|
||||
}
|
||||
if (priv->module_count)
|
||||
free(priv->modules);
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <ltdl.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <winsock2.h>
|
||||
|
@ -55,7 +54,7 @@ struct pcsc_global_private_data {
|
|||
DWORD transaction_end_action;
|
||||
DWORD reconnect_action;
|
||||
const char *provider_library;
|
||||
lt_dlhandle dlhandle;
|
||||
void *dlhandle;
|
||||
SCardEstablishContext_t SCardEstablishContext;
|
||||
SCardReleaseContext_t SCardReleaseContext;
|
||||
SCardConnect_t SCardConnect;
|
||||
|
@ -653,45 +652,45 @@ static int pcsc_init(sc_context_t *ctx)
|
|||
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "PC/SC options: connect_exclusive=%d disconnect_action=%d transaction_end_action=%d reconnect_action=%d enable_pinpad=%d",
|
||||
gpriv->connect_exclusive, gpriv->disconnect_action, gpriv->transaction_end_action, gpriv->reconnect_action, gpriv->enable_pinpad);
|
||||
|
||||
gpriv->dlhandle = lt_dlopen(gpriv->provider_library);
|
||||
gpriv->dlhandle = sc_dlopen(gpriv->provider_library);
|
||||
if (gpriv->dlhandle == NULL) {
|
||||
ret = SC_ERROR_CANNOT_LOAD_MODULE;
|
||||
goto out;
|
||||
}
|
||||
|
||||
gpriv->SCardEstablishContext = (SCardEstablishContext_t)lt_dlsym(gpriv->dlhandle, "SCardEstablishContext");
|
||||
gpriv->SCardReleaseContext = (SCardReleaseContext_t)lt_dlsym(gpriv->dlhandle, "SCardReleaseContext");
|
||||
gpriv->SCardConnect = (SCardConnect_t)lt_dlsym(gpriv->dlhandle, "SCardConnect");
|
||||
gpriv->SCardReconnect = (SCardReconnect_t)lt_dlsym(gpriv->dlhandle, "SCardReconnect");
|
||||
gpriv->SCardDisconnect = (SCardDisconnect_t)lt_dlsym(gpriv->dlhandle, "SCardDisconnect");
|
||||
gpriv->SCardBeginTransaction = (SCardBeginTransaction_t)lt_dlsym(gpriv->dlhandle, "SCardBeginTransaction");
|
||||
gpriv->SCardEndTransaction = (SCardEndTransaction_t)lt_dlsym(gpriv->dlhandle, "SCardEndTransaction");
|
||||
gpriv->SCardStatus = (SCardStatus_t)lt_dlsym(gpriv->dlhandle, "SCardStatus");
|
||||
gpriv->SCardGetStatusChange = (SCardGetStatusChange_t)lt_dlsym(gpriv->dlhandle, "SCardGetStatusChange");
|
||||
gpriv->SCardCancel = (SCardCancel_t)lt_dlsym(gpriv->dlhandle, "SCardCancel");
|
||||
gpriv->SCardTransmit = (SCardTransmit_t)lt_dlsym(gpriv->dlhandle, "SCardTransmit");
|
||||
gpriv->SCardListReaders = (SCardListReaders_t)lt_dlsym(gpriv->dlhandle, "SCardListReaders");
|
||||
gpriv->SCardEstablishContext = (SCardEstablishContext_t)sc_dlsym(gpriv->dlhandle, "SCardEstablishContext");
|
||||
gpriv->SCardReleaseContext = (SCardReleaseContext_t)sc_dlsym(gpriv->dlhandle, "SCardReleaseContext");
|
||||
gpriv->SCardConnect = (SCardConnect_t)sc_dlsym(gpriv->dlhandle, "SCardConnect");
|
||||
gpriv->SCardReconnect = (SCardReconnect_t)sc_dlsym(gpriv->dlhandle, "SCardReconnect");
|
||||
gpriv->SCardDisconnect = (SCardDisconnect_t)sc_dlsym(gpriv->dlhandle, "SCardDisconnect");
|
||||
gpriv->SCardBeginTransaction = (SCardBeginTransaction_t)sc_dlsym(gpriv->dlhandle, "SCardBeginTransaction");
|
||||
gpriv->SCardEndTransaction = (SCardEndTransaction_t)sc_dlsym(gpriv->dlhandle, "SCardEndTransaction");
|
||||
gpriv->SCardStatus = (SCardStatus_t)sc_dlsym(gpriv->dlhandle, "SCardStatus");
|
||||
gpriv->SCardGetStatusChange = (SCardGetStatusChange_t)sc_dlsym(gpriv->dlhandle, "SCardGetStatusChange");
|
||||
gpriv->SCardCancel = (SCardCancel_t)sc_dlsym(gpriv->dlhandle, "SCardCancel");
|
||||
gpriv->SCardTransmit = (SCardTransmit_t)sc_dlsym(gpriv->dlhandle, "SCardTransmit");
|
||||
gpriv->SCardListReaders = (SCardListReaders_t)sc_dlsym(gpriv->dlhandle, "SCardListReaders");
|
||||
|
||||
if (gpriv->SCardConnect == NULL)
|
||||
gpriv->SCardConnect = (SCardConnect_t)lt_dlsym(gpriv->dlhandle, "SCardConnectA");
|
||||
gpriv->SCardConnect = (SCardConnect_t)sc_dlsym(gpriv->dlhandle, "SCardConnectA");
|
||||
if (gpriv->SCardStatus == NULL)
|
||||
gpriv->SCardStatus = (SCardStatus_t)lt_dlsym(gpriv->dlhandle, "SCardStatusA");
|
||||
gpriv->SCardStatus = (SCardStatus_t)sc_dlsym(gpriv->dlhandle, "SCardStatusA");
|
||||
if (gpriv->SCardGetStatusChange == NULL)
|
||||
gpriv->SCardGetStatusChange = (SCardGetStatusChange_t)lt_dlsym(gpriv->dlhandle, "SCardGetStatusChangeA");
|
||||
gpriv->SCardGetStatusChange = (SCardGetStatusChange_t)sc_dlsym(gpriv->dlhandle, "SCardGetStatusChangeA");
|
||||
if (gpriv->SCardListReaders == NULL)
|
||||
gpriv->SCardListReaders = (SCardListReaders_t)lt_dlsym(gpriv->dlhandle, "SCardListReadersA");
|
||||
gpriv->SCardListReaders = (SCardListReaders_t)sc_dlsym(gpriv->dlhandle, "SCardListReadersA");
|
||||
|
||||
/* If we have SCardGetAttrib it is correct API */
|
||||
if (lt_dlsym(gpriv->dlhandle, "SCardGetAttrib") != NULL) {
|
||||
if (sc_dlsym(gpriv->dlhandle, "SCardGetAttrib") != NULL) {
|
||||
#ifdef __APPLE__
|
||||
gpriv->SCardControl = (SCardControl_t)lt_dlsym(gpriv->dlhandle, "SCardControl132");
|
||||
gpriv->SCardControl = (SCardControl_t)sc_dlsym(gpriv->dlhandle, "SCardControl132");
|
||||
#endif
|
||||
if (gpriv->SCardControl == NULL) {
|
||||
gpriv->SCardControl = (SCardControl_t)lt_dlsym(gpriv->dlhandle, "SCardControl");
|
||||
gpriv->SCardControl = (SCardControl_t)sc_dlsym(gpriv->dlhandle, "SCardControl");
|
||||
}
|
||||
}
|
||||
else {
|
||||
gpriv->SCardControlOLD = (SCardControlOLD_t)lt_dlsym(gpriv->dlhandle, "SCardControl");
|
||||
gpriv->SCardControlOLD = (SCardControlOLD_t)sc_dlsym(gpriv->dlhandle, "SCardControl");
|
||||
}
|
||||
|
||||
if (
|
||||
|
@ -719,7 +718,7 @@ static int pcsc_init(sc_context_t *ctx)
|
|||
out:
|
||||
if (gpriv != NULL) {
|
||||
if (gpriv->dlhandle != NULL)
|
||||
lt_dlclose(gpriv->dlhandle);
|
||||
sc_dlclose(gpriv->dlhandle);
|
||||
free(gpriv);
|
||||
}
|
||||
|
||||
|
@ -736,7 +735,7 @@ static int pcsc_finish(sc_context_t *ctx)
|
|||
if (gpriv->pcsc_ctx != -1)
|
||||
gpriv->SCardReleaseContext(gpriv->pcsc_ctx);
|
||||
if (gpriv->dlhandle != NULL)
|
||||
lt_dlclose(gpriv->dlhandle);
|
||||
sc_dlclose(gpriv->dlhandle);
|
||||
free(gpriv);
|
||||
}
|
||||
|
||||
|
@ -1602,31 +1601,31 @@ static int cardmod_init(sc_context_t *ctx)
|
|||
}
|
||||
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "PC/SC options: enable_pinpad=%d", gpriv->enable_pinpad);
|
||||
|
||||
gpriv->dlhandle = lt_dlopen("winscard.dll");
|
||||
gpriv->dlhandle = sc_dlopen("winscard.dll");
|
||||
if (gpriv->dlhandle == NULL) {
|
||||
ret = SC_ERROR_CANNOT_LOAD_MODULE;
|
||||
goto out;
|
||||
}
|
||||
|
||||
gpriv->SCardStatus = (SCardStatus_t)lt_dlsym(gpriv->dlhandle, "SCardStatus");
|
||||
gpriv->SCardGetStatusChange = (SCardGetStatusChange_t)lt_dlsym(gpriv->dlhandle, "SCardGetStatusChange");
|
||||
gpriv->SCardTransmit = (SCardTransmit_t)lt_dlsym(gpriv->dlhandle, "SCardTransmit");
|
||||
gpriv->SCardStatus = (SCardStatus_t)sc_dlsym(gpriv->dlhandle, "SCardStatus");
|
||||
gpriv->SCardGetStatusChange = (SCardGetStatusChange_t)sc_dlsym(gpriv->dlhandle, "SCardGetStatusChange");
|
||||
gpriv->SCardTransmit = (SCardTransmit_t)sc_dlsym(gpriv->dlhandle, "SCardTransmit");
|
||||
|
||||
if (gpriv->SCardStatus == NULL)
|
||||
gpriv->SCardStatus = (SCardStatus_t)lt_dlsym(gpriv->dlhandle, "SCardStatusA");
|
||||
gpriv->SCardStatus = (SCardStatus_t)sc_dlsym(gpriv->dlhandle, "SCardStatusA");
|
||||
if (gpriv->SCardGetStatusChange == NULL)
|
||||
gpriv->SCardGetStatusChange = (SCardGetStatusChange_t)lt_dlsym(gpriv->dlhandle, "SCardGetStatusChangeA");
|
||||
gpriv->SCardGetStatusChange = (SCardGetStatusChange_t)sc_dlsym(gpriv->dlhandle, "SCardGetStatusChangeA");
|
||||
|
||||
gpriv->SCardGetAttrib = lt_dlsym(gpriv->dlhandle, "SCardGetAttrib");
|
||||
gpriv->SCardGetAttrib = sc_dlsym(gpriv->dlhandle, "SCardGetAttrib");
|
||||
|
||||
/* If we have SCardGetAttrib it is correct API */
|
||||
if (gpriv->SCardGetAttrib != NULL) {
|
||||
if (gpriv->SCardControl == NULL) {
|
||||
gpriv->SCardControl = (SCardControl_t)lt_dlsym(gpriv->dlhandle, "SCardControl");
|
||||
gpriv->SCardControl = (SCardControl_t)sc_dlsym(gpriv->dlhandle, "SCardControl");
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* gpriv->SCardControlOLD = (SCardControlOLD_t)lt_dlsym(gpriv->dlhandle, "SCardControl"); */
|
||||
/* gpriv->SCardControlOLD = (SCardControlOLD_t)sc_dlsym(gpriv->dlhandle, "SCardControl"); */
|
||||
}
|
||||
|
||||
if (
|
||||
|
@ -1646,7 +1645,7 @@ static int cardmod_init(sc_context_t *ctx)
|
|||
out:
|
||||
if (gpriv != NULL) {
|
||||
if (gpriv->dlhandle != NULL)
|
||||
lt_dlclose(gpriv->dlhandle);
|
||||
sc_dlclose(gpriv->dlhandle);
|
||||
free(gpriv);
|
||||
}
|
||||
|
||||
|
@ -1659,7 +1658,7 @@ static int cardmod_finish(sc_context_t *ctx)
|
|||
|
||||
if (gpriv) {
|
||||
if (gpriv->dlhandle != NULL)
|
||||
lt_dlclose(gpriv->dlhandle);
|
||||
sc_dlclose(gpriv->dlhandle);
|
||||
free(gpriv);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ EXTRA_DIST = Makefile.mak
|
|||
|
||||
dist_noinst_SCRIPTS = opensc_pkcs11_install.js
|
||||
lib_LTLIBRARIES = opensc-pkcs11.la pkcs11-spy.la onepin-opensc-pkcs11.la
|
||||
noinst_LTLIBRARIES = libpkcs11.la
|
||||
|
||||
AM_CFLAGS = $(OPTIONAL_OPENSSL_CFLAGS) $(LTLIB_CFLAGS) $(PTHREAD_CFLAGS)
|
||||
INCLUDES = -I$(top_srcdir)/src
|
||||
|
@ -19,9 +18,6 @@ OPENSC_PKCS11_LIBS = $(OPTIONAL_OPENSSL_LIBS) $(PTHREAD_LIBS) \
|
|||
$(top_builddir)/src/common/libcompat.la \
|
||||
$(top_builddir)/src/libopensc/libopensc.la
|
||||
|
||||
libpkcs11_la_SOURCES = libpkcs11.c
|
||||
libpkcs11_la_LIBADD = $(LTLIB_LIBS)
|
||||
|
||||
opensc_pkcs11_la_SOURCES = $(OPENSC_PKCS11_SRC) $(OPENSC_PKCS11_INC) hack-disabled.c
|
||||
opensc_pkcs11_la_LIBADD = $(OPENSC_PKCS11_LIBS)
|
||||
opensc_pkcs11_la_LDFLAGS = $(AM_LDFLAGS) \
|
||||
|
@ -35,7 +31,7 @@ onepin_opensc_pkcs11_la_LDFLAGS = $(AM_LDFLAGS) \
|
|||
-module -shared -avoid-version -no-undefined
|
||||
|
||||
pkcs11_spy_la_SOURCES = pkcs11-spy.c pkcs11-display.c pkcs11-display.h pkcs11-spy.exports
|
||||
pkcs11_spy_la_LIBADD = $(OPTIONAL_OPENSSL_LIBS) $(LTLIB_LIBS) libpkcs11.la
|
||||
pkcs11_spy_la_LIBADD = $(OPTIONAL_OPENSSL_LIBS) $(LTLIB_LIBS) $(top_builddir)/src/common/libpkcs11.la
|
||||
pkcs11_spy_la_LDFLAGS = $(AM_LDFLAGS) \
|
||||
-export-symbols "$(srcdir)/pkcs11-spy.exports" \
|
||||
-module -shared -avoid-version -no-undefined
|
||||
|
|
|
@ -2,19 +2,16 @@ TOPDIR = ..\..
|
|||
|
||||
TARGET0 = onepin-opensc-pkcs11.dll
|
||||
TARGET = opensc-pkcs11.dll
|
||||
TARGET2 = libpkcs11.lib
|
||||
TARGET3 = pkcs11-spy.dll
|
||||
|
||||
OBJECTS = pkcs11-global.obj pkcs11-session.obj pkcs11-object.obj misc.obj slot.obj \
|
||||
mechanism.obj openssl.obj framework-pkcs15.obj \
|
||||
framework-pkcs15init.obj debug.obj pkcs11-display.obj \
|
||||
$(TOPDIR)\win32\versioninfo.res
|
||||
OBJECTS2 = libpkcs11.obj \
|
||||
$(TOPDIR)\win32\versioninfo.res
|
||||
OBJECTS3 = pkcs11-spy.obj pkcs11-display.obj libpkcs11.obj \
|
||||
OBJECTS3 = pkcs11-spy.obj pkcs11-display.obj \
|
||||
$(TOPDIR)\win32\versioninfo.res
|
||||
|
||||
all: $(TOPDIR)\win32\versioninfo.res $(TARGET0) $(TARGET) $(TARGET2) $(TARGET3)
|
||||
all: $(TOPDIR)\win32\versioninfo.res $(TARGET0) $(TARGET) $(TARGET3)
|
||||
|
||||
!INCLUDE $(TOPDIR)\win32\Make.rules.mak
|
||||
|
||||
|
@ -22,22 +19,19 @@ $(TARGET0): $(OBJECTS) hack-enabled.obj ..\libopensc\opensc.lib ..\scconf\scconf
|
|||
echo LIBRARY $* > $*.def
|
||||
echo EXPORTS >> $*.def
|
||||
type opensc-pkcs11.exports >> $*.def
|
||||
link $(LINKFLAGS) /dll /def:$*.def /implib:$*.lib /out:$(TARGET0) $(OBJECTS) hack-enabled.obj ..\libopensc\opensc.lib ..\scconf\scconf.lib ..\pkcs15init\pkcs15init.lib ..\common\common.lib winscard.lib $(OPENSSL_LIB) $(LIBLTDL) gdi32.lib
|
||||
link $(LINKFLAGS) /dll /def:$*.def /implib:$*.lib /out:$(TARGET0) $(OBJECTS) hack-enabled.obj ..\libopensc\opensc.lib ..\scconf\scconf.lib ..\pkcs15init\pkcs15init.lib ..\common\common.lib winscard.lib $(OPENSSL_LIB) gdi32.lib
|
||||
if EXIST $(TARGET0).manifest mt -manifest $(TARGET0).manifest -outputresource:$(TARGET0);2
|
||||
|
||||
$(TARGET): $(OBJECTS) hack-disabled.obj ..\libopensc\opensc.lib ..\scconf\scconf.lib ..\pkcs15init\pkcs15init.lib ..\common\common.lib
|
||||
echo LIBRARY $* > $*.def
|
||||
echo EXPORTS >> $*.def
|
||||
type $*.exports >> $*.def
|
||||
link $(LINKFLAGS) /dll /def:$*.def /implib:$*.lib /out:$(TARGET) $(OBJECTS) hack-disabled.obj ..\libopensc\opensc.lib ..\scconf\scconf.lib ..\pkcs15init\pkcs15init.lib ..\common\common.lib winscard.lib $(OPENSSL_LIB) $(LIBLTDL) gdi32.lib
|
||||
link $(LINKFLAGS) /dll /def:$*.def /implib:$*.lib /out:$(TARGET) $(OBJECTS) hack-disabled.obj ..\libopensc\opensc.lib ..\scconf\scconf.lib ..\pkcs15init\pkcs15init.lib ..\common\common.lib winscard.lib $(OPENSSL_LIB) gdi32.lib
|
||||
if EXIST $(TARGET).manifest mt -manifest $(TARGET).manifest -outputresource:$(TARGET);2
|
||||
|
||||
$(TARGET2): $(OBJECTS2)
|
||||
lib /nologo /machine:ix86 /out:$(TARGET2) $(OBJECTS2) $(LIBLTDL_LIB)
|
||||
|
||||
$(TARGET3): $(OBJECTS3) ..\libopensc\opensc.lib
|
||||
echo LIBRARY $* > $*.def
|
||||
echo EXPORTS >> $*.def
|
||||
type $*.exports >> $*.def
|
||||
link $(LINKFLAGS) /dll /def:$*.def /implib:$*.lib /out:$(TARGET3) $(OBJECTS3) ..\libopensc\opensc.lib $(OPENSSL_LIB) $(LIBLTDL_LIB) gdi32.lib advapi32.lib
|
||||
link $(LINKFLAGS) /dll /def:$*.def /implib:$*.lib /out:$(TARGET3) $(OBJECTS3) ..\libopensc\opensc.lib ..\common\libpkcs11.lib $(OPENSSL_LIB) gdi32.lib advapi32.lib
|
||||
if EXIST $(TARGET3).manifest mt -manifest $(TARGET3).manifest -outputresource:$(TARGET3);2
|
||||
|
|
|
@ -54,7 +54,6 @@
|
|||
#include <openssl/rsa.h>
|
||||
#include <openssl/pkcs12.h>
|
||||
#endif
|
||||
#include <ltdl.h>
|
||||
|
||||
#include "common/compat_strlcpy.h"
|
||||
#include "libopensc/pkcs15.h"
|
||||
|
@ -240,32 +239,32 @@ load_dynamic_driver(struct sc_context *ctx, void **dll,
|
|||
const char *name)
|
||||
{
|
||||
const char *version, *libname;
|
||||
lt_dlhandle handle;
|
||||
void *handle;
|
||||
void *(*modinit)(const char *) = NULL;
|
||||
const char *(*modversion)(void) = NULL;
|
||||
|
||||
libname = find_library(ctx, name);
|
||||
if (!libname)
|
||||
return NULL;
|
||||
handle = lt_dlopen(libname);
|
||||
handle = sc_dlopen(libname);
|
||||
if (handle == NULL) {
|
||||
sc_log(ctx, "Module %s: cannot load '%s' library: %s", name, libname, lt_dlerror());
|
||||
sc_log(ctx, "Module %s: cannot load '%s' library: %s", name, libname, sc_dlerror());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* verify correctness of module */
|
||||
modinit = (void *(*)(const char *)) lt_dlsym(handle, "sc_module_init");
|
||||
modversion = (const char *(*)(void)) lt_dlsym(handle, "sc_driver_version");
|
||||
modinit = (void *(*)(const char *)) sc_dlsym(handle, "sc_module_init");
|
||||
modversion = (const char *(*)(void)) sc_dlsym(handle, "sc_driver_version");
|
||||
if (modinit == NULL || modversion == NULL) {
|
||||
sc_log(ctx, "dynamic library '%s' is not a OpenSC module",libname);
|
||||
lt_dlclose(handle);
|
||||
sc_dlclose(handle);
|
||||
return NULL;
|
||||
}
|
||||
/* verify module version */
|
||||
version = modversion();
|
||||
if (version == NULL || strncmp(version, "0.9.", strlen("0.9.")) > 0) {
|
||||
sc_log(ctx,"dynamic library '%s': invalid module version",libname);
|
||||
lt_dlclose(handle);
|
||||
sc_dlclose(handle);
|
||||
return NULL;
|
||||
}
|
||||
*dll = handle;
|
||||
|
@ -388,7 +387,7 @@ sc_pkcs15init_unbind(struct sc_profile *profile)
|
|||
sc_log(ctx, "Failed to update TokenInfo: %s", sc_strerror(r));
|
||||
}
|
||||
if (profile->dll)
|
||||
lt_dlclose(profile->dll);
|
||||
sc_dlclose(profile->dll);
|
||||
sc_profile_free(profile);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ pkcs15_tool_SOURCES = pkcs15-tool.c util.c
|
|||
pkcs15_tool_LDADD = $(OPTIONAL_OPENSSL_LIBS)
|
||||
pkcs11_tool_SOURCES = pkcs11-tool.c util.c
|
||||
pkcs11_tool_LDADD = $(OPTIONAL_OPENSSL_LIBS) $(LTLIB_LIBS) \
|
||||
$(top_builddir)/src/pkcs11/libpkcs11.la
|
||||
$(top_builddir)/src/common/libpkcs11.la
|
||||
pkcs15_crypt_SOURCES = pkcs15-crypt.c util.c
|
||||
pkcs15_crypt_LDADD = $(OPTIONAL_OPENSSL_LIBS)
|
||||
cryptoflex_tool_SOURCES = cryptoflex-tool.c util.c
|
||||
|
|
|
@ -17,6 +17,6 @@ all: $(TARGETS)
|
|||
cl $(COPTS) /c $<
|
||||
link $(LINKFLAGS) /pdb:$*.pdb /out:$@ $*.obj util.obj \
|
||||
..\common\common.lib ..\scconf\scconf.lib ..\libopensc\opensc.lib \
|
||||
..\pkcs15init\pkcs15init.lib ..\pkcs11\libpkcs11.lib \
|
||||
$(TOPDIR)\win32\versioninfo.res $(OPENSSL_LIB) $(LIBLTDL) gdi32.lib
|
||||
..\pkcs15init\pkcs15init.lib ..\common\libpkcs11.lib \
|
||||
$(TOPDIR)\win32\versioninfo.res $(OPENSSL_LIB) gdi32.lib
|
||||
if EXIST $@.manifest mt -manifest $@.manifest -outputresource:$@;1
|
||||
|
|
|
@ -1,18 +1,8 @@
|
|||
# Note: these instructions obsolete the instructions in opensc.html
|
||||
|
||||
# You first need to download the gnuwin32 libtool (e.g. the "Binaries" and "Developer
|
||||
# files" from http://gnuwin32.sourceforge.net/packages/libtool.htm)
|
||||
# Then fill in the directory path to ltdl.h on the LIBLTDL_INCL line below, preceeded
|
||||
# by an "/I"; and fill in the path to the libltdl.lib on the LIBLTDL_LIB line below.
|
||||
# Then you can build this OpenSC package; and afterwards you'll need to copy the
|
||||
# libltdl3.dll somewhere on your execution path.
|
||||
LIBLTDL_INCL = # E.g. /IC:\libtool-1.5.8-lib\include
|
||||
LIBLTDL_LIB = # E.g. C:\libtool-1.5.8-lib\lib\libltdl.lib
|
||||
|
||||
OPENSC_FEATURES = pcsc
|
||||
|
||||
#Uncomment to use 'static' linking mode
|
||||
#LINK_MODE = STATIC
|
||||
LINK_MODE = STATIC
|
||||
|
||||
#Include support of minidriver 'cardmon'
|
||||
MINIDRIVER_DEF = /DENABLE_MINIDRIVER
|
||||
|
@ -27,7 +17,7 @@ LINK_MODE = STATIC
|
|||
!ENDIF
|
||||
|
||||
|
||||
# If you want support for OpenSSL (needed for a.o. pkcs15-init tool and openssl engine):
|
||||
# If you want support for OpenSSL (needed for pkcs15-init tool, software hashing in PKCS#11 library and verification):
|
||||
# - download and build OpenSSL
|
||||
# - uncomment the line starting with OPENSSL_DEF
|
||||
# - set the OPENSSL_INCL_DIR below to your openssl include directory, preceded by "/I"
|
||||
|
@ -61,17 +51,21 @@ ZLIB_LIB = C:\ZLIB\LIB\zlib.lib
|
|||
OPENSC_FEATURES = $(OPENSC_FEATURES) zlib
|
||||
!ENDIF
|
||||
|
||||
# Used for MiniDriver
|
||||
CNGSDK_INCL_DIR = "/IC:\Program Files\Microsoft CNG Development Kit\Include"
|
||||
|
||||
# Mandatory path to 'ISO C9x compliant stdint.h and inttypes.h for Microsoft Visual Studio'
|
||||
# http://msinttypes.googlecode.com/files/msinttypes-r26.zip
|
||||
INTTYPES_INCL_DIR = /IC:\opensc\dependencies\msys\local
|
||||
# INTTYPES_INCL_DIR = /IC:\opensc\dependencies\msys\local
|
||||
|
||||
ALL_INCLUDES = /I$(TOPDIR)\win32 /I$(TOPDIR)\src $(OPENSSL_INCL_DIR) $(ZLIB_INCL_DIR) $(LIBLTDL_INCL) $(INTTYPES_INCL_DIR) $(CNGSDK_INCL_DIR)
|
||||
!IF "$(LINK_MODE)" != "STATIC"
|
||||
COPTS = /D_CRT_SECURE_NO_DEPRECATE /Zi /MD /nologo /DHAVE_CONFIG_H /I$(TOPDIR)\win32 /I$(TOPDIR)\src $(OPENSSL_INCL_DIR) $(ZLIB_INCL_DIR) $(LIBLTDL_INCL) $(INTTYPES_INCL_DIR) /D_WIN32_WINNT=0x0400 /DWIN32_LEAN_AND_MEAN $(OPENSSL_DEF) $(ZLIB_DEF) /DOPENSC_FEATURES="\"$(OPENSC_FEATURES)\""
|
||||
COPTS = /D_CRT_SECURE_NO_DEPRECATE /Zi /MD /nologo /DHAVE_CONFIG_H $(ALL_INCLUDES) /D_WIN32_WINNT=0x0400 /DWIN32_LEAN_AND_MEAN $(OPENSSL_DEF) $(ZLIB_DEF) /DOPENSC_FEATURES="\"$(OPENSC_FEATURES)\""
|
||||
LINKFLAGS = /DEBUG /NOLOGO /INCREMENTAL:NO /MACHINE:IX86
|
||||
!ENDIF
|
||||
|
||||
!IF "$(LINK_MODE)" == "STATIC"
|
||||
COPTS = /D_CRT_SECURE_NO_DEPRECATE /MT /nologo /DHAVE_CONFIG_H /I$(TOPDIR)\win32 /I$(TOPDIR)\src /I$(TOPDIR)\src\include\opensc /I$(TOPDIR)\src\common $(OPENSSL_INCL_DIR) $(ZLIB_INCL_DIR) $(LIBLTDL_INCL) $(INTTYPES_INCL_DIR) /D_WIN32_WINNT=0x0400 /DWIN32_LEAN_AND_MEAN $(OPENSSL_DEF) $(ZLIB_DEF) /DOPENSC_FEATURES="\"$(OPENSC_FEATURES)\""
|
||||
COPTS = /D_CRT_SECURE_NO_DEPRECATE /MT /nologo /DHAVE_CONFIG_H $(ALL_INCLUDES) /D_WIN32_WINNT=0x0400 /DWIN32_LEAN_AND_MEAN $(OPENSSL_DEF) $(ZLIB_DEF) /DOPENSC_FEATURES="\"$(OPENSC_FEATURES)\""
|
||||
LINKFLAGS = /NOLOGO /INCREMENTAL:NO /MACHINE:IX86 /MANIFEST:NO /NODEFAULTLIB:MSVCRTD /NODEFAULTLIB:MSVCRT /NODEFAULTLIB:LIBCMTD
|
||||
!ENDIF
|
||||
|
||||
|
|
Loading…
Reference in New Issue