aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Maier <pmaier@sysmocom.de>2019-03-21 16:21:12 +0100
committerPhilipp Maier <pmaier@sysmocom.de>2019-04-01 15:50:50 +0200
commitee908ae1958eb9da9e6eebfb9aba0c80db17d804 (patch)
tree55d800d7733534bb664163fc5af4bda56f5c21a4
parent2d15ea015e8d4f5d1de638e7790e1be7dce0e0db (diff)
sysmo-usim-sjs1: update EF.AD with correct MNC length
At the moment EF.AD, which contains the length of the MNC is not updated. For two digit MNC (the usual case) this is fine since the length is set to 2 by default. However, when one wants to set an MNC with 3 digit length the file must be updated, otherwise the third digit of the MNC is recognized as part of the MSIN. Change-Id: I827092b2c7f7952f54b2d9f8dbda419a0dbfaf65 Related: OS#3850
-rwxr-xr-xpySim-read.py7
-rw-r--r--pySim/cards.py19
2 files changed, 26 insertions, 0 deletions
diff --git a/pySim-read.py b/pySim-read.py
index 4356453..bcdbca6 100755
--- a/pySim-read.py
+++ b/pySim-read.py
@@ -176,5 +176,12 @@ if __name__ == '__main__':
except Exception as e:
print "MSISDN: Can't read file -- " + str(e)
+ # EF.AD
+ (res, sw) = scc.read_binary(['3f00', '7f20', '6fad'])
+ if sw == '9000':
+ print("AD: %s" % (res,))
+ else:
+ print("AD: Can't read, response code = %s" % (sw,))
+
# Done for this card and maybe for everything ?
print "Done !\n"
diff --git a/pySim/cards.py b/pySim/cards.py
index 1012cfd..fb84a8d 100644
--- a/pySim/cards.py
+++ b/pySim/cards.py
@@ -118,6 +118,20 @@ class Card(object):
data, sw = self._scc.update_record(EF['SMSP'], 1, rpad(smsp, 84))
return sw
+ def update_ad(self, mnc):
+ #See also: 3GPP TS 31.102, chapter 4.2.18
+ mnclen = len(str(mnc))
+ if mnclen == 1:
+ mnclen = 2
+ if mnclen > 3:
+ raise RuntimeError('unable to calculate proper mnclen')
+
+ data = self._scc.read_binary(EF['AD'], length=None, offset=0)
+ size = len(data[0])/2
+ content = data[0][0:6] + "%02X" % mnclen
+ data, sw = self._scc.update_binary(EF['AD'], content)
+ return sw
+
def read_spn(self):
(spn, sw) = self._scc.read_binary(EF['SPN'])
if sw == '9000':
@@ -593,6 +607,11 @@ class SysmoUSIMSJS1(Card):
if sw != '9000':
print("Programming OPLMNwAcT failed with code %s"%sw)
+ # EF.AD
+ if p.get('mcc') and p.get('mnc'):
+ sw = self.update_ad(p['mnc'])
+ if sw != '9000':
+ print("Programming AD failed with code %s"%sw)
# EF.SMSP
r = self._scc.select_file(['3f00', '7f10'])