diff options
author | Henryk Plötz <henryk@ploetzli.ch> | 2010-03-03 05:28:48 +0100 |
---|---|---|
committer | Henryk Plötz <henryk@ploetzli.ch> | 2010-03-03 05:28:48 +0100 |
commit | 9fbc745bd0fde9bf5a3d3406cacde474309fa84e (patch) | |
tree | 28b9c962126b543e174e8bd32ed70b72ae5fd43c | |
parent | 41bb2396b6c575885830869dc4cb441c24f1ca27 (diff) |
Change behavior of defaults, possible API CHANGE, hope it's not too intrusive
+ Change R_APDU parser and data default to allow construction of empty R_APDUs
+ Default unspecified C_APDU fields to None instead of 0, makes distinction of Le=0 vs. Le not present externally visible
-rw-r--r-- | utils.py | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -124,7 +124,7 @@ def _unformat_hexdump(dump): def _make_byte_property(prop): "Make a byte property(). This is meta code." - return property(lambda self: getattr(self, "_"+prop, getattr(self, "_DEFAULT_"+prop, 0)), + return property(lambda self: getattr(self, "_"+prop, getattr(self, "_DEFAULT_"+prop, None)), lambda self, value: self._setbyte(prop, value), lambda self: delattr(self, "_"+prop), "The %s attribute of the APDU" % prop) @@ -177,7 +177,7 @@ class APDU(object): setattr(self, name, value) def _getdata(self): - return getattr(self, "_data", []) + return getattr(self, "_data", "") def _setdata(self, value): if isinstance(value, str): self._data = "".join([e for e in value]) @@ -444,6 +444,9 @@ class R_APDU(APDU): def parse(self, apdu): "Parse a full response APDU and assign the values to our object, overwriting whatever there was." + if len(apdu) == 0: # To be filled in later + return + self.SW = apdu[-2:] self.data = apdu[:-2] |