mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-03-22 13:28:33 +03:00
cards: also program EF.AD under ADF.USIM
DF.GSM and ADF.USIM have an EF.AD with nearly the same contents. Usually there is one file physically present and the other is just a link. Apparantly this is not always the case for sysmo-ismi-sja2 cards, so lets program EF.AD in both locations. Change-Id: Ic9dd4acc8d9a72acbb7376ddf3e2128125d4a8f5 Related: OS#5830
This commit is contained in:
@@ -178,7 +178,7 @@ class SimCard:
|
|||||||
data, sw = self._scc.update_record(EF['SMSP'], 1, rpad(smsp, 84))
|
data, sw = self._scc.update_record(EF['SMSP'], 1, rpad(smsp, 84))
|
||||||
return sw
|
return sw
|
||||||
|
|
||||||
def update_ad(self, mnc=None, opmode=None, ofm=None):
|
def update_ad(self, mnc=None, opmode=None, ofm=None, path=EF['AD']):
|
||||||
"""
|
"""
|
||||||
Update Administrative Data (AD)
|
Update Administrative Data (AD)
|
||||||
|
|
||||||
@@ -191,6 +191,7 @@ class SimCard:
|
|||||||
mnc (str): MNC of IMSI
|
mnc (str): MNC of IMSI
|
||||||
opmode (Hex-str, 1 Byte): MS Operation Mode
|
opmode (Hex-str, 1 Byte): MS Operation Mode
|
||||||
ofm (Hex-str, 1 Byte): Operational Feature Monitor (OFM) aka Ciphering Indicator
|
ofm (Hex-str, 1 Byte): Operational Feature Monitor (OFM) aka Ciphering Indicator
|
||||||
|
path (optional list with file path e.g. ['3f00', '7f20', '6fad'])
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
str: Return code of write operation
|
str: Return code of write operation
|
||||||
@@ -200,7 +201,7 @@ class SimCard:
|
|||||||
|
|
||||||
# read from card
|
# read from card
|
||||||
raw_hex_data, sw = self._scc.read_binary(
|
raw_hex_data, sw = self._scc.read_binary(
|
||||||
EF['AD'], length=None, offset=0)
|
path, length=None, offset=0)
|
||||||
abstract_data = ad.decode_hex(raw_hex_data)
|
abstract_data = ad.decode_hex(raw_hex_data)
|
||||||
|
|
||||||
# perform updates
|
# perform updates
|
||||||
@@ -223,7 +224,7 @@ class SimCard:
|
|||||||
|
|
||||||
# write to card
|
# write to card
|
||||||
raw_hex_data = ad.encode_hex(abstract_data)
|
raw_hex_data = ad.encode_hex(abstract_data)
|
||||||
data, sw = self._scc.update_binary(EF['AD'], raw_hex_data)
|
data, sw = self._scc.update_binary(path, raw_hex_data)
|
||||||
return sw
|
return sw
|
||||||
|
|
||||||
def read_spn(self):
|
def read_spn(self):
|
||||||
@@ -1576,6 +1577,17 @@ class SysmoISIMSJA2(UsimCard, IsimCard):
|
|||||||
|
|
||||||
data, sw = self.select_adf_by_aid(adf="usim")
|
data, sw = self.select_adf_by_aid(adf="usim")
|
||||||
if sw == '9000':
|
if sw == '9000':
|
||||||
|
# EF.AD in ADF.USIM
|
||||||
|
if (p.get('mcc') and p.get('mnc')) or p.get('opmode'):
|
||||||
|
if p.get('mcc') and p.get('mnc'):
|
||||||
|
mnc = p['mnc']
|
||||||
|
else:
|
||||||
|
mnc = None
|
||||||
|
sw = self.update_ad(mnc=mnc, opmode=p.get('opmode'),
|
||||||
|
path=EF_USIM_ADF_map['AD'])
|
||||||
|
if sw != '9000':
|
||||||
|
print("Programming AD failed with code %s" % sw)
|
||||||
|
|
||||||
# update EF-USIM_AUTH_KEY in ADF.USIM
|
# update EF-USIM_AUTH_KEY in ADF.USIM
|
||||||
if p.get('ki'):
|
if p.get('ki'):
|
||||||
self._scc.update_binary('af20', p['ki'], 1)
|
self._scc.update_binary('af20', p['ki'], 1)
|
||||||
|
|||||||
Reference in New Issue
Block a user