diff --git a/src/pkcs11/libpkcs11.c b/src/pkcs11/libpkcs11.c index 4175a211..f62091d9 100644 --- a/src/pkcs11/libpkcs11.c +++ b/src/pkcs11/libpkcs11.c @@ -18,14 +18,15 @@ struct sc_pkcs11_module { unsigned int _magic; - scdl_context_t *handle; + void *handle; }; +typedef struct sc_pkcs11_module sc_pkcs11_module_t; /* * Load a module - this will load the shared object, call * C_Initialize, and get the list of function pointers */ -sc_pkcs11_module_t * +void * C_LoadModule(const char *mspec, CK_FUNCTION_LIST_PTR_PTR funcs) { sc_pkcs11_module_t *mod; @@ -48,9 +49,9 @@ C_LoadModule(const char *mspec, CK_FUNCTION_LIST_PTR_PTR funcs) goto failed; rv = c_get_function_list(funcs); if (rv == CKR_OK) - return mod; + return (void *) mod; -failed: C_UnloadModule(mod); +failed: C_UnloadModule((void *) mod); return NULL; } @@ -60,8 +61,10 @@ failed: C_UnloadModule(mod); * and calling C_Finalize */ CK_RV -C_UnloadModule(sc_pkcs11_module_t *mod) +C_UnloadModule(void *module) { + sc_pkcs11_module_t *mod = (sc_pkcs11_module_t *) module; + if (!mod || mod->_magic != MAGIC) return CKR_ARGUMENTS_BAD; diff --git a/src/pkcs11/pkcs11-spy.c b/src/pkcs11/pkcs11-spy.c index e3aa39a0..bb7867a3 100644 --- a/src/pkcs11/pkcs11-spy.c +++ b/src/pkcs11/pkcs11-spy.c @@ -38,7 +38,7 @@ CK_FUNCTION_LIST_PTR pkcs11_spy = NULL; /* Real Module Function List */ CK_FUNCTION_LIST_PTR po = NULL; /* Dynamic Module Handle */ -static sc_pkcs11_module_t *modhandle = NULL; +static void *modhandle = NULL; /* Spy module output */ FILE *spy_output = NULL; diff --git a/src/pkcs11/pkcs11.h b/src/pkcs11/pkcs11.h index c283964b..ad10c0fd 100644 --- a/src/pkcs11/pkcs11.h +++ b/src/pkcs11/pkcs11.h @@ -49,11 +49,8 @@ extern "C" { #define PKCS11_DEFAULT_MODULE_NAME "opensc-pkcs11.so"; #endif -typedef struct sc_pkcs11_module sc_pkcs11_module_t; - -extern sc_pkcs11_module_t *C_LoadModule(const char *name, - CK_FUNCTION_LIST_PTR_PTR); -extern CK_RV C_UnloadModule(sc_pkcs11_module_t *); +extern void *C_LoadModule(const char *name, CK_FUNCTION_LIST_PTR_PTR); +extern CK_RV C_UnloadModule(void *module); #ifdef __cplusplus } diff --git a/src/scdl/scdl.c b/src/scdl/scdl.c index a225185c..7d510bcf 100644 --- a/src/scdl/scdl.c +++ b/src/scdl/scdl.c @@ -18,6 +18,7 @@ #ifdef __APPLE__ #include #endif +#include "scdl.h" #define SCDL_MAGIC 0xbeefd00d @@ -207,7 +208,7 @@ mac_get_address(scdl_context_t *mod, const char *symbol) } #endif -scdl_context_t * +void * scdl_open(const char *name) { scdl_context_t *mod; @@ -237,12 +238,13 @@ scdl_open(const char *name) free(mod); return NULL; } - return mod; + return (void *) mod; } int -scdl_close(scdl_context_t *mod) +scdl_close(void *module) { + scdl_context_t *mod = (scdl_context_t *) module; int rv; if (!mod || mod->magic != SCDL_MAGIC) @@ -269,8 +271,10 @@ scdl_close(scdl_context_t *mod) } void * -scdl_get_address(scdl_context_t *mod, const char *symbol) +scdl_get_address(void *module, const char *symbol) { + scdl_context_t *mod = (scdl_context_t *) module; + if (!mod || mod->magic != SCDL_MAGIC) return NULL; #if defined(_WIN32) diff --git a/src/scdl/scdl.h b/src/scdl/scdl.h index b1c4b037..12c869e1 100644 --- a/src/scdl/scdl.h +++ b/src/scdl/scdl.h @@ -17,11 +17,9 @@ extern "C" { #endif -typedef void scdl_context_t; - -extern scdl_context_t *scdl_open(const char *name); -extern int scdl_close(scdl_context_t *mod); -extern void *scdl_get_address(scdl_context_t *mod, const char *symbol); +extern void *scdl_open(const char *name); +extern int scdl_close(void *module); +extern void *scdl_get_address(void *module, const char *symbol); #ifdef __cplusplus } diff --git a/src/sslengines/p11_load.c b/src/sslengines/p11_load.c index 4ab63684..31ff596b 100644 --- a/src/sslengines/p11_load.c +++ b/src/sslengines/p11_load.c @@ -67,7 +67,7 @@ * but is not anymore. The typical ``watch me walk over the edge * of that cliff there'' thing. */ -static void * the_handler = NULL; +static void *handle = NULL; /* * Create a new context @@ -105,12 +105,12 @@ PKCS11_CTX_load(PKCS11_CTX *ctx, const char *name) PKCS11err(PKCS11_F_PKCS11_CTX_LOAD, PKCS11_MODULE_LOADED_ERROR); return -1; } - the_handler=C_LoadModule(name, &priv->method ); - if (!the_handler) { + handle=C_LoadModule(name, &priv->method ); + if (!handle) { PKCS11err(PKCS11_F_PKCS11_CTX_LOAD, PKCS11_LOAD_MODULE_ERROR); return -1; } -/* +#if 0 priv->method = PKCS11_NEW(PKCS11_method); base = (caddr_t) (priv->method); for (sym = pkcs11_symbols; sym->name; sym++) { @@ -120,7 +120,7 @@ PKCS11_CTX_load(PKCS11_CTX *ctx, const char *name) return -1; } } -*/ +#endif /* Tell the PKCS11 to initialize itself */ rv = priv->method->C_Initialize(NULL); @@ -152,7 +152,7 @@ PKCS11_CTX_unload(PKCS11_CTX *ctx) priv->method->C_Finalize(NULL); /* Unload the module */ - C_UnloadModule(the_handler); + C_UnloadModule(handle); } /* diff --git a/src/tools/pkcs11-tool.c b/src/tools/pkcs11-tool.c index 0317d14f..e05f7b22 100644 --- a/src/tools/pkcs11-tool.c +++ b/src/tools/pkcs11-tool.c @@ -120,7 +120,7 @@ static CK_BYTE opt_object_id[100], new_object_id[100]; static int opt_object_id_len = 0, new_object_id_len = 0; static char * opt_object_label = NULL; -static sc_pkcs11_module_t *module = NULL; +static void *module = NULL; static CK_FUNCTION_LIST_PTR p11 = NULL; static CK_SLOT_ID_PTR p11_slots = NULL; static CK_ULONG p11_num_slots = 0;