From a8c84d490a76cb3caddafed022b16dda3f63e837 Mon Sep 17 00:00:00 2001 From: Frank Morgner Date: Tue, 29 Jan 2019 17:03:33 +0100 Subject: [PATCH] handle multiple verifications when changing secret --- src/tools/goid-tool.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/tools/goid-tool.c b/src/tools/goid-tool.c index 100b7524..3eb93aa7 100644 --- a/src/tools/goid-tool.c +++ b/src/tools/goid-tool.c @@ -252,10 +252,25 @@ soc_change(sc_card_t *card, unsigned char p1, unsigned char p2) { int ok = 0; sc_apdu_t apdu; - sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0x24, 0x00, p2); + sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0x24, p1, p2); SC_TEST_GOTO_ERR(card->ctx, SC_LOG_DEBUG_VERBOSE_TOOL, sc_transmit_apdu(card, &apdu), "Changing secret failed"); + while (apdu.sw1 == 0x91 && apdu.sw2 == 0x00) { + switch (p2) { + case 0x80: + sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE_TOOL, + "Verify your PIN on the card using the same position."); + break; + case 0x40: + sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE_TOOL, + "Verify your finger print on the card using the same position."); + break; + } + SC_TEST_GOTO_ERR(card->ctx, SC_LOG_DEBUG_VERBOSE_TOOL, + sc_transmit_apdu(card, &apdu), + "Changing secret failed"); + } SC_TEST_GOTO_ERR(card->ctx, SC_LOG_DEBUG_VERBOSE_TOOL, sc_check_sw(card, apdu.sw1, apdu.sw2), "Verification failed");