From 7c877ebea2431c901957345df7ca3114c3a8a6cf Mon Sep 17 00:00:00 2001 From: Pol Henarejos Date: Mon, 7 Nov 2022 22:31:19 +0100 Subject: [PATCH] Using file_out parameter. Signed-off-by: Pol Henarejos --- tools/pico-hsm-tool.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/pico-hsm-tool.py b/tools/pico-hsm-tool.py index 8b836cf..ea488d1 100644 --- a/tools/pico-hsm-tool.py +++ b/tools/pico-hsm-tool.py @@ -428,7 +428,13 @@ def cipher(card, args): data += [0x83, len(args.aad)] + list(args.aad) ret = send_apdu(card, [0x80, 0x78], int(args.key), alg, data) - sys.stdout.buffer.write(bytes(ret)) + if (args.file_out): + fout = open(args.file_out, 'wb') + else: + fout = sys.stdout.buffer + fout.write(bytes(ret)) + if (args.file_out): + fout.close() def main(args): sys.stderr.buffer.write(b'Pico HSM Tool v1.8\n')