diff options
author | Rob Austein <sra@hactrn.net> | 2020-06-09 18:34:06 -0400 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2020-06-09 18:34:06 -0400 |
commit | 2f21fc43638cf39da07ab85dd21546bc34515730 (patch) | |
tree | 1664aac76b2948d089a9ac9b69d8abb443f04b32 /cryptech | |
parent | ed4c22473f5fb07006e773137ed047950e25a4d8 (diff) |
Whack with club until Python 2 works again and Python 3 almost works
There's still something wrong with XDR for attribute lists in Python
3, XDR complains that there's unconsumed data and attributes coming
back are (sometimes truncated). Python 2 works. Probably data type
issue somewhere but haven't spotted it yet.
Diffstat (limited to 'cryptech')
-rw-r--r-- | cryptech/libhal.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/cryptech/libhal.py b/cryptech/libhal.py index 56712cb..1e2dbc6 100644 --- a/cryptech/libhal.py +++ b/cryptech/libhal.py @@ -490,18 +490,19 @@ class HSM(object): msg = slip_decode(b"".join(msg)) if not msg: continue - msg = ContextManagedUnpacker(b"".join(msg)) + msg = ContextManagedUnpacker(msg) if msg.unpack_uint() != code: continue return msg _pack_builtin = ((int, "_pack_uint"), - (str, "_pack_bytes"), + (bytes, "_pack_bytes"), + (str, "_pack_str"), ((list, tuple, set), "_pack_array"), (dict, "_pack_items")) try: - _pack_builtin += (long, "_pack_uint") + _pack_builtin += ((long, "_pack_uint"),) except NameError: # "long" merged with "int" in Python 3 pass @@ -523,6 +524,9 @@ class HSM(object): def _pack_bytes(self, packer, arg): packer.pack_bytes(arg) + def _pack_str(self, packer, arg): + packer.pack_bytes(arg.encode()) + def _pack_array(self, packer, arg): packer.pack_uint(len(arg)) self._pack_args(packer, arg) |