aboutsummaryrefslogtreecommitdiff
path: root/cryptech/libhal.py
diff options
context:
space:
mode:
Diffstat (limited to 'cryptech/libhal.py')
-rw-r--r--cryptech/libhal.py10
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)