Skip to content

Commit

Permalink
Print to ctx->out
Browse files Browse the repository at this point in the history
  • Loading branch information
qpernil committed Dec 14, 2021
1 parent 076906a commit 7eaa157
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions common/ecdh.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void mserror(const char *str, int err) {
}
}

int ecdh_load_module(const char *module) {
int ecdh_load_module(const char *module, FILE *out) {
UNUSED(module);
return 0;
}
Expand Down Expand Up @@ -1570,7 +1570,7 @@ static void trimright(unsigned char *buf, size_t len) {
*p = 0;
}

int ecdh_load_module(const char *module) {
int ecdh_load_module(const char *module, FILE *out) {

if (module_handle) {
p11->C_Finalize(0);
Expand All @@ -1582,22 +1582,22 @@ int ecdh_load_module(const char *module) {
if (strcmp(module, "-")) {
module_handle = dlopen(module, RTLD_NOW | RTLD_GLOBAL);
if (module_handle == 0) {
puts("Can't open shared library");
fprintf(out, "Can't open shared library '%s'\n", module);
return CKR_ARGUMENTS_BAD;
}

CK_C_GetFunctionList fn = 0;
*(void **) (&fn) = dlsym(module_handle, "C_GetFunctionList");
if (fn == 0) {
puts("Can't find symbol");
fprintf(out, "Can't find symbol 'C_GetFunctionList' in '%s'\n", module);
dlclose(module_handle);
module_handle = 0;
return CKR_GENERAL_ERROR;
}

CK_RV rv = fn(&p11);
if (rv != CKR_OK) {
puts("Can't get function list");
fprintf(out, "Can't get function list from '%s', rv=%lu\n", module, rv);
dlclose(module_handle);
module_handle = 0;
p11 = &function_list;
Expand All @@ -1606,7 +1606,7 @@ int ecdh_load_module(const char *module) {

rv = p11->C_Initialize(0);
if (rv != CKR_OK) {
puts("Can't initialize module");
fprintf(out, "Can't initialize module '%s', rv = %lu\n", module, rv);
dlclose(module_handle);
module_handle = 0;
p11 = &function_list;
Expand Down
2 changes: 1 addition & 1 deletion common/ecdh.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ int YH_INTERNAL ecdh_curve_p256(void);
int YH_INTERNAL ecdh_curve_p384(void);
int YH_INTERNAL ecdh_curve_p521(void);

int YH_INTERNAL ecdh_load_module(const char *module);
int YH_INTERNAL ecdh_load_module(const char *module, FILE *out);

int YH_INTERNAL ecdh_list_providers(void *ctx,
int (*callback)(void *ctx,
Expand Down
4 changes: 2 additions & 2 deletions lib/yubihsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1310,9 +1310,9 @@ static int name_listing(void *ctx, const char *name) {
return 0;
}

yh_rc yh_util_load_client_auth_module(const char *module) {
yh_rc yh_util_load_client_auth_module(const char *module, FILE *out) {

ecdh_load_module(module);
ecdh_load_module(module, out);

return YHR_SUCCESS;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/yubihsm.h
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ yh_rc yh_create_session(yh_connector *connector, uint16_t authkey_id,
const uint8_t *key_mac, size_t key_mac_len,
bool recreate_session, yh_session **session);

yh_rc yh_util_load_client_auth_module(const char *module);
yh_rc yh_util_load_client_auth_module(const char *module, FILE *out);

yh_rc yh_util_list_client_auth_providers(FILE *out);

Expand Down
2 changes: 1 addition & 1 deletion src/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -1527,7 +1527,7 @@ int yh_com_load_client_auth_module(yubihsm_context *ctx, Argument *argv,
UNUSED(in_fmt);
UNUSED(fmt);

yh_util_load_client_auth_module(argv[0].s);
yh_util_load_client_auth_module(argv[0].s, ctx->out);
return 0;
}

Expand Down

0 comments on commit 7eaa157

Please sign in to comment.