[pkg-opensc-commit] [libp11] 08/51: UI user_data passed to pkcs11_authenticate()
Eric Dorland
eric at moszumanska.debian.org
Wed Dec 7 17:51:30 UTC 2016
This is an automated email from the git hooks/post-receive script.
eric pushed a commit to branch master
in repository libp11.
commit 4e6087f2ff3a61214f2af725b9eabdc3fff94c4b
Author: Michał Trojnara <Michal.Trojnara at stunnel.org>
Date: Sat Oct 1 22:51:50 2016 +0200
UI user_data passed to pkcs11_authenticate()
Closes #113
---
src/eng_back.c | 2 +-
src/libp11-int.h | 4 +++-
src/libp11.h | 3 ++-
src/p11_front.c | 4 ++--
src/p11_key.c | 5 ++++-
5 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/src/eng_back.c b/src/eng_back.c
index 62f458a..dc11d42 100644
--- a/src/eng_back.c
+++ b/src/eng_back.c
@@ -808,7 +808,7 @@ static EVP_PKEY *pkcs11_load_key(ENGINE_CTX *ctx, const char *s_slot_key_id,
}
if (selected_key != NULL) {
- PKCS11_set_ui_method(selected_key, ui_method);
+ PKCS11_set_ui_method(selected_key, ui_method, callback_data);
pk = isPrivate ?
PKCS11_get_private_key(selected_key) :
PKCS11_get_public_key(selected_key);
diff --git a/src/libp11-int.h b/src/libp11-int.h
index 3929f65..6232440 100644
--- a/src/libp11-int.h
+++ b/src/libp11-int.h
@@ -95,6 +95,7 @@ typedef struct pkcs11_key_private {
CK_OBJECT_HANDLE object;
CK_BBOOL always_authenticate;
UI_METHOD *ui_method;
+ void *ui_user_data;
unsigned char id[255];
size_t id_len;
PKCS11_KEY_ops *ops;
@@ -276,7 +277,8 @@ extern int pkcs11_enumerate_certs(PKCS11_TOKEN *token,
PKCS11_CERT **certs, unsigned int *ncerts);
/* Set UI method to allow retrieving PIN values interactively */
-extern int pkcs11_set_ui_method(PKCS11_KEY *key, UI_METHOD *ui_method);
+extern int pkcs11_set_ui_method(PKCS11_KEY *key,
+ UI_METHOD *ui_method, void *ui_user_data);
/* Initialize a token */
extern int pkcs11_init_token(PKCS11_TOKEN * token, const char *pin,
diff --git a/src/libp11.h b/src/libp11.h
index a1c521c..fa24802 100644
--- a/src/libp11.h
+++ b/src/libp11.h
@@ -282,7 +282,8 @@ extern PKCS11_KEY *PKCS11_find_key_from_key(PKCS11_KEY *);
extern int PKCS11_enumerate_certs(PKCS11_TOKEN *, PKCS11_CERT **, unsigned int *);
/* Set UI method to allow retrieving PIN values interactively */
-extern int PKCS11_set_ui_method(PKCS11_KEY *key, UI_METHOD *ui_method);
+extern int PKCS11_set_ui_method(PKCS11_KEY *key,
+ UI_METHOD *ui_method, void *ui_user_data);
/**
* Initialize a token
diff --git a/src/p11_front.c b/src/p11_front.c
index f69031f..6844cb8 100644
--- a/src/p11_front.c
+++ b/src/p11_front.c
@@ -379,11 +379,11 @@ int PKCS11_generate_random(PKCS11_SLOT *slot, unsigned char *r, unsigned int r_l
return pkcs11_generate_random(slot, r, r_len);
}
-int PKCS11_set_ui_method(PKCS11_KEY *key, UI_METHOD *ui_method)
+int PKCS11_set_ui_method(PKCS11_KEY *key, UI_METHOD *ui_method, void *ui_user_data)
{
if (check_key_fork(key) < 0)
return -1;
- return pkcs11_set_ui_method(key, ui_method);
+ return pkcs11_set_ui_method(key, ui_method, ui_user_data);
}
/* External interface to the deprecated features */
diff --git a/src/p11_key.c b/src/p11_key.c
index 229dab4..7cc5b4f 100644
--- a/src/p11_key.c
+++ b/src/p11_key.c
@@ -39,12 +39,14 @@ static int pkcs11_store_key(PKCS11_TOKEN *, EVP_PKEY *, unsigned int,
char *, unsigned char *, size_t, PKCS11_KEY **);
/* Set UI method to allow retrieving PIN values interactively */
-int pkcs11_set_ui_method(PKCS11_KEY *key, UI_METHOD *ui_method)
+int pkcs11_set_ui_method(PKCS11_KEY *key,
+ UI_METHOD *ui_method, void *ui_user_data)
{
PKCS11_KEY_private *kpriv = PRIVKEY(key);
if (kpriv == NULL)
return -1;
kpriv->ui_method = ui_method;
+ kpriv->ui_user_data = ui_user_data;
return 0;
}
@@ -362,6 +364,7 @@ int pkcs11_authenticate(PKCS11_KEY *key)
if (ui == NULL)
return PKCS11_UI_FAILED;
UI_set_method(ui, kpriv->ui_method);
+ UI_add_user_data(ui, kpriv->ui_user_data);
if (!UI_add_input_string(ui, "PKCS#11 key PIN: ",
UI_INPUT_FLAG_DEFAULT_PWD, pin, 1, MAX_PIN_LENGTH)) {
UI_free(ui);
--
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