mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-04-01 10:30:05 +03:00
Add API + shell command for sending TERMINAL PROFILE to card
This allows a very first start to play with PROACTIVE SIM Change-Id: Id8f23f7cebe0f9efce2c0ce4229509f35cd93d6a
This commit is contained in:
@@ -441,3 +441,9 @@ class SimCardCommands(object):
|
|||||||
def envelope(self, payload:str):
|
def envelope(self, payload:str):
|
||||||
"""Send one ENVELOPE command to the SIM"""
|
"""Send one ENVELOPE command to the SIM"""
|
||||||
return self._tp.send_apdu_checksw('80c20000%02x%s' % (len(payload)//2, payload))
|
return self._tp.send_apdu_checksw('80c20000%02x%s' % (len(payload)//2, payload))
|
||||||
|
|
||||||
|
def terminal_profile(self, payload:str):
|
||||||
|
"""Send TERMINAL PROFILE to card"""
|
||||||
|
data_length = len(payload) // 2
|
||||||
|
data, sw = self._tp.send_apdu(('80100000%02x' % data_length) + payload)
|
||||||
|
return (data, sw)
|
||||||
|
|||||||
@@ -136,6 +136,10 @@ class LinkBase(abc.ABC):
|
|||||||
"""
|
"""
|
||||||
rv = self.send_apdu(pdu)
|
rv = self.send_apdu(pdu)
|
||||||
|
|
||||||
|
if sw == '9000' and sw_match(rv[1], '91xx'):
|
||||||
|
# proactive sim as per TS 102 221 Setion 7.4.2
|
||||||
|
rv = self.send_apdu_checksw('80120000' + rv[1][2:], sw)
|
||||||
|
print("FETCH: %s", rv[0])
|
||||||
if not sw_match(rv[1], sw):
|
if not sw_match(rv[1], sw):
|
||||||
raise SwMatchError(rv[1], sw.lower(), self.sw_interpreter)
|
raise SwMatchError(rv[1], sw.lower(), self.sw_interpreter)
|
||||||
return rv
|
return rv
|
||||||
|
|||||||
@@ -1084,6 +1084,10 @@ class ADF_USIM(CardADF):
|
|||||||
(data, sw) = self._cmd.card._scc.authenticate(opts.rand, opts.autn)
|
(data, sw) = self._cmd.card._scc.authenticate(opts.rand, opts.autn)
|
||||||
self._cmd.poutput_json(data)
|
self._cmd.poutput_json(data)
|
||||||
|
|
||||||
|
def do_terminal_profile(self, arg):
|
||||||
|
"""Send a TERMINAL PROFILE command to the card."""
|
||||||
|
(data, sw) = self._cmd.card._scc.terminal_profile(arg)
|
||||||
|
self._cmd.poutput('SW: %s, data: %s' % (sw, data))
|
||||||
|
|
||||||
|
|
||||||
# TS 31.102 Section 7.3
|
# TS 31.102 Section 7.3
|
||||||
|
|||||||
Reference in New Issue
Block a user