aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2023-06-06 18:15:52 +0200
committerlaforge <laforge@osmocom.org>2023-06-07 15:54:17 +0000
commit7ec822373ee6f14165c59fe6c997ad31d4bbf3e8 (patch)
tree2df684189d22bd9532c9497de9814f5715d365c0
parent621f78c9437b315264a532eeb6d2cc0e9b50c441 (diff)
ts_31_102: Add shell command for GET IDENTITY
GET IDENTITY is used in the "SUCI computation on USIM" feature. Change-Id: I619d397900dbd6565f8f46acdabcee511903830c
-rw-r--r--docs/shell.rst6
-rw-r--r--pySim/commands.py5
-rw-r--r--pySim/ts_31_102.py17
3 files changed, 28 insertions, 0 deletions
diff --git a/docs/shell.rst b/docs/shell.rst
index cce790a..e13d054 100644
--- a/docs/shell.rst
+++ b/docs/shell.rst
@@ -566,6 +566,12 @@ envelope_sms
:module: pySim.ts_31_102
:func: ADF_USIM.AddlShellCommands.envelope_sms_parser
+get_identity
+~~~~~~~~~~~~
+.. argparse::
+ :module: pySim.ts_31_102
+ :func: ADF_USIM.AddlShellCommands.get_id_parser
+
File-specific commands
----------------------
diff --git a/pySim/commands.py b/pySim/commands.py
index dc0edad..3c6ae49 100644
--- a/pySim/commands.py
+++ b/pySim/commands.py
@@ -641,3 +641,8 @@ class SimCardCommands:
def get_data(self, tag: int, cla: int = 0x00):
data, sw = self._tp.send_apdu('%02xca%04x00' % (cla, tag))
return (data, sw)
+
+ # TS 31.102 Section 7.5.2
+ def get_identity(self, context: int):
+ data, sw = self._tp.send_apdu_checksw('807800%02x00' % (context))
+ return (data, sw)
diff --git a/pySim/ts_31_102.py b/pySim/ts_31_102.py
index 342ea87..81b671e 100644
--- a/pySim/ts_31_102.py
+++ b/pySim/ts_31_102.py
@@ -1664,6 +1664,23 @@ class ADF_USIM(CardADF):
(data, sw) = self._cmd.card._scc.envelope(b2h(sms_dl.to_tlv()))
self._cmd.poutput('SW: %s, data: %s' % (sw, data))
+ get_id_parser = argparse.ArgumentParser()
+ get_id_parser.add_argument("--nswo-context", action='store_true')
+
+ @cmd2.with_argparser(get_id_parser)
+ def do_get_identity(self, opts):
+ """Send a GET IDENTITY command to the card. This is part of the
+ procedure for "SUCI calculation performed on USIM" supported
+ by USIM with support for both EF.UST service 124 and 125."""
+ context = 0x01 # SUCI
+ if opts.nswo_context:
+ context = 0x02 # SUCI 5G NSWO
+ (data, sw) = self._cmd.card._scc.get_identity(context)
+ do = SUCI_TlvDataObject()
+ do.from_tlv(h2b(data))
+ do_d = do.to_dict()
+ self._cmd.poutput('SUCI TLV Data Object: %s' % do_d['suci__tlv_data_object'])
+
# TS 31.102 Section 7.3
sw_usim = {