From f87603cc9713d34b3488bddce4acd9d787ecd8fe Mon Sep 17 00:00:00 2001 From: Ludovic Rousseau Date: Wed, 31 Mar 2021 12:21:18 +0200 Subject: [PATCH 1/2] Use an floor division to fix a Python 3 error File "python-yubico/util/yubikey-totp", line 106, in make_totp secret = struct.pack("> Q", args.time / args.step).ljust(64, chr(0x0)) struct.error: required argument is not an integer --- util/yubikey-totp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/yubikey-totp b/util/yubikey-totp index 9ace901..026232c 100755 --- a/util/yubikey-totp +++ b/util/yubikey-totp @@ -103,7 +103,7 @@ def make_totp(args): print("Serial : %i" % YK.serial()) print("") # Do challenge-response - secret = struct.pack("> Q", args.time / args.step).ljust(64, chr(0x0)) + secret = struct.pack("> Q", args.time // args.step).ljust(64, chr(0x0)) if args.debug: print("Sending challenge : %s\n" % (binascii.hexlify(secret))) response = YK.challenge_response(secret, slot=args.slot) From b16dc8ca99e1f5a1c43cdae2eac24bf9adb50058 Mon Sep 17 00:00:00 2001 From: Ludovic Rousseau Date: Wed, 31 Mar 2021 12:23:48 +0200 Subject: [PATCH 2/2] Use a byte string to fix a Python3 error File "python-yubico/util/yubikey-totp", line 106, in make_totp secret = struct.pack("> Q", args.time // args.step).ljust(64, chr(0x0)) TypeError: ljust() argument 2 must be a byte string of length 1, not str --- util/yubikey-totp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/yubikey-totp b/util/yubikey-totp index 026232c..cecf355 100755 --- a/util/yubikey-totp +++ b/util/yubikey-totp @@ -103,7 +103,7 @@ def make_totp(args): print("Serial : %i" % YK.serial()) print("") # Do challenge-response - secret = struct.pack("> Q", args.time // args.step).ljust(64, chr(0x0)) + secret = struct.pack("> Q", args.time // args.step).ljust(64, b'\0') if args.debug: print("Sending challenge : %s\n" % (binascii.hexlify(secret))) response = YK.challenge_response(secret, slot=args.slot)