lists.osmocom.org
Sign In Sign Up
Manage this list Sign In Sign Up

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

gerrit-log

Thread Start a new thread
Download
Threads by month
  • ----- 2026 -----
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2025 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2022 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
gerrit-log@lists.osmocom.org

February 2024

  • 1 participants
  • 1748 discussions
[M] Change in libosmo-abis[master]: Add support for sending and receiving Sa bits, as well as some line s...
by jolly 04 Feb '24

04 Feb '24
Attention is currently required from: dexter, laforge, tnt. jolly has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-abis/+/35563?usp=email ) Change subject: Add support for sending and receiving Sa bits, as well as some line signals ...................................................................... Patch Set 4: (1 comment) File src/e1_input.c: https://gerrit.osmocom.org/c/libosmo-abis/+/35563/comment/56542776_d1cab1f8 PS4, Line 1124: { S_L_INP_LINE_LOF, "LINE-LOF" }, : { S_L_INP_LINE_NOLOF, "LINE-NOLOF" }, > As I wrote: " As far as I can tell, this would affect libosmo-abis and osmo-v5" Done -- To view, visit https://gerrit.osmocom.org/c/libosmo-abis/+/35563?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-abis Gerrit-Branch: master Gerrit-Change-Id: Ie7643693c2daac99f5747591decd60e982b8052a Gerrit-Change-Number: 35563 Gerrit-PatchSet: 4 Gerrit-Owner: jolly <andreas(a)eversberg.eu> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: tnt <tnt(a)246tNt.com> Gerrit-CC: dexter <pmaier(a)sysmocom.de> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Attention: tnt <tnt(a)246tNt.com> Gerrit-Attention: dexter <pmaier(a)sysmocom.de> Gerrit-Comment-Date: Sun, 04 Feb 2024 19:42:45 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: jolly <andreas(a)eversberg.eu> Comment-In-Reply-To: laforge <laforge(a)osmocom.org> Comment-In-Reply-To: tnt <tnt(a)246tNt.com> Gerrit-MessageType: comment
1 0
0 0
[S] Change in pysim[master]: contrib/jenkins.sh: include tests/*.py in pylint
by laforge 04 Feb '24

04 Feb '24
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/35805?usp=email ) Change subject: contrib/jenkins.sh: include tests/*.py in pylint ...................................................................... contrib/jenkins.sh: include tests/*.py in pylint Change-Id: I9c8113acf5341b198d91040710b6b10cb2b6ef38 --- M contrib/jenkins.sh 1 file changed, 10 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/05/35805/1 diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh index e75ac40..3f32e9e 100755 --- a/contrib/jenkins.sh +++ b/contrib/jenkins.sh @@ -45,7 +45,7 @@ --disable E1102 \ --disable E0401 \ --enable W0301 \ - pySim *.py + pySim tests/*.py *.py ;; "docs") rm -rf docs/_build -- To view, visit https://gerrit.osmocom.org/c/pysim/+/35805?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: I9c8113acf5341b198d91040710b6b10cb2b6ef38 Gerrit-Change-Number: 35805 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in pysim[master]: make our tests pass pylint
by laforge 04 Feb '24

04 Feb '24
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/35804?usp=email ) Change subject: make our tests pass pylint ...................................................................... make our tests pass pylint Change-Id: If3a9f178c3f915123178efe00269fce74f6e585d --- M tests/test_globalplatform.py M tests/test_tlv.py 2 files changed, 23 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/04/35804/1 diff --git a/tests/test_globalplatform.py b/tests/test_globalplatform.py index bf5ffdb..df65816 100644 --- a/tests/test_globalplatform.py +++ b/tests/test_globalplatform.py @@ -65,12 +65,24 @@ self.assertEqual(b2h(wrapped).upper(), '84F280020A4F00B21AAFA3EB2D1672') -class SCP03_Test: +class SCP03_Test(abc.ABC): """some kind of 'abstract base class' for a unittest.UnitTest, implementing common functionality for all of our SCP03 test caseses.""" get_eid_cmd_plain = h2b('80E2910006BF3E035C015A') get_eid_rsp_plain = h2b('bf3e125a1089882119900000000000000000000005') + # must be overridden by derived classes + init_upd_cmd = b'' + init_upd_rsp = b'' + ext_auth_cmd = b'' + get_eid_cmd = b'' + get_eid_rsp = b'' + keyset = None + + @abc.abstractmethod + def assertEqual(self, *a, **k): + pass + @property def host_challenge(self) -> bytes: return self.init_upd_cmd[5:] diff --git a/tests/test_tlv.py b/tests/test_tlv.py index 1e5000d..0e73ab1 100644 --- a/tests/test_tlv.py +++ b/tests/test_tlv.py @@ -17,6 +17,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import unittest +from construct import Int8ub from pySim.tlv import * class TestUtils(unittest.TestCase): -- To view, visit https://gerrit.osmocom.org/c/pysim/+/35804?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: If3a9f178c3f915123178efe00269fce74f6e585d Gerrit-Change-Number: 35804 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newchange
1 0
0 0
[M] Change in pysim[master]: global_platform: KCV support for PUT KEY
by laforge 04 Feb '24

04 Feb '24
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/35803?usp=email ) Change subject: global_platform: KCV support for PUT KEY ...................................................................... global_platform: KCV support for PUT KEY GlobalPlatform requires the use of the KCV for DES + AES keys. Let's implement that. (11.8.2.3.3: "For all key types described in section B.6, the Key Check Value shall be present.") Change-Id: Ief168a66dee58b56f4126db12829b3a98906c8db --- M pySim/global_platform/__init__.py M tests/test_globalplatform.py 2 files changed, 55 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/03/35803/1 diff --git a/pySim/global_platform/__init__.py b/pySim/global_platform/__init__.py index b6d2343..494cfe1 100644 --- a/pySim/global_platform/__init__.py +++ b/pySim/global_platform/__init__.py @@ -539,7 +539,8 @@ if opts.key_check and len(opts.key_check) > i: kcv = opts.key_check[i] else: - kcv = '' + kcv_bin = compute_kcv(opts.key_type[i], h2b(opts.key_data[i])) or b'' + kcv = b2h(kcv_bin) kdb.append({'key_type': opts.key_type[i], 'kcb': opts.key_data[i], 'kcv': kcv}) p2 = opts.key_id if len(opts.key_type) > 1: @@ -770,3 +771,35 @@ def __str__(self): return "%s(KVN=%u, ENC=%s, MAC=%s, DEK=%s)" % (self.__class__.__name__, self.kvn, b2h(self.enc), b2h(self.mac), b2h(self.dek)) + +from Cryptodome.Cipher import DES, DES3, AES + +def compute_kcv_des(key:bytes) -> bytes: + # GP Card Spec B.6: For a DES key, the key check value is computed by encrypting 8 bytes, each with + # value '00', with the key to be checked and retaining the 3 highest-order bytes of the encrypted + # result. + plaintext = b'\x00' * 8 + cipher = DES3.new(key, DES.MODE_ECB) + return cipher.encrypt(plaintext) + +def compute_kcv_aes(key:bytes) -> bytes: + # GP Card Spec B.6: For a AES key, the key check value is computed by encrypting 16 bytes, each with + # value '01', with the key to be checked and retaining the 3 highest-order bytes of the encrypted + # result. + plaintext = b'\x01' * 16 + cipher = AES.new(key, AES.MODE_ECB) + return cipher.encrypt(plaintext) + +# dict is keyed by the string name of the KeyType enum above in this file +KCV_CALCULATOR = { + 'aes': compute_kcv_aes, + 'des': compute_kcv_des, + } + +def compute_kcv(key_type: str, key: bytes) -> Optional[bytes]: + """Compute the KCV (Key Check Value) for given key type and key.""" + kcv_calculator = KCV_CALCULATOR.get(key_type) + if not kcv_calculator: + return None + else: + return kcv_calculator(key)[:3] diff --git a/tests/test_globalplatform.py b/tests/test_globalplatform.py index 62eb43e..bf5ffdb 100644 --- a/tests/test_globalplatform.py +++ b/tests/test_globalplatform.py @@ -202,6 +202,12 @@ # FIXME: test auth with random (0x60) vs pseudo-random (0x70) challenge +class SCP03_KCV_Test(unittest.TestCase): + def test_kcv(self): + self.assertEqual(compute_kcv('aes', KEYSET_AES128.enc), h2b('C35280')) + self.assertEqual(compute_kcv('aes', KEYSET_AES128.mac), h2b('013808')) + self.assertEqual(compute_kcv('aes', KEYSET_AES128.dek), h2b('840DE5')) + if __name__ == "__main__": unittest.main() -- To view, visit https://gerrit.osmocom.org/c/pysim/+/35803?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: Ief168a66dee58b56f4126db12829b3a98906c8db Gerrit-Change-Number: 35803 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in pysim[master]: Be more conservative in our imports
by laforge 04 Feb '24

04 Feb '24
Attention is currently required from: laforge. Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/pysim/+/35802?usp=email to look at the new patch set (#3). The following approvals got outdated and were removed: Verified-1 by Jenkins Builder Change subject: Be more conservative in our imports ...................................................................... Be more conservative in our imports Try to avoid '*' from anything into various modules, polluting the namespace. Change-Id: Iba749d18e1863ded88ba2d2183e2e8d718b2d612 --- M pySim/apdu/ts_102_221.py M pySim/construct.py M pySim/global_platform/__init__.py M pySim/tlv.py M pySim/ts_31_103.py 5 files changed, 20 insertions(+), 5 deletions(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/02/35802/3 -- To view, visit https://gerrit.osmocom.org/c/pysim/+/35802?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: Iba749d18e1863ded88ba2d2183e2e8d718b2d612 Gerrit-Change-Number: 35802 Gerrit-PatchSet: 3 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newpatchset
1 0
0 0
[S] Change in pysim[master]: global_platform: Add install_for_personalization command
by laforge 04 Feb '24

04 Feb '24
laforge has submitted this change. ( 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, 32 insertions(+), 0 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved diff --git a/docs/shell.rst b/docs/shell.rst index dff6cd1..dbe6f8b 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_perso_parser + establish_scp02 ~~~~~~~~~~~~~~~ .. argparse:: diff --git a/pySim/global_platform/__init__.py b/pySim/global_platform/__init__.py index ad193ee..5492e44 100644 --- a/pySim/global_platform/__init__.py +++ b/pySim/global_platform/__init__.py @@ -584,6 +584,20 @@ p2 |= 0x01 return grd_list + 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) + est_scp02_parser = argparse.ArgumentParser() est_scp02_parser.add_argument('--key-ver', type=auto_uint8, required=True, help='Key Version Number (KVN)') -- 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: 9 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-MessageType: merged
1 0
0 0
[M] Change in pysim[master]: global_platform: add set_status command
by laforge 04 Feb '24

04 Feb '24
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/35772?usp=email ) Change subject: global_platform: add set_status command ...................................................................... global_platform: add set_status command Using this command, one can change the life cycle status of on-card applications, specifically one can LOCK (disable) them and re-enable them as needed. Change-Id: Ie14297a119d01cad1284f315a2508aa92cb4633b --- M docs/shell.rst M pySim/global_platform/__init__.py 2 files changed, 49 insertions(+), 2 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved diff --git a/docs/shell.rst b/docs/shell.rst index dbe6f8b..aed9565 100644 --- a/docs/shell.rst +++ b/docs/shell.rst @@ -947,6 +947,12 @@ :module: pySim.global_platform :func: ADF_SD.AddlShellCommands.get_status_parser +set_status +~~~~~~~~~~ +.. argparse:: + :module: pySim.global_platform + :func: ADF_SD.AddlShellCommands.set_status_parser + store_data ~~~~~~~~~~ .. argparse:: diff --git a/pySim/global_platform/__init__.py b/pySim/global_platform/__init__.py index 5492e44..17be946 100644 --- a/pySim/global_platform/__init__.py +++ b/pySim/global_platform/__init__.py @@ -94,6 +94,12 @@ ecc_key_parameters_reference=0xF0, # v2.3.1 Section 11.1.8 not_available=0xff) +# GlobalPlatform 2.3 Section 11.10.2.1 Table 11-86 +SetStatusScope = Enum(Byte, isd=0x80, app_or_ssd=0x40, isd_and_assoc_apps=0xc0) + +# GlobalPlatform 2.3 section 11.1.1 +CLifeCycleState = Enum(Byte, loaded=0x01, installed=0x03, selectable=0x07, personalized=0x0f, locked=0x83) + # GlobalPlatform 2.1.1 Section 9.3.3.1 class KeyInformationData(BER_TLV_IE, tag=0xc0): _test_de_encode = [ @@ -376,7 +382,7 @@ # Section 11.4.3.1 Table 11-36 class LifeCycleState(BER_TLV_IE, tag=0x9f70): - _construct = Int8ub + _construct = CLifeCycleState # Section 11.4.3.1 Table 11-36 + Section 11.1.2 class Privileges(BER_TLV_IE, tag=0xc5): @@ -557,7 +563,7 @@ @cmd2.with_argparser(get_status_parser) def do_get_status(self, opts): - """Perform GlobalPlatform GET STATUS command in order to retriev status information + """Perform GlobalPlatform GET STATUS command in order to retrieve status information on Issuer Security Domain, Executable Load File, Executable Module or Applications.""" grd_list = self.get_status(opts.subset, opts.aid) for grd in grd_list: @@ -584,6 +590,28 @@ p2 |= 0x01 return grd_list + set_status_parser = argparse.ArgumentParser() + set_status_parser.add_argument('scope', choices=SetStatusScope.ksymapping.values(), + help='Defines the scope of the requested status change') + set_status_parser.add_argument('status', choices=CLifeCycleState.ksymapping.values(), + help='Specify the new intended status') + set_status_parser.add_argument('--aid', type=is_hexstr, + help='AID of the target Application or Security Domain') + + @cmd2.with_argparser(set_status_parser) + def do_set_status(self, opts): + """Perform GlobalPlatform SET STATUS command in order to change the life cycle state of the + Issuer Security Domain, Supplementary Security Domain or Application. This normally requires + prior authentication with a Secure Channel Protocol.""" + self.set_status(opts.scope, opts.status, opts.aid) + + def set_status(self, scope:str, status:str, aid:Hexstr = ''): + SetStatus = Struct(Const(0x80, Byte), Const(0xF0, Byte), + 'scope'/SetStatusScope, 'status'/CLifeCycleState, + 'aid'/HexAdapter(Prefixed(Int8ub, Optional(GreedyBytes)))) + apdu = build_construct(SetStatus, {'scope':scope, 'status':status, 'aid':aid}) + data, sw = self._cmd.lchan.scc.send_apdu_checksw(b2h(apdu)) + inst_perso_parser = argparse.ArgumentParser() inst_perso_parser.add_argument('application-aid', type=is_hexstr, help='Application AID') -- To view, visit https://gerrit.osmocom.org/c/pysim/+/35772?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: Ie14297a119d01cad1284f315a2508aa92cb4633b Gerrit-Change-Number: 35772 Gerrit-PatchSet: 7 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-MessageType: merged
1 0
0 0
[M] Change in pysim[master]: global_platform: add delete_key and delete_card_content
by laforge 04 Feb '24

04 Feb '24
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/35798?usp=email ) Change subject: global_platform: add delete_key and delete_card_content ...................................................................... global_platform: add delete_key and delete_card_content This GlobalPlatform command is used to delete applications/load-files or keys. Change-Id: Ib5d18e983d0e918633d7c090c54fb9a3384a22e5 --- M docs/shell.rst M pySim/global_platform/__init__.py 2 files changed, 63 insertions(+), 0 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved diff --git a/docs/shell.rst b/docs/shell.rst index aed9565..4d6839b 100644 --- a/docs/shell.rst +++ b/docs/shell.rst @@ -965,12 +965,24 @@ :module: pySim.global_platform :func: ADF_SD.AddlShellCommands.put_key_parser +delete_key +~~~~~~~~~~ +.. argparse:: + :module: pySim.global_platform + :func: ADF_SD.AddlShellCommands.del_key_parser + install_for_personalization ~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. argparse:: :module: pySim.global_platform :func: ADF_SD.AddlShellCommands.inst_perso_parser +delete_card_content +~~~~~~~~~~~~~~~~~~~ +.. argparse:: + :module: pySim.global_platform + :func: ADF_SD.AddlShellCommands.del_cc_parser + establish_scp02 ~~~~~~~~~~~~~~~ .. argparse:: diff --git a/pySim/global_platform/__init__.py b/pySim/global_platform/__init__.py index 17be946..e32b47e 100644 --- a/pySim/global_platform/__init__.py +++ b/pySim/global_platform/__init__.py @@ -626,6 +626,45 @@ cmd_hex = "80E6%02x%02x%02x%s" % (p1, p2, len(data)//2, data) return self._cmd.lchan.scc.send_apdu_checksw(cmd_hex) + del_cc_parser = argparse.ArgumentParser() + del_cc_parser.add_argument('aid', type=is_hexstr, + help='Executable Load File or Application AID') + del_cc_parser.add_argument('--delete-related-objects', action='store_true', + help='Delete not only the object but also its related objects') + + @cmd2.with_argparser(del_cc_parser) + def do_delete_card_content(self, opts): + """Perform a GlobalPlatform DELETE [card content] command in order to delete an Executable Load + File, an Application or an Executable Load File and its related Applications.""" + p2 = 0x80 if opts.delete_related_objects else 0x00 + aid = ApplicationAID(decoded=opts.aid) + self.delete(0x00, p2, b2h(aid.to_tlv())) + + del_key_parser = argparse.ArgumentParser() + del_key_parser.add_argument('--key-id', type=auto_uint7, help='Key Identifier (KID)') + del_key_parser.add_argument('--key-ver', type=auto_uint8, help='Key Version Number (KVN)') + del_key_parser.add_argument('--delete-related-objects', action='store_true', + help='Delete not only the object but also its related objects') + + @cmd2.with_argparser(del_key_parser) + def do_delete_key(self, opts): + """Perform GlobalPlaform DELETE (Key) command. + If both KID and KVN are specified, exactly one key is deleted. If only either of the two is + specified, multiple matching keys may be deleted.""" + if opts.key_id == None and opts.key_ver == None: + raise ValueError('At least one of KID or KVN must be specified') + p2 = 0x80 if opts.delete_related_objects else 0x00 + cmd = "" + if opts.key_id != None: + cmd += "d001%02x" % opts.key_id + if opts.key_ver != None: + cmd += "d201%02x" % opts.key_ver + self.delete(0x00, p2, cmd) + + def delete(self, p1:int, p2:int, data:Hexstr) -> ResTuple: + cmd_hex = "80E4%02x%02x%02x%s" % (p1, p2, len(data)//2, data) + return self._cmd.lchan.scc.send_apdu_checksw(cmd_hex) + est_scp02_parser = argparse.ArgumentParser() est_scp02_parser.add_argument('--key-ver', type=auto_uint8, required=True, help='Key Version Number (KVN)') -- To view, visit https://gerrit.osmocom.org/c/pysim/+/35798?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: Ib5d18e983d0e918633d7c090c54fb9a3384a22e5 Gerrit-Change-Number: 35798 Gerrit-PatchSet: 5 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-MessageType: merged
1 0
0 0
[S] Change in pysim[master]: global_platform: Fix --key-id argument
by laforge 04 Feb '24

04 Feb '24
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/35800?usp=email ) Change subject: global_platform: Fix --key-id argument ...................................................................... global_platform: Fix --key-id argument The key-id is actually a 7-bit integer and on the wire the 8th bit has a special meaning which can be derived automatically. Let's unburden the user from explicitly encoding that 8th bit and instead set it automatically. Change-Id: I8da37aa8fd064e6d35ed29a70f5d7a0e9060be3a --- M pySim/global_platform/__init__.py 1 file changed, 21 insertions(+), 3 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved diff --git a/pySim/global_platform/__init__.py b/pySim/global_platform/__init__.py index e32b47e..848adba 100644 --- a/pySim/global_platform/__init__.py +++ b/pySim/global_platform/__init__.py @@ -522,12 +522,12 @@ See GlobalPlatform CardSpecification v2.3 Section 11.8 for details. Example (SCP80 KIC/KID/KIK): - put_key --key-version-nr 1 --key-id 0x81 --key-type aes --key-data 000102030405060708090a0b0c0d0e0f + put_key --key-version-nr 1 --key-id 0x01 --key-type aes --key-data 000102030405060708090a0b0c0d0e0f --key-type aes --key-data 101112131415161718191a1b1c1d1e1f --key-type aes --key-data 202122232425262728292a2b2c2d2e2f Example (SCP81 TLS-PSK/KEK): - put_key --key-version-nr 0x40 --key-id 0x81 --key-type tls_psk --key-data 303132333435363738393a3b3c3d3e3f + put_key --key-version-nr 0x40 --key-id 0x01 --key-type tls_psk --key-data 303132333435363738393a3b3c3d3e3f --key-type des --key-data 404142434445464748494a4b4c4d4e4f """ @@ -540,7 +540,10 @@ else: kcv = '' kdb.append({'key_type': opts.key_type[i], 'kcb': opts.key_data[i], 'kcv': kcv}) - self.put_key(opts.old_key_version_nr, opts.key_version_nr, opts.key_id, kdb) + p2 = opts.key_id + if len(opts.key_type) > 1: + p2 |= 0x80 + self.put_key(opts.old_key_version_nr, opts.key_version_nr, p2, kdb) # Table 11-68: Key Data Field - Format 1 (Basic Format) KeyDataBasic = GreedyRange(Struct('key_type'/KeyType, -- To view, visit https://gerrit.osmocom.org/c/pysim/+/35800?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: I8da37aa8fd064e6d35ed29a70f5d7a0e9060be3a Gerrit-Change-Number: 35800 Gerrit-PatchSet: 3 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-MessageType: merged
1 0
0 0
[S] Change in pysim[master]: rename global_platform.scp02 to global_platform.scp
by laforge 04 Feb '24

04 Feb '24
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/35801?usp=email ) Change subject: rename global_platform.scp02 to global_platform.scp ...................................................................... rename global_platform.scp02 to global_platform.scp This is in preparation of extending it to cover SCP03 in a follow-up patch. Change-Id: Idc0afac6e95f89ddaf277a89f9c95607e70a471c --- M pySim/global_platform/__init__.py R pySim/global_platform/scp.py M tests/test_globalplatform.py 3 files changed, 14 insertions(+), 2 deletions(-) Approvals: laforge: Looks good to me, approved Jenkins Builder: Verified diff --git a/pySim/global_platform/__init__.py b/pySim/global_platform/__init__.py index 848adba..3ca22af 100644 --- a/pySim/global_platform/__init__.py +++ b/pySim/global_platform/__init__.py @@ -22,7 +22,7 @@ from construct import * from bidict import bidict from Cryptodome.Random import get_random_bytes -from pySim.global_platform.scp02 import SCP02 +from pySim.global_platform.scp import SCP02 from pySim.construct import * from pySim.utils import * from pySim.filesystem import * diff --git a/pySim/global_platform/scp02.py b/pySim/global_platform/scp.py similarity index 100% rename from pySim/global_platform/scp02.py rename to pySim/global_platform/scp.py diff --git a/tests/test_globalplatform.py b/tests/test_globalplatform.py index 280199f..d50948f 100644 --- a/tests/test_globalplatform.py +++ b/tests/test_globalplatform.py @@ -19,7 +19,7 @@ import logging from pySim.global_platform import * -from pySim.global_platform.scp02 import SCP02 +from pySim.global_platform.scp import SCP02 from pySim.utils import b2h, h2b KIC = h2b('100102030405060708090a0b0c0d0e0f') # enc -- To view, visit https://gerrit.osmocom.org/c/pysim/+/35801?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: Idc0afac6e95f89ddaf277a89f9c95607e70a471c Gerrit-Change-Number: 35801 Gerrit-PatchSet: 3 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-MessageType: merged
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • ...
  • 175
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.