Skip to content

Commit

Permalink
scd/pkcs11-lib: remove libscdl
Browse files Browse the repository at this point in the history
Removed libscdl: wrapping of dl* functions unnecessary in our usage
context as we only target linux systems.

Signed-off-by: Maximilian Peisl <[email protected]>
  • Loading branch information
MPeisl committed Feb 24, 2025
1 parent b495b78 commit 5e8f238
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 116 deletions.
3 changes: 1 addition & 2 deletions scd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ ifeq ($(TRUSTME_PKCS11), y)
LOCAL_LDFLAGS += -ldl
SRC_FILES += \
p11token.c \
pkcs11-lib/libpkcs11.c \
pkcs11-lib/libscdl.c
pkcs11-lib/libpkcs11.c
endif


Expand Down
13 changes: 7 additions & 6 deletions scd/pkcs11-lib/libpkcs11.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
#include <stdio.h>
#include <string.h>

#include "libscdl.h"
#include <dlfcn.h>

#include "libpkcs11.h"
#include "../common/macro.h"

Expand Down Expand Up @@ -60,15 +61,15 @@ C_LoadModule(const char *mspec, struct ck_function_list **funcs)
free(mod);
return NULL;
}
mod->handle = sc_dlopen(mspec);
mod->handle = dlopen(mspec, RTLD_LAZY);
if (mod->handle == NULL) {
fprintf(stderr, "sc_dlopen failed: %s\n", sc_dlerror());
fprintf(stderr, "dlopen failed: %s\n", dlerror());
goto failed;
}

c_get_interface =
CAST(ck_rv_t(*)(unsigned char *, struct ck_version *, struct ck_interface **,
ck_flags_t)) sc_dlsym(mod->handle, "C_GetInterface");
ck_flags_t)) dlsym(mod->handle, "C_GetInterface");
if (c_get_interface) {
struct ck_interface *interface = NULL;

Expand All @@ -87,7 +88,7 @@ C_LoadModule(const char *mspec, struct ck_function_list **funcs)

/* Get the list of function pointers */
c_get_function_list = CAST(ck_rv_t(*)(struct ck_function_list **))
sc_dlsym(mod->handle, "C_GetFunctionList");
dlsym(mod->handle, "C_GetFunctionList");
if (!c_get_function_list)
goto failed;
rv = c_get_function_list(funcs);
Expand Down Expand Up @@ -117,7 +118,7 @@ C_UnloadModule(void *module)
if (!mod || mod->_magic != MAGIC)
return CKR_ARGUMENTS_BAD;

if (mod->handle != NULL && sc_dlclose(mod->handle) < 0)
if (mod->handle != NULL && dlclose(mod->handle) < 0)
return CKR_FUNCTION_FAILED;

free(mod);
Expand Down
80 changes: 0 additions & 80 deletions scd/pkcs11-lib/libscdl.c

This file was deleted.

27 changes: 0 additions & 27 deletions scd/pkcs11-lib/libscdl.h

This file was deleted.

1 change: 0 additions & 1 deletion scd/pkcs11-tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ SRC_FILES := \
../common/munit.c \
../p11token.c \
../pkcs11-lib/libpkcs11.c \
../pkcs11-lib/libscdl.c \
p11token-test.c

all: p11test
Expand Down

0 comments on commit 5e8f238

Please sign in to comment.