From 3d7f714936456d7a9a5530dac15ab1ecbef8054f Mon Sep 17 00:00:00 2001 From: Pol Henarejos Date: Tue, 5 Sep 2023 18:44:12 +0200 Subject: [PATCH] Fix initialization with so-pin. Signed-off-by: Pol Henarejos --- tools/pico-hsm-tool.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tools/pico-hsm-tool.py b/tools/pico-hsm-tool.py index 72d30e6..012c15f 100644 --- a/tools/pico-hsm-tool.py +++ b/tools/pico-hsm-tool.py @@ -39,7 +39,7 @@ except ModuleNotFoundError: sys.exit(-1) try: - from picohsm import PicoHSM, PinType, DOPrefixes, KeyType, EncryptionMode, utils + from picohsm import PicoHSM, PinType, DOPrefixes, KeyType, EncryptionMode, utils, APDUResponse, SWCodes except ModuleNotFoundError: print('ERROR: picohsm module not found! Install picohsm package.\nTry with `pip install pypicohsm`') sys.exit(-1) @@ -188,13 +188,19 @@ def initialize(picohsm, args): _ = input('[Press enter to confirm]') if (args.pin): - picohsm.login(args.pin) - pin = args + try: + picohsm.login(args.pin) + except APDUResponse: + pass + pin = args.pin else: pin = '648219' if (args.so_pin): - picohsm.login(args.pin, who=PinType.SO_PIN) + try: + picohsm.login(args.so_pin, who=PinType.SO_PIN) + except APDUResponse: + pass so_pin = args.so_pin else: so_pin = '57621880'