From a5e025a4e5b1430c49cde0022de91522649f7a35 Mon Sep 17 00:00:00 2001 From: Pol Henarejos Date: Mon, 7 Nov 2022 21:37:42 +0100 Subject: [PATCH] If no applet is selected, then select it. Signed-off-by: Pol Henarejos --- tools/pico-hsm-tool.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/pico-hsm-tool.py b/tools/pico-hsm-tool.py index c577a9c..2846bdd 100644 --- a/tools/pico-hsm-tool.py +++ b/tools/pico-hsm-tool.py @@ -84,6 +84,12 @@ def send_apdu(card, command, p1, p2, data=None): apdu = apdu + [p1, p2] + lc + dataf + le response, sw1, sw2 = card.connection.transmit(apdu) if (sw1 != 0x90): + if (sw1 == 0x6A and sw2 == 0x82): + response, sw1, sw2 = card.connection.transmit([0x00, 0xA4, 0x04, 0x00, 0xB, 0xE8, 0x2B, 0x06, 0x01, 0x04, 0x01, 0x81, 0xC3, 0x1F, 0x02, 0x01, 0x0]) + if (sw1 == 0x90): + response, sw1, sw2 = card.connection.transmit(apdu) + if (sw1 == 0x90): + return response raise APDUResponse(sw1, sw2) return response