From e1550002097a60173834d73b36cb9b146cbd3963 Mon Sep 17 00:00:00 2001 From: Klas Lindfors Date: Mon, 3 Feb 2014 15:13:25 +0100 Subject: [PATCH] print version --- yubico-piv-tool.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/yubico-piv-tool.c b/yubico-piv-tool.c index a6e5e34..e1d90fb 100644 --- a/yubico-piv-tool.c +++ b/yubico-piv-tool.c @@ -208,6 +208,22 @@ static bool authenticate(SCARDHANDLE *card, unsigned char *key, int verbose) { return false; } +static void print_version(SCARDHANDLE *card, int verbose) { + APDU apdu; + unsigned char data[0xff]; + unsigned long recv_len = sizeof(data); + int sw; + + memset(apdu.raw, 0, sizeof(apdu)); + apdu.st.ins = 0xfd; + sw = send_data(card, apdu, 4, data, &recv_len, verbose); + if(sw == 0x9000) { + printf("Applet version %d.%d.%d found.\n", data[0], data[1], data[2]); + } else { + printf("Applet version not found. Status code: %x\n", sw); + } +} + int send_data(SCARDHANDLE *card, APDU apdu, unsigned int send_len, unsigned char *data, unsigned long *recv_len, int verbose) { long rc; int sw; @@ -295,5 +311,7 @@ int main(int argc, char *argv[]) { return EXIT_FAILURE; } + print_version(&card, args_info.verbose_flag); + return EXIT_SUCCESS; }