diff options
author | Rob Austein <sra@hactrn.net> | 2016-05-16 08:56:55 -0400 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2016-05-16 08:56:55 -0400 |
commit | b45a4ffd33f123a77f480725ea5dd9c7a3bfc143 (patch) | |
tree | 1ecd408a8503bdd7e545cc8227cd48f3eb59a3f1 | |
parent | dddf744a3cfb4f58f07eb983a4788d83f261b860 (diff) |
Fix leading zero handling in Py11's BigInteger encoder.
-rw-r--r-- | py11/attributes.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/py11/attributes.py b/py11/attributes.py index 32cf940..56473ad 100644 --- a/py11/attributes.py +++ b/py11/attributes.py @@ -42,7 +42,7 @@ class Attribute_CK_ULONG(Attribute): def decode(self, x): return unpack("L", x)[0] class Attribute_biginteger(Attribute): - def encode(self, x): return ("%*x" % (((x.bit_length() + 7) / 8) * 2, x)).decode("hex") + def encode(self, x): return "\x00" if x == 0 else ("%0*x" % (((x.bit_length() + 7) / 8) * 2, x)).decode("hex") def decode(self, x): return long(x.encode("hex"), 16) |