From cb88d3245e71ddfdf6e45a59fb0d66158f3f5af1 Mon Sep 17 00:00:00 2001 From: Dain Nilsson Date: Wed, 29 May 2024 16:56:52 +0200 Subject: [PATCH] Send extended APDUs by default in the "apdu" command --- ykman/_cli/apdu.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ykman/_cli/apdu.py b/ykman/_cli/apdu.py index b7ef0752..ccfe7ec0 100644 --- a/ykman/_cli/apdu.py +++ b/ykman/_cli/apdu.py @@ -29,6 +29,7 @@ from yubikit.core.smartcard import ( SmartCardConnection, SmartCardProtocol, + ApduFormat, ApduError, SW, AID, @@ -102,9 +103,10 @@ def _print_response(resp: bytes, sw: int, no_pretty: bool) -> None: required=False, help="select application", ) +@click.option("--short", is_flag=True, help="use short APDUs instead of extended") @click.argument("apdu", nargs=-1) @click.option("-s", "--send-apdu", multiple=True, help="provide full APDUs") -def apdu(ctx, no_pretty, app, apdu, send_apdu): +def apdu(ctx, no_pretty, app, short, apdu, send_apdu): """ Execute arbitrary APDUs. Provide APDUs as a hex encoded, space-separated list using the following syntax: @@ -150,6 +152,11 @@ def apdu(ctx, no_pretty, app, apdu, send_apdu): else: params = None + if not short: + protocol.apdu_format = ApduFormat.EXTENDED + elif params: + ctx.fail("--short cannot be used with SCP") + if app: is_first = False click.echo("SELECT AID: " + _hex(app))