diff --git a/keepkeyctl b/keepkeyctl index b6d105a8..113af94a 100755 --- a/keepkeyctl +++ b/keepkeyctl @@ -297,7 +297,7 @@ class Commands(object): raise Exception("Must provide firmware filename or URL") if args.file: - fp = open(args.file, 'r') + fp = open(args.file, 'rb') elif args.url: print("Downloading from", args.url) resp = urllib.urlretrieve(args.url) @@ -316,8 +316,9 @@ class Commands(object): fp_old.close() fp.seek(0) - if fp.read(4) != 'KPKY': - raise Exception("KeepKey firmware header expected") + magic = fp.read(4).decode("utf-8") + if magic != 'KPKY': + raise Exception("KeepKey firmware header expected. magic={}".format(magic)) print("Please confirm action on device...")