laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/pysim/+/35771?usp=email )


Change subject: global_platform: Add install_for_personalization command
......................................................................

global_platform: Add install_for_personalization command

This allows us to perform STORE DATA on applications like ARA-M/ARA-D
after establishing SCP02 to the related security domain.

Change-Id: I2ce766b97bba42c64c4d4492b505be66c24f471e
---
M docs/shell.rst
M pySim/global_platform/__init__.py
2 files changed, 33 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/71/35771/1

diff --git a/docs/shell.rst b/docs/shell.rst
index dff6cd1..96b04a7 100644
--- a/docs/shell.rst
+++ b/docs/shell.rst
@@ -959,6 +959,12 @@
    :module: pySim.global_platform
    :func: ADF_SD.AddlShellCommands.put_key_parser

+install_for_personalization
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.. argparse::
+   :module: pySim.global_platform
+   :func: ADF_SD.AddlShellCommands.inst_for_perso_parser
+
 establish_scp02
 ~~~~~~~~~~~~~~~
 .. argparse::
diff --git a/pySim/global_platform/__init__.py 
b/pySim/global_platform/__init__.py
index 44a24df..25b58d9 100644
--- a/pySim/global_platform/__init__.py
+++ b/pySim/global_platform/__init__.py
@@ -598,6 +598,21 @@
         est_scp02_parser.add_argument('--security-level', type=auto_int, 
default=0x01,
                                       help='Security Level. Default: 0x01 
(C-MAC only)')
 
+        inst_perso_parser = argparse.ArgumentParser()
+        inst_perso_parser.add_argument('application-aid', type=is_hexstr, 
help='Application AID')
+
+        @cmd2.with_argparser(inst_perso_parser)
+        def do_install_for_personalization(self, opts):
+            """Perform GlobalPlatform INSTALL [for personalization] command in 
order toinform a Security
+            Domain that the following STORE DATA commands are meant for a 
specific AID (specified here)."""
+            # Section 11.5.2.3.6 / Table 11-47
+            self.install(0x20, 0x00, "0000%02u%s000000" % 
(len(opts.application_aid)//2, opts.application_aid))
+
+        def install(self, p1:int, p2:int, data:Hexstr) -> ResTuple:
+            cmd_hex = "80E6%02x%02x%02x%s" % (p1, p2, len(data)//2, data)
+            return self._cmd.lchan.scc.send_apdu_checksw(cmd_hex)
+
+
         @cmd2.with_argparser(est_scp02_parser)
         def do_establish_scp02(self, opts):
             """Establish a secure channel using the GlobalPlatform SCP02 
protocol."""

--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35771?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I2ce766b97bba42c64c4d4492b505be66c24f471e
Gerrit-Change-Number: 35771
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <lafo...@osmocom.org>
Gerrit-MessageType: newchange

Reply via email to