add callback_data parameter to get_pin; supplied by Douglas E. Engert <deengert@anl.gov>

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2317 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
nils 2005-04-23 12:26:00 +00:00
parent d9e2a443e3
commit 45879d3997
2 changed files with 12 additions and 6 deletions

View File

@ -272,13 +272,16 @@ int set_pin(const char *_pin)
return 1;
}
char *get_pin(UI_METHOD * ui_method, char *sc_pin, int maxlen)
static char *get_pin(UI_METHOD * ui_method, void *callback_data, char *sc_pin, int maxlen)
{
UI *ui;
ui = UI_new();
if (ui_method)
if (ui_method != NULL)
UI_set_method(ui, ui_method);
if (callback_data != NULL)
UI_set_app_data(ui, callback_data);
if (!UI_add_input_string(ui, "SmartCard PIN: ", 0, sc_pin, 1, maxlen)) {
fprintf(stderr, "UI_add_input_string failed\n");
UI_free(ui);
@ -311,7 +314,7 @@ EVP_PKEY *opensc_load_private_key(ENGINE * e, const char *s_key_id,
EVP_PKEY_free(key_out);
return NULL;
}
if (!get_pin(ui_method, sc_pin, 12)) {
if (!get_pin(ui_method, callback_data, sc_pin, 12)) {
fprintf(stderr, "Failed to get pin\n");
unset_pin();
EVP_PKEY_free(key_out);

View File

@ -60,13 +60,16 @@ int inc_verbose()
return 1;
}
char *get_pin(UI_METHOD * ui_method, char *sc_pin, int maxlen)
static char *get_pin(UI_METHOD * ui_method, void *callback_data, char *sc_pin, int maxlen)
{
UI *ui;
ui = UI_new();
if (ui_method)
if (ui_method != NULL)
UI_set_method(ui, ui_method);
if (callback_data != NULL)
UI_set_app_data(ui, callback_data);
if (!UI_add_input_string(ui, "PKCS#11 token PIN: ", 0, sc_pin, 1, maxlen)) {
fprintf(stderr, "UI_add_input_string failed\n");
UI_free(ui);
@ -509,7 +512,7 @@ EVP_PKEY *pkcs11_load_key(ENGINE * e, const char *s_slot_key_id,
if (pin == NULL) {
pin = (char *) calloc(12, sizeof(char));
if (!tok->secureLogin)
get_pin(ui_method, pin, 12);
get_pin(ui_method, callback_data, pin, 12);
}
if (PKCS11_login(slot, 0, pin)) {
if(pin != NULL) {