From b45a4ffd33f123a77f480725ea5dd9c7a3bfc143 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Mon, 16 May 2016 08:56:55 -0400 Subject: Fix leading zero handling in Py11's BigInteger encoder. --- py11/attributes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) -- cgit v1.2.3