[pkg-opensc-commit] [libp11] 04/12: Renamed symbols defined in eng_back.c
Eric Dorland
eric at moszumanska.debian.org
Sat Jan 28 08:45:04 UTC 2017
This is an automated email from the git hooks/post-receive script.
eric pushed a commit to branch master
in repository libp11.
commit 4303db536fbb7c2775ed46ca3237b93689000b69
Author: Michał Trojnara <Michal.Trojnara at stunnel.org>
Date: Thu Jan 12 22:18:01 2017 +0100
Renamed symbols defined in eng_back.c
This will prevent confusion with libp11 private symbol names.
---
src/eng_back.c | 96 ++++++++++++++++++++++++++++-----------------------------
src/eng_front.c | 20 ++++++------
src/engine.h | 14 ++++-----
3 files changed, 65 insertions(+), 65 deletions(-)
diff --git a/src/eng_back.c b/src/eng_back.c
index 2f210fd..4f7ce43 100644
--- a/src/eng_back.c
+++ b/src/eng_back.c
@@ -37,7 +37,7 @@
struct st_engine_ctx {
/* Engine configuration */
/*
- * The PIN used for login. Cache for the get_pin function.
+ * The PIN used for login. Cache for the ctx_get_pin function.
* The memory for this PIN is always owned internally,
* and may be freed as necessary. Before freeing, the PIN
* must be whitened, to prevent security holes.
@@ -77,7 +77,7 @@ static void dump_hex(FILE *stream, const char *val, const size_t len) {
/******************************************************************************/
/* Free PIN storage in secure way. */
-static void destroy_pin(ENGINE_CTX *ctx)
+static void ctx_destroy_pin(ENGINE_CTX *ctx)
{
if (ctx->pin != NULL) {
OPENSSL_cleanse(ctx->pin, ctx->pin_length);
@@ -91,7 +91,7 @@ static void destroy_pin(ENGINE_CTX *ctx)
* passed to the user interface implemented by an application. Only the
* application knows how to interpret the call-back data.
* A (strdup'ed) copy of the PIN code will be stored in the pin variable. */
-static int get_pin(ENGINE_CTX *ctx, UI_METHOD *ui_method, void *callback_data)
+static int ctx_get_pin(ENGINE_CTX *ctx, UI_METHOD *ui_method, void *callback_data)
{
UI *ui;
@@ -104,7 +104,7 @@ static int get_pin(ENGINE_CTX *ctx, UI_METHOD *ui_method, void *callback_data)
if (callback_data != NULL)
UI_add_user_data(ui, callback_data);
- destroy_pin(ctx);
+ ctx_destroy_pin(ctx);
ctx->pin = OPENSSL_malloc(MAX_PIN_LENGTH+1);
if (ctx->pin == NULL)
return 0;
@@ -134,7 +134,7 @@ static int get_pin(ENGINE_CTX *ctx, UI_METHOD *ui_method, void *callback_data)
* @callback_data are application data to the user interface
* @return 1 on success, 0 on error.
*/
-static int pkcs11_login(ENGINE_CTX *ctx, PKCS11_SLOT *slot, PKCS11_TOKEN *tok,
+static int ctx_login(ENGINE_CTX *ctx, PKCS11_SLOT *slot, PKCS11_TOKEN *tok,
UI_METHOD *ui_method, void *callback_data)
{
int already_logged_in = 0;
@@ -154,8 +154,8 @@ static int pkcs11_login(ENGINE_CTX *ctx, PKCS11_SLOT *slot, PKCS11_TOKEN *tok,
* then use a NULL PIN. Otherwise, obtain a new PIN if needed. */
if (tok->secureLogin) {
/* Free the PIN if it has already been
- * assigned (i.e, cached by get_pin) */
- destroy_pin(ctx);
+ * assigned (i.e, cached by ctx_get_pin) */
+ ctx_destroy_pin(ctx);
} else if (ctx->pin == NULL) {
ctx->pin = OPENSSL_malloc(MAX_PIN_LENGTH+1);
ctx->pin_length = MAX_PIN_LENGTH;
@@ -164,8 +164,8 @@ static int pkcs11_login(ENGINE_CTX *ctx, PKCS11_SLOT *slot, PKCS11_TOKEN *tok,
return 0;
}
memset(ctx->pin, 0, MAX_PIN_LENGTH+1);
- if (!get_pin(ctx, ui_method, callback_data)) {
- destroy_pin(ctx);
+ if (!ctx_get_pin(ctx, ui_method, callback_data)) {
+ ctx_destroy_pin(ctx);
fprintf(stderr, "No PIN code was entered\n");
return 0;
}
@@ -174,7 +174,7 @@ static int pkcs11_login(ENGINE_CTX *ctx, PKCS11_SLOT *slot, PKCS11_TOKEN *tok,
/* Now login in with the (possibly NULL) PIN */
if (PKCS11_login(slot, 0, ctx->pin)) {
/* Login failed, so free the PIN if present */
- destroy_pin(ctx);
+ ctx_destroy_pin(ctx);
fprintf(stderr, "Login failed\n");
return 0;
}
@@ -185,7 +185,7 @@ static int pkcs11_login(ENGINE_CTX *ctx, PKCS11_SLOT *slot, PKCS11_TOKEN *tok,
/* Initialization and cleanup */
/******************************************************************************/
-ENGINE_CTX *pkcs11_new()
+ENGINE_CTX *ctx_new()
{
ENGINE_CTX *ctx;
char *mod;
@@ -216,12 +216,12 @@ ENGINE_CTX *pkcs11_new()
return ctx;
}
-/* Destroy the context allocated with pkcs11_new() */
-int pkcs11_destroy(ENGINE_CTX *ctx)
+/* Destroy the context allocated with ctx_new() */
+int ctx_destroy(ENGINE_CTX *ctx)
{
if (ctx) {
- pkcs11_finish(ctx);
- destroy_pin(ctx);
+ ctx_finish(ctx);
+ ctx_destroy_pin(ctx);
OPENSSL_free(ctx->module);
OPENSSL_free(ctx->init_args);
#if OPENSSL_VERSION_NUMBER >= 0x10100004L
@@ -236,7 +236,7 @@ int pkcs11_destroy(ENGINE_CTX *ctx)
}
/* Initialize libp11 data: ctx->pkcs11_ctx and ctx->slot_list */
-static void pkcs11_init_libp11_unlocked(ENGINE_CTX *ctx)
+static void ctx_init_libp11_unlocked(ENGINE_CTX *ctx)
{
PKCS11_CTX *pkcs11_ctx;
PKCS11_SLOT *slot_list = NULL;
@@ -272,7 +272,7 @@ static void pkcs11_init_libp11_unlocked(ENGINE_CTX *ctx)
ctx->slot_count = slot_count;
}
-static int pkcs11_init_libp11(ENGINE_CTX *ctx)
+static int ctx_init_libp11(ENGINE_CTX *ctx)
{
#if OPENSSL_VERSION_NUMBER >= 0x10100004L
CRYPTO_THREAD_write_lock(ctx->rwlock);
@@ -281,7 +281,7 @@ static int pkcs11_init_libp11(ENGINE_CTX *ctx)
CRYPTO_w_lock(ctx->rwlock);
#endif
if (ctx->pkcs11_ctx == NULL || ctx->slot_list == NULL)
- pkcs11_init_libp11_unlocked(ctx);
+ ctx_init_libp11_unlocked(ctx);
#if OPENSSL_VERSION_NUMBER >= 0x10100004L
CRYPTO_THREAD_unlock(ctx->rwlock);
#else
@@ -292,7 +292,7 @@ static int pkcs11_init_libp11(ENGINE_CTX *ctx)
}
/* Function called from ENGINE_init() */
-int pkcs11_init(ENGINE_CTX *ctx)
+int ctx_init(ENGINE_CTX *ctx)
{
/* OpenSC implicitly locks CRYPTO_LOCK_ENGINE during C_GetSlotList().
* OpenSSL also locks CRYPTO_LOCK_ENGINE in ENGINE_init().
@@ -307,7 +307,7 @@ int pkcs11_init(ENGINE_CTX *ctx)
CRYPTO_get_dynlock_lock_callback() == NULL ||
CRYPTO_get_dynlock_destroy_callback() == NULL) {
CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
- pkcs11_init_libp11_unlocked(ctx);
+ ctx_init_libp11_unlocked(ctx);
CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
return ctx->pkcs11_ctx && ctx->slot_list ? 1 : 0;
}
@@ -315,8 +315,8 @@ int pkcs11_init(ENGINE_CTX *ctx)
return 1;
}
-/* Finish engine operations initialized with pkcs11_init() */
-int pkcs11_finish(ENGINE_CTX *ctx)
+/* Finish engine operations initialized with ctx_init() */
+int ctx_finish(ENGINE_CTX *ctx)
{
if (ctx) {
if (ctx->slot_list) {
@@ -327,7 +327,7 @@ int pkcs11_finish(ENGINE_CTX *ctx)
}
if (ctx->pkcs11_ctx) {
/* Modules cannot be unloaded in pkcs11_finish() nor
- * pkcs11_destroy() because of a deadlock in PKCS#11
+ * ctx_destroy() because of a deadlock in PKCS#11
* modules that internally use OpenSSL engines.
* A memory leak is better than a deadlock... */
/* PKCS11_CTX_unload(ctx->pkcs11_ctx); */
@@ -345,7 +345,7 @@ int pkcs11_finish(ENGINE_CTX *ctx)
/* prototype for OpenSSL ENGINE_load_cert */
/* used by load_cert_ctrl via ENGINE_ctrl for now */
-static X509 *pkcs11_load_cert(ENGINE_CTX *ctx, const char *s_slot_cert_id)
+static X509 *ctx_load_cert(ENGINE_CTX *ctx, const char *s_slot_cert_id)
{
PKCS11_SLOT *slot;
PKCS11_SLOT *found_slot = NULL;
@@ -361,7 +361,7 @@ static X509 *pkcs11_load_cert(ENGINE_CTX *ctx, const char *s_slot_cert_id)
int slot_nr = -1;
char flags[64];
- if (pkcs11_init_libp11(ctx)) /* Delayed libp11 initialization */
+ if (ctx_init_libp11(ctx)) /* Delayed libp11 initialization */
return NULL;
if (s_slot_cert_id && *s_slot_cert_id) {
@@ -370,7 +370,7 @@ static X509 *pkcs11_load_cert(ENGINE_CTX *ctx, const char *s_slot_cert_id)
cert_id, &cert_id_len,
tmp_pin, &tmp_pin_len, &cert_label);
if (n && tmp_pin_len > 0 && tmp_pin[0] != 0) {
- destroy_pin(ctx);
+ ctx_destroy_pin(ctx);
ctx->pin = OPENSSL_malloc(MAX_PIN_LENGTH+1);
if (ctx->pin != NULL) {
memset(ctx->pin, 0, MAX_PIN_LENGTH+1);
@@ -496,7 +496,7 @@ static X509 *pkcs11_load_cert(ENGINE_CTX *ctx, const char *s_slot_cert_id)
/* In several tokens certificates are marked as private.
* We require a cached pin, as no UI method is available. */
- if (ctx->pin && !pkcs11_login(ctx, slot, tok, NULL, NULL)) {
+ if (ctx->pin && !ctx_login(ctx, slot, tok, NULL, NULL)) {
fprintf(stderr, "Login to token failed, returning NULL...\n");
return NULL;
}
@@ -536,7 +536,7 @@ static X509 *pkcs11_load_cert(ENGINE_CTX *ctx, const char *s_slot_cert_id)
return x509;
}
-static int ctrl_load_cert(ENGINE_CTX *ctx, void *p)
+static int ctx_ctrl_load_cert(ENGINE_CTX *ctx, void *p)
{
struct {
const char *s_slot_cert_id;
@@ -546,7 +546,7 @@ static int ctrl_load_cert(ENGINE_CTX *ctx, void *p)
if (parms->cert != NULL)
return 0;
- parms->cert = pkcs11_load_cert(ctx, parms->s_slot_cert_id);
+ parms->cert = ctx_load_cert(ctx, parms->s_slot_cert_id);
if (parms->cert == NULL)
return 0;
@@ -557,7 +557,7 @@ static int ctrl_load_cert(ENGINE_CTX *ctx, void *p)
/* Private and public key handling */
/******************************************************************************/
-static EVP_PKEY *pkcs11_load_key(ENGINE_CTX *ctx, const char *s_slot_key_id,
+static EVP_PKEY *ctx_load_key(ENGINE_CTX *ctx, const char *s_slot_key_id,
UI_METHOD *ui_method, void *callback_data, int isPrivate)
{
PKCS11_SLOT *slot;
@@ -575,7 +575,7 @@ static EVP_PKEY *pkcs11_load_key(ENGINE_CTX *ctx, const char *s_slot_key_id,
size_t tmp_pin_len = MAX_PIN_LENGTH;
char flags[64];
- if (pkcs11_init_libp11(ctx)) /* Delayed libp11 initialization */
+ if (ctx_init_libp11(ctx)) /* Delayed libp11 initialization */
return NULL;
if (ctx->verbose)
@@ -589,7 +589,7 @@ static EVP_PKEY *pkcs11_load_key(ENGINE_CTX *ctx, const char *s_slot_key_id,
tmp_pin, &tmp_pin_len, &key_label);
if (n && tmp_pin_len > 0 && tmp_pin[0] != 0) {
- destroy_pin(ctx);
+ ctx_destroy_pin(ctx);
ctx->pin = OPENSSL_malloc(MAX_PIN_LENGTH+1);
if (ctx->pin != NULL) {
memset(ctx->pin, 0, MAX_PIN_LENGTH+1);
@@ -747,7 +747,7 @@ static EVP_PKEY *pkcs11_load_key(ENGINE_CTX *ctx, const char *s_slot_key_id,
}
/* Perform login to the token if required */
- if (!pkcs11_login(ctx, slot, tok, ui_method, callback_data)) {
+ if (!ctx_login(ctx, slot, tok, ui_method, callback_data)) {
fprintf(stderr, "Login to token failed, returning NULL...\n");
return NULL;
}
@@ -809,12 +809,12 @@ static EVP_PKEY *pkcs11_load_key(ENGINE_CTX *ctx, const char *s_slot_key_id,
return pk;
}
-EVP_PKEY *pkcs11_load_public_key(ENGINE_CTX *ctx, const char *s_key_id,
+EVP_PKEY *ctx_load_pubkey(ENGINE_CTX *ctx, const char *s_key_id,
UI_METHOD *ui_method, void *callback_data)
{
EVP_PKEY *pk;
- pk = pkcs11_load_key(ctx, s_key_id, ui_method, callback_data, 0);
+ pk = ctx_load_key(ctx, s_key_id, ui_method, callback_data, 0);
if (pk == NULL) {
fprintf(stderr, "PKCS11_load_public_key returned NULL\n");
return NULL;
@@ -822,12 +822,12 @@ EVP_PKEY *pkcs11_load_public_key(ENGINE_CTX *ctx, const char *s_key_id,
return pk;
}
-EVP_PKEY *pkcs11_load_private_key(ENGINE_CTX *ctx, const char *s_key_id,
+EVP_PKEY *ctx_load_privkey(ENGINE_CTX *ctx, const char *s_key_id,
UI_METHOD *ui_method, void *callback_data)
{
EVP_PKEY *pk;
- pk = pkcs11_load_key(ctx, s_key_id, ui_method, callback_data, 1);
+ pk = ctx_load_key(ctx, s_key_id, ui_method, callback_data, 1);
if (pk == NULL) {
fprintf(stderr, "PKCS11_get_private_key returned NULL\n");
return NULL;
@@ -839,7 +839,7 @@ EVP_PKEY *pkcs11_load_private_key(ENGINE_CTX *ctx, const char *s_key_id,
/* Engine ctrl request handling */
/******************************************************************************/
-static int ctrl_set_module(ENGINE_CTX *ctx, const char *modulename)
+static int ctx_ctrl_set_module(ENGINE_CTX *ctx, const char *modulename)
{
OPENSSL_free(ctx->module);
ctx->module = modulename ? OPENSSL_strdup(modulename) : NULL;
@@ -859,7 +859,7 @@ static int ctrl_set_module(ENGINE_CTX *ctx, const char *modulename)
*
* @return 1 on success, 0 on failure.
*/
-static int ctrl_set_pin(ENGINE_CTX *ctx, const char *pin)
+static int ctx_ctrl_set_pin(ENGINE_CTX *ctx, const char *pin)
{
/* Pre-condition check */
if (pin == NULL) {
@@ -869,7 +869,7 @@ static int ctrl_set_pin(ENGINE_CTX *ctx, const char *pin)
/* Copy the PIN. If the string cannot be copied, NULL
* shall be returned and errno shall be set. */
- destroy_pin(ctx);
+ ctx_destroy_pin(ctx);
ctx->pin = OPENSSL_strdup(pin);
if (ctx->pin != NULL)
ctx->pin_length = strlen(ctx->pin);
@@ -877,35 +877,35 @@ static int ctrl_set_pin(ENGINE_CTX *ctx, const char *pin)
return ctx->pin != NULL;
}
-static int ctrl_inc_verbose(ENGINE_CTX *ctx)
+static int ctx_ctrl_inc_verbose(ENGINE_CTX *ctx)
{
ctx->verbose++;
return 1;
}
-static int ctrl_set_init_args(ENGINE_CTX *ctx, const char *init_args_orig)
+static int ctx_ctrl_set_init_args(ENGINE_CTX *ctx, const char *init_args_orig)
{
OPENSSL_free(ctx->init_args);
ctx->init_args = init_args_orig ? OPENSSL_strdup(init_args_orig) : NULL;
return 1;
}
-int pkcs11_engine_ctrl(ENGINE_CTX *ctx, int cmd, long i, void *p, void (*f)())
+int ctx_engine_ctrl(ENGINE_CTX *ctx, int cmd, long i, void *p, void (*f)())
{
(void)i; /* We don't currently take integer parameters */
(void)f; /* We don't currently take callback parameters */
/*int initialised = ((pkcs11_dso == NULL) ? 0 : 1); */
switch (cmd) {
case CMD_MODULE_PATH:
- return ctrl_set_module(ctx, (const char *)p);
+ return ctx_ctrl_set_module(ctx, (const char *)p);
case CMD_PIN:
- return ctrl_set_pin(ctx, (const char *)p);
+ return ctx_ctrl_set_pin(ctx, (const char *)p);
case CMD_VERBOSE:
- return ctrl_inc_verbose(ctx);
+ return ctx_ctrl_inc_verbose(ctx);
case CMD_LOAD_CERT_CTRL:
- return ctrl_load_cert(ctx, p);
+ return ctx_ctrl_load_cert(ctx, p);
case CMD_INIT_ARGS:
- return ctrl_set_init_args(ctx, (const char *)p);
+ return ctx_ctrl_set_init_args(ctx, (const char *)p);
default:
break;
}
diff --git a/src/eng_front.c b/src/eng_front.c
index d03fa39..8a8d232 100644
--- a/src/eng_front.c
+++ b/src/eng_front.c
@@ -3,7 +3,7 @@
* project 2000.
* Copied/modified by Kevin Stefanik (kstef at mtppi.org) for the OpenSC
* project 2003.
- * Copyright (c) 2016 Michał Trojnara
+ * Copyright (c) 2017 Michał Trojnara
*/
/* ====================================================================
* Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved.
@@ -126,13 +126,13 @@ static ENGINE_CTX *get_ctx(ENGINE *engine)
ctx = ENGINE_get_ex_data(engine, pkcs11_idx);
}
if (ctx == NULL) {
- ctx = pkcs11_new();
+ ctx = ctx_new();
ENGINE_set_ex_data(engine, pkcs11_idx, ctx);
}
return ctx;
}
-/* Destroy the context allocated with pkcs11_new() */
+/* Destroy the context allocated with ctx_new() */
static int engine_destroy(ENGINE *engine)
{
ENGINE_CTX *ctx;
@@ -141,7 +141,7 @@ static int engine_destroy(ENGINE *engine)
ctx = get_ctx(engine);
if (ctx == NULL)
return 0;
- rv = pkcs11_destroy(ctx);
+ rv = ctx_destroy(ctx);
ENGINE_set_ex_data(engine, pkcs11_idx, NULL);
return rv;
}
@@ -153,10 +153,10 @@ static int engine_init(ENGINE *engine)
ctx = get_ctx(engine);
if (ctx == NULL)
return 0;
- return pkcs11_init(ctx);
+ return ctx_init(ctx);
}
-/* Finish engine operations initialized with pkcs11_init() */
+/* Finish engine operations initialized with ctx_init() */
static int engine_finish(ENGINE *engine)
{
ENGINE_CTX *ctx;
@@ -164,7 +164,7 @@ static int engine_finish(ENGINE *engine)
ctx = get_ctx(engine);
if (ctx == NULL)
return 0;
- return pkcs11_finish(ctx);
+ return ctx_finish(ctx);
}
static EVP_PKEY *load_pubkey(ENGINE *engine, const char *s_key_id,
@@ -175,7 +175,7 @@ static EVP_PKEY *load_pubkey(ENGINE *engine, const char *s_key_id,
ctx = get_ctx(engine);
if (ctx == NULL)
return 0;
- return pkcs11_load_public_key(ctx, s_key_id, ui_method, callback_data);
+ return ctx_load_pubkey(ctx, s_key_id, ui_method, callback_data);
}
static EVP_PKEY *load_privkey(ENGINE *engine, const char *s_key_id,
@@ -186,7 +186,7 @@ static EVP_PKEY *load_privkey(ENGINE *engine, const char *s_key_id,
ctx = get_ctx(engine);
if (ctx == NULL)
return 0;
- return pkcs11_load_private_key(ctx, s_key_id, ui_method, callback_data);
+ return ctx_load_privkey(ctx, s_key_id, ui_method, callback_data);
}
static int engine_ctrl(ENGINE *engine, int cmd, long i, void *p, void (*f) ())
@@ -196,7 +196,7 @@ static int engine_ctrl(ENGINE *engine, int cmd, long i, void *p, void (*f) ())
ctx = get_ctx(engine);
if (ctx == NULL)
return 0;
- return pkcs11_engine_ctrl(ctx, cmd, i, p, f);
+ return ctx_engine_ctrl(ctx, cmd, i, p, f);
}
/* This internal function is used by ENGINE_pkcs11() and possibly by the
diff --git a/src/engine.h b/src/engine.h
index 45a5ccf..4cfd53b 100644
--- a/src/engine.h
+++ b/src/engine.h
@@ -51,20 +51,20 @@ typedef struct st_engine_ctx ENGINE_CTX; /* opaque */
/* defined in eng_back.c */
-ENGINE_CTX *pkcs11_new();
+ENGINE_CTX *ctx_new();
-int pkcs11_destroy(ENGINE_CTX *ctx);
+int ctx_destroy(ENGINE_CTX *ctx);
-int pkcs11_init(ENGINE_CTX *ctx);
+int ctx_init(ENGINE_CTX *ctx);
-int pkcs11_finish(ENGINE_CTX *ctx);
+int ctx_finish(ENGINE_CTX *ctx);
-int pkcs11_engine_ctrl(ENGINE_CTX *ctx, int cmd, long i, void *p, void (*f)());
+int ctx_engine_ctrl(ENGINE_CTX *ctx, int cmd, long i, void *p, void (*f)());
-EVP_PKEY *pkcs11_load_public_key(ENGINE_CTX *ctx, const char *s_key_id,
+EVP_PKEY *ctx_load_pubkey(ENGINE_CTX *ctx, const char *s_key_id,
UI_METHOD * ui_method, void *callback_data);
-EVP_PKEY *pkcs11_load_private_key(ENGINE_CTX *ctx, const char *s_key_id,
+EVP_PKEY *ctx_load_privkey(ENGINE_CTX *ctx, const char *s_key_id,
UI_METHOD * ui_method, void *callback_data);
/* defined in eng_parse.c */
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-opensc/libp11.git
More information about the pkg-opensc-commit
mailing list