cards: reset uninitalized EF.AD

The contents of EF.AD me be uninitalized (all bytes set to 0xff). If
this is the case reset all bytes of the file to 0x00 and continue the
update of EF.AD with this value.

Change-Id: I57cf53e0c540469f11b6d85bd3daf3f9e14c237e
This commit is contained in:
Philipp Maier 2020-05-11 21:28:52 +02:00 committed by laforge
parent 7f1d3c496f
commit 7f9f64ac2a
1 changed files with 7 additions and 2 deletions

View File

@ -148,8 +148,13 @@ class Card(object):
if mnclen > 3:
raise RuntimeError('unable to calculate proper mnclen')
data = self._scc.read_binary(EF['AD'], length=None, offset=0)
content = data[0][0:6] + "%02X" % mnclen
data, sw = self._scc.read_binary(EF['AD'], length=None, offset=0)
# Reset contents to EF.AD in case the file is uninintalized
if data.lower() == "ffffffff":
data = "00000000"
content = data[0:6] + "%02X" % mnclen
data, sw = self._scc.update_binary(EF['AD'], content)
return sw