diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2001-06-23 12:50:06 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2001-06-23 12:50:06 +0000 |
commit | 429266b7e4b494b72e16045d47ffc5c3e378a9bf (patch) | |
tree | c2cbc4ac27fd5a6c21b1f93d7ccc5aebee46ab69 | |
parent | 2c7bc88d785b40bd12a5080fc3d2ef9445460079 (diff) | |
download | openssl-429266b7e4b494b72e16045d47ffc5c3e378a9bf.tar.gz |
Fix hwcrhk_insert_card.
-rw-r--r-- | crypto/engine/hw_ncipher.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/crypto/engine/hw_ncipher.c b/crypto/engine/hw_ncipher.c index 1b9254c321..b2af378960 100644 --- a/crypto/engine/hw_ncipher.c +++ b/crypto/engine/hw_ncipher.c @@ -1175,7 +1175,7 @@ static int hwcrhk_insert_card(const char *prompt_info, HWCryptoHook_PassphraseContext *ppctx, HWCryptoHook_CallerContext *cactx) { - int ok = 1; + int ok = -1; UI *ui; void *callback_data = NULL; UI_METHOD *ui_method = NULL; @@ -1211,7 +1211,7 @@ static int hwcrhk_insert_card(const char *prompt_info, BIO_snprintf(buf, sizeof(buf)-1, "Current card: \"%s\"\n", wrong_info); ok = UI_dup_info_string(ui, buf); - if (ok == 0 && prompt_info) + if (ok && prompt_info) { BIO_snprintf(buf, sizeof(buf)-1, "Insert card \"%s\"\n then hit <enter> or C<enter> to cancel\n", prompt_info); @@ -1219,15 +1219,20 @@ static int hwcrhk_insert_card(const char *prompt_info, answer, 0, sizeof(answer)-1); } UI_add_user_data(ui, callback_data); - if (ok == 0) + if (ok) ok = UI_process(ui); UI_free(ui); - if (strchr("Cc",answer[0]) == 0) + /* If canceled input treat as 'cancel' */ + if (ok == -2) + ok = 1; + else if(ok != 0) + ok = -1; + else if (answer[0] == 'c' || answer[0] == 'C') ok = 1; + else + ok = 0; } - if (ok == 0) - return 0; - return -1; + return ok; } static void hwcrhk_log_message(void *logstr, const char *message) |