diff --git a/ykman/cli/otp.py b/ykman/cli/otp.py index 32f3d88f8..8994c541e 100644 --- a/ykman/cli/otp.py +++ b/ykman/cli/otp.py @@ -591,8 +591,8 @@ def chalresp(ctx, slot, key, totp, touch, force, generate): @click.option( "-d", "--digits", - type=click.Choice(["6", "8"]), - default="6", + type=click.Choice(["0", "6", "8"]), + default="0", help="Number of digits in generated TOTP code (default: 6).", ) @click.pass_context @@ -633,7 +633,11 @@ def on_keepalive(status): setattr(on_keepalive, "prompted", True) response = session.calculate_hmac_sha1(slot, challenge, event, on_keepalive) - if totp: + + if totp and digits == "0": + digits = "6" + + if digits != "0": value = format_oath_code(response, int(digits)) else: value = response.hex()