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

November 2023

  • 1 participants
  • 1508 discussions
[M] Change in pysim[master]: sysmocom_sja2: Add some de/encode test vectors
by fixeria 03 Nov '23

03 Nov '23
Attention is currently required from: laforge. fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/34949?usp=email ) Change subject: sysmocom_sja2: Add some de/encode test vectors ...................................................................... Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/pysim/+/34949?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: I7932bab7c81a2314c1b9477f50b82a46f24d074e Gerrit-Change-Number: 34949 Gerrit-PatchSet: 2 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Comment-Date: Fri, 03 Nov 2023 06:05:41 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[S] Change in pysim[master]: pySim-shell: Reject any non-decimal PIN values
by fixeria 03 Nov '23

03 Nov '23
Attention is currently required from: laforge. fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/34948?usp=email ) Change subject: pySim-shell: Reject any non-decimal PIN values ...................................................................... Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/pysim/+/34948?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: Icec1698851471af7f76f20201dcdcfcd48ddf365 Gerrit-Change-Number: 34948 Gerrit-PatchSet: 2 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Comment-Date: Fri, 03 Nov 2023 06:04:33 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[S] Change in pysim[master]: pySim-shell: permit string with spaces for 'echo' command
by fixeria 03 Nov '23

03 Nov '23
Attention is currently required from: laforge. fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/34947?usp=email ) Change subject: pySim-shell: permit string with spaces for 'echo' command ...................................................................... Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/pysim/+/34947?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: I1369bc3aa975865e3a8a574c132e469813a9f6b9 Gerrit-Change-Number: 34947 Gerrit-PatchSet: 2 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Comment-Date: Fri, 03 Nov 2023 06:01:15 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[S] Change in pysim[master]: pySim-shell: Validate that argument to 'apdu' command is proper hexstr
by fixeria 03 Nov '23

03 Nov '23
Attention is currently required from: laforge, pespin. fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/34946?usp=email ) Change subject: pySim-shell: Validate that argument to 'apdu' command is proper hexstr ...................................................................... Patch Set 2: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/pysim/+/34946?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: I58465244101cc1a976e5a17af2aceea1cf9f9b54 Gerrit-Change-Number: 34946 Gerrit-PatchSet: 2 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-CC: pespin <pespin(a)sysmocom.de> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Fri, 03 Nov 2023 06:00:47 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[S] Change in pysim[master]: pySim-shell: Improved argument validation for verify_adm argument
by fixeria 03 Nov '23

03 Nov '23
Attention is currently required from: laforge. fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/34945?usp=email ) Change subject: pySim-shell: Improved argument validation for verify_adm argument ...................................................................... Patch Set 3: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/pysim/+/34945?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: I4a193a3cf63462fad73d145ab1481070ddf767ca Gerrit-Change-Number: 34945 Gerrit-PatchSet: 3 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Comment-Date: Fri, 03 Nov 2023 05:59:24 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[M] Change in osmo-ttcn3-hacks[master]: sccp: Introduce test TC_cr_timeout_cc_too_late
by fixeria 03 Nov '23

03 Nov '23
Attention is currently required from: pespin. fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/34923?usp=email ) Change subject: sccp: Introduce test TC_cr_timeout_cc_too_late ...................................................................... Patch Set 3: (1 comment) File library/SCCP_Templates.ttcn: https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/34923/comment/d1394c82_7c2d… PS3, Line 120: calling_enc Now why this template becomes a function? I may be missing something, but to me it looks like there is no need to turn this template into a function. Otherwise a comment explaining why would be welcome. -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/34923?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Change-Id: If4b53565f1fa19894ca24fa71e02ae7b1941411e Gerrit-Change-Number: 34923 Gerrit-PatchSet: 3 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de> Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Fri, 03 Nov 2023 05:42:00 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Gerrit-MessageType: comment
1 0
0 0
[M] Change in osmo-ttcn3-hacks[master]: sccp: Introduce test TC_cr_timeout_cc_too_late
by daniel 03 Nov '23

03 Nov '23
Attention is currently required from: fixeria, pespin. daniel has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/34923?usp=email ) Change subject: sccp: Introduce test TC_cr_timeout_cc_too_late ...................................................................... Patch Set 3: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/34923?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Change-Id: If4b53565f1fa19894ca24fa71e02ae7b1941411e Gerrit-Change-Number: 34923 Gerrit-PatchSet: 3 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de> Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Comment-Date: Fri, 03 Nov 2023 05:04:42 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[M] Change in pysim[master]: Use construct 'Flag' instead of 'Bit' for type descriptions
by laforge 03 Nov '23

03 Nov '23
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/34957?usp=email ) Change subject: Use construct 'Flag' instead of 'Bit' for type descriptions ...................................................................... Use construct 'Flag' instead of 'Bit' for type descriptions It's better for the human reader (and more obvious that it's a boolean value) if we decode single Bits as True/False instead of 1/0. Change-Id: Ib025f9c4551af7cf57090a0678ab0f66a6684fa4 --- M pySim/sysmocom_sja2.py M pySim/ts_31_102.py 2 files changed, 32 insertions(+), 19 deletions(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/57/34957/1 diff --git a/pySim/sysmocom_sja2.py b/pySim/sysmocom_sja2.py index bd9e8a8..8073e74 100644 --- a/pySim/sysmocom_sja2.py +++ b/pySim/sysmocom_sja2.py @@ -140,14 +140,14 @@ class EF_SIM_AUTH_KEY(TransparentEF): _test_de_encode = [ ( '14000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f', - {"cfg": {"use_sres_deriv_func_2": 0, "use_opc_instead_of_op": 1, "algorithm": "milenage"}, "key": + {"cfg": {"use_sres_deriv_func_2": False, "use_opc_instead_of_op": True, "algorithm": "milenage"}, "key": "000102030405060708090a0b0c0d0e0f", "op_opc": "101112131415161718191a1b1c1d1e1f"} ), ] def __init__(self, fid='6f20', name='EF.SIM_AUTH_KEY'): super().__init__(fid, name=name, desc='USIM authentication key') CfgByte = BitStruct(Padding(2), - 'use_sres_deriv_func_2'/Bit, - 'use_opc_instead_of_op'/Bit, + 'use_sres_deriv_func_2'/Flag, + 'use_opc_instead_of_op'/Flag, 'algorithm'/Enum(Nibble, milenage=4, comp128v1=1, comp128v2=2, comp128v3=3)) self._construct = Struct('cfg'/CfgByte, 'key'/HexAdapter(Bytes(16)), @@ -181,19 +181,19 @@ class EF_USIM_SQN(TransparentEF): _test_de_encode = [ ( 'd503000200000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', - {"flag1": {"skip_next_sqn_check": 1, "delta_max_check": 1, "age_limit_check": 0, "sqn_check": 1, - "ind_len": 5}, "flag2": {"rfu": 0, "dont_clear_amf_for_macs": 0, "aus_concealed": 1, - "autn_concealed": 1}, "delta_max": 8589934592, "age_limit": + {"flag1": {"skip_next_sqn_check": True, "delta_max_check": True, "age_limit_check": False, "sqn_check": True, + "ind_len": 5}, "flag2": {"rfu": 0, "dont_clear_amf_for_macs": False, "aus_concealed": True, + "autn_concealed": True}, "delta_max": 8589934592, "age_limit": 8589934592, "freshness": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]} ), ] def __init__(self, fid='af30', name='EF.USIM_SQN'): super().__init__(fid, name=name, desc='SQN parameters for AKA') - Flag1 = BitStruct('skip_next_sqn_check'/Bit, 'delta_max_check'/Bit, - 'age_limit_check'/Bit, 'sqn_check'/Bit, + Flag1 = BitStruct('skip_next_sqn_check'/Flag, 'delta_max_check'/Flag, + 'age_limit_check'/Flag, 'sqn_check'/Flag, 'ind_len'/BitsInteger(4)) - Flag2 = BitStruct('rfu'/BitsRFU(5), 'dont_clear_amf_for_macs'/Bit, - 'aus_concealed'/Bit, 'autn_concealed'/Bit) + Flag2 = BitStruct('rfu'/BitsRFU(5), 'dont_clear_amf_for_macs'/Flag, + 'aus_concealed'/Flag, 'autn_concealed'/Flag) self._construct = Struct('flag1'/Flag1, 'flag2'/Flag2, 'delta_max' / BytesInteger(6), 'age_limit'/BytesInteger(6), @@ -204,8 +204,8 @@ def __init__(self, fid='af20', name='EF.USIM_AUTH_KEY'): super().__init__(fid, name=name, desc='USIM authentication key') Algorithm = Enum(Nibble, milenage=4, sha1_aka=5, tuak=6, xor=15) - CfgByte = BitStruct(Padding(1), 'only_4bytes_res_in_3g'/Bit, - 'sres_deriv_func_2_in_3g'/Mapping(Bit, {1:0, 2:1}), + CfgByte = BitStruct(Padding(1), 'only_4bytes_res_in_3g'/Flag, + 'sres_deriv_func_2_in_3g'/Mapping(Bit, {1:False, 2:True}), 'use_opc_instead_of_op'/Mapping(Bit, {False:0, True:1}), 'algorithm'/Algorithm) self._construct = Struct('cfg'/CfgByte, @@ -216,7 +216,7 @@ # the TUAK and non-TUAK situation CfgByteTuak = BitStruct(Padding(1), 'key_length'/Mapping(Bit, {128:0, 256:1}), - 'sres_deriv_func_in_3g'/Mapping(Bit, {1:0, 2:1}), + 'sres_deriv_func_in_3g'/Mapping(Bit, {1:False, 2:True}), 'use_opc_instead_of_op'/Mapping(Bit, {False:0, True:1}), 'algorithm'/Algorithm) TuakCfgByte = BitStruct(Padding(1), @@ -245,15 +245,15 @@ class EF_USIM_AUTH_KEY_2G(TransparentEF): _test_de_encode = [ ( '14000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f', - {"cfg": {"only_4bytes_res_in_3g": 0, "use_sres_deriv_func_2_in_3g": 0, "use_opc_instead_of_op": 1, + {"cfg": {"only_4bytes_res_in_3g": False, "use_sres_deriv_func_2_in_3g": False, "use_opc_instead_of_op": True, "algorithm": "milenage"}, "key": "000102030405060708090a0b0c0d0e0f", "op_opc": "101112131415161718191a1b1c1d1e1f"} ), ] def __init__(self, fid='af22', name='EF.USIM_AUTH_KEY_2G'): super().__init__(fid, name=name, desc='USIM authentication key in 2G context') - CfgByte = BitStruct(Padding(1), 'only_4bytes_res_in_3g'/Bit, - 'use_sres_deriv_func_2_in_3g'/Bit, - 'use_opc_instead_of_op'/Bit, + CfgByte = BitStruct(Padding(1), 'only_4bytes_res_in_3g'/Flag, + 'use_sres_deriv_func_2_in_3g'/Flag, + 'use_opc_instead_of_op'/Flag, 'algorithm'/Enum(Nibble, milenage=4, comp128v1=1, comp128v2=2, comp128v3=3, xor=14)) self._construct = Struct('cfg'/CfgByte, 'key'/HexAdapter(Bytes(16)), @@ -322,6 +322,7 @@ rs.mf.add_file(DF_SYSTEM()) # optional USIM application if 'a0000000871002' in rs.mf.applications: + print("#####################") usim_adf = rs.mf.applications['a0000000871002'] files_adf_usim = [ EF_USIM_AUTH_KEY(), diff --git a/pySim/ts_31_102.py b/pySim/ts_31_102.py index cd0d99c..738f107 100644 --- a/pySim/ts_31_102.py +++ b/pySim/ts_31_102.py @@ -889,14 +889,14 @@ def __init__(self, fid='6ff7', sfid=None, name='EF.FromPreferred', size=(1, 1), desc='From Preferred', **kwargs): super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size, **kwargs) - self._construct = BitStruct('rfu'/BitsRFU(7), 'from_preferred'/Bit) + self._construct = BitStruct('rfu'/BitsRFU(7), 'from_preferred'/Flag) # TS 31.102 Section 4.2.114 class EF_eAKA(TransparentEF): def __init__(self, fid='6f01', sfid=None, name='EF.eAKA', size=(1, 1), desc='enhanced AKA support', **kwargs): super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size, **kwargs) - self._construct = BitStruct('rfu'/BitsRFU(7), 'enhanced_sqn_calculation_supported'/Bit) + self._construct = BitStruct('rfu'/BitsRFU(7), 'enhanced_sqn_calculation_supported'/Flag) ###################################################################### -- To view, visit https://gerrit.osmocom.org/c/pysim/+/34957?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: Ib025f9c4551af7cf57090a0678ab0f66a6684fa4 Gerrit-Change-Number: 34957 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newchange
1 0
0 0
[M] Change in pysim[master]: pySim-shell: Move init_card() function to new pySim.app module
by laforge 03 Nov '23

03 Nov '23
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/34956?usp=email ) Change subject: pySim-shell: Move init_card() function to new pySim.app module ...................................................................... pySim-shell: Move init_card() function to new pySim.app module The point of this is to move generic code out of pySim-shell.py, paving the way for more/other executables using the full power of our class model without having to reinvent the wheel. Change-Id: Icf557ed3064ef613ed693ce28bd3514a97a938bd --- M pySim-shell.py A pySim/app.py 2 files changed, 132 insertions(+), 94 deletions(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/56/34956/1 diff --git a/pySim-shell.py b/pySim-shell.py index 0c559f9..795276a 100755 --- a/pySim-shell.py +++ b/pySim-shell.py @@ -2,7 +2,7 @@ # Interactive shell for working with SIM / UICC / USIM / ISIM cards # -# (C) 2021-2022 by Harald Welte <laforge(a)osmocom.org> +# (C) 2021-2023 by Harald Welte <laforge(a)osmocom.org> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -48,111 +48,20 @@ from pprint import pprint as pp from pySim.exceptions import * -from pySim.commands import SimCardCommands from pySim.transport import init_reader, ApduTracer, argparse_add_reader_args, ProactiveHandler -from pySim.cards import card_detect, SimCardBase, UiccCardBase from pySim.utils import h2b, b2h, i2h, swap_nibbles, rpad, JsonEncoder, bertlv_parse_one, sw_match from pySim.utils import sanitize_pin_adm, tabulate_str_list, boxed_heading_str, Hexstr, dec_iccid from pySim.utils import is_hexstr_or_decimal, is_hexstr, is_decimal from pySim.card_handler import CardHandler, CardHandlerAuto -from pySim.filesystem import CardDF, CardADF, CardModel, CardApplication -from pySim.runtime import RuntimeState -from pySim.profile import CardProfile -from pySim.cdma_ruim import CardProfileRUIM -from pySim.ts_102_221 import CardProfileUICC +from pySim.filesystem import CardDF, CardADF from pySim.ts_102_222 import Ts102222Commands from pySim.gsm_r import DF_EIRENE from pySim.cat import ProactiveCommand -# we need to import this module so that the SysmocomSJA2 sub-class of -# CardModel is created, which will add the ATR-based matching and -# calling of SysmocomSJA2.add_files. See CardModel.apply_matching_models -import pySim.sysmocom_sja2 - -# we need to import these modules so that the various sub-classes of -# CardProfile are created, which will be used in init_card() to iterate -# over all known CardProfile sub-classes. -import pySim.ts_31_102 -import pySim.ts_31_103 -import pySim.ts_31_104 -import pySim.ara_m -import pySim.global_platform -import pySim.euicc - from pySim.card_key_provider import CardKeyProviderCsv, card_key_provider_register, card_key_provider_get_field - -def init_card(sl): - """ - Detect card in reader and setup card profile and runtime state. This - function must be called at least once on startup. The card and runtime - state object (rs) is required for all pySim-shell commands. - """ - - # Create command layer - scc = SimCardCommands(transport=sl) - - # Wait up to three seconds for a card in reader and try to detect - # the card type. - print("Waiting for card...") - try: - sl.wait_for_card(3) - except NoCardError: - print("No card detected!") - return None, None - except: - print("Card not readable!") - return None, None - - generic_card = False - card = card_detect(scc) - if card is None: - print("Warning: Could not detect card type - assuming a generic card type...") - card = SimCardBase(scc) - generic_card = True - - profile = CardProfile.pick(scc) - if profile is None: - print("Unsupported card type!") - return None, card - - # ETSI TS 102 221, Table 9.3 specifies a default for the PIN key - # references, however card manufactures may still decide to pick an - # arbitrary key reference. In case we run on a generic card class that is - # detected as an UICC, we will pick the key reference that is officially - # specified. - if generic_card and isinstance(profile, CardProfileUICC): - card._adm_chv_num = 0x0A - - print("Info: Card is of type: %s" % str(profile)) - - # FIXME: this shouldn't really be here but somewhere else/more generic. - # We cannot do it within pySim/profile.py as that would create circular - # dependencies between the individual profiles and profile.py. - if isinstance(profile, CardProfileUICC): - for app_cls in CardApplication.__subclasses__(): - constr_sig = inspect.signature(app_cls.__init__) - # skip any intermediary sub-classes such as CardApplicationSD - if len(constr_sig.parameters) != 1: - continue - profile.add_application(app_cls()) - # We have chosen SimCard() above, but we now know it actually is an UICC - # so it's safe to assume it supports USIM application (which we're adding above). - # IF we don't do this, we will have a SimCard but try USIM specific commands like - # the update_ust method (see https://osmocom.org/issues/6055) - if generic_card: - card = UiccCardBase(scc) - - # Create runtime state with card profile - rs = RuntimeState(card, profile) - - CardModel.apply_matching_models(scc, rs) - - # inform the transport that we can do context-specific SW interpretation - sl.set_sw_interpreter(rs) - - return rs, card +from pySim.app import init_card class Cmd2Compat(cmd2.Cmd): diff --git a/pySim/app.py b/pySim/app.py new file mode 100644 index 0000000..073e5d1 --- /dev/null +++ b/pySim/app.py @@ -0,0 +1,116 @@ +# (C) 2021-2023 by Harald Welte <laforge(a)osmocom.org> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + + +import inspect +from typing import Tuple + +from pySim.transport import LinkBase +from pySim.commands import SimCardCommands +from pySim.filesystem import CardModel, CardApplication +from pySim.cards import card_detect, SimCardBase, UiccCardBase +from pySim.runtime import RuntimeState +from pySim.profile import CardProfile +from pySim.cdma_ruim import CardProfileRUIM +from pySim.ts_102_221 import CardProfileUICC + +# we need to import this module so that the SysmocomSJA2 sub-class of +# CardModel is created, which will add the ATR-based matching and +# calling of SysmocomSJA2.add_files. See CardModel.apply_matching_models +import pySim.sysmocom_sja2 + +# we need to import these modules so that the various sub-classes of +# CardProfile are created, which will be used in init_card() to iterate +# over all known CardProfile sub-classes. +import pySim.ts_31_102 +import pySim.ts_31_103 +import pySim.ts_31_104 +import pySim.ara_m +import pySim.global_platform +import pySim.euicc + +def init_card(sl: LinkBase) -> Tuple[RuntimeState, SimCardBase]: + """ + Detect card in reader and setup card profile and runtime state. This + function must be called at least once on startup. The card and runtime + state object (rs) is required for all pySim-shell commands. + """ + + # Create command layer + scc = SimCardCommands(transport=sl) + + # Wait up to three seconds for a card in reader and try to detect + # the card type. + print("Waiting for card...") + try: + sl.wait_for_card(3) + except NoCardError: + print("No card detected!") + return None, None + except: + print("Card not readable!") + return None, None + + generic_card = False + card = card_detect(scc) + if card is None: + print("Warning: Could not detect card type - assuming a generic card type...") + card = SimCardBase(scc) + generic_card = True + + profile = CardProfile.pick(scc) + if profile is None: + print("Unsupported card type!") + return None, card + + # ETSI TS 102 221, Table 9.3 specifies a default for the PIN key + # references, however card manufactures may still decide to pick an + # arbitrary key reference. In case we run on a generic card class that is + # detected as an UICC, we will pick the key reference that is officially + # specified. + if generic_card and isinstance(profile, CardProfileUICC): + card._adm_chv_num = 0x0A + + print("Info: Card is of type: %s" % str(profile)) + + # FIXME: this shouldn't really be here but somewhere else/more generic. + # We cannot do it within pySim/profile.py as that would create circular + # dependencies between the individual profiles and profile.py. + if isinstance(profile, CardProfileUICC): + for app_cls in CardApplication.__subclasses__(): + constr_sig = inspect.signature(app_cls.__init__) + # skip any intermediary sub-classes such as CardApplicationSD + if len(constr_sig.parameters) != 1: + continue + profile.add_application(app_cls()) + # We have chosen SimCard() above, but we now know it actually is an UICC + # so it's safe to assume it supports USIM application (which we're adding above). + # IF we don't do this, we will have a SimCard but try USIM specific commands like + # the update_ust method (see https://osmocom.org/issues/6055) + if generic_card: + card = UiccCardBase(scc) + + # Create runtime state with card profile + rs = RuntimeState(card, profile) + + CardModel.apply_matching_models(scc, rs) + + # inform the transport that we can do context-specific SW interpretation + sl.set_sw_interpreter(rs) + + return rs, card + + + -- To view, visit https://gerrit.osmocom.org/c/pysim/+/34956?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: Icf557ed3064ef613ed693ce28bd3514a97a938bd Gerrit-Change-Number: 34956 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in pysim[master]: pySim-shell: Validate that argument to 'apdu' command is proper hexstr
by laforge 03 Nov '23

03 Nov '23
Attention is currently required from: pespin. laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/34946?usp=email ) Change subject: pySim-shell: Validate that argument to 'apdu' command is proper hexstr ...................................................................... Patch Set 2: (1 comment) File pySim/utils.py: https://gerrit.osmocom.org/c/pysim/+/34946/comment/75ddfb44_d8428a9d PS1, Line 1476: if not all(c in string.hexdigits for c in instr): > you can probably return is_hexstr here. nice idea, but the error strings would then be potentially confusing. Like getting "Input must be hexadecimal" when calling is_hexstr_or_decimal, which currently states "Input must be [hexa]decimal"... -- To view, visit https://gerrit.osmocom.org/c/pysim/+/34946?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: I58465244101cc1a976e5a17af2aceea1cf9f9b54 Gerrit-Change-Number: 34946 Gerrit-PatchSet: 2 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-CC: pespin <pespin(a)sysmocom.de> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Thu, 02 Nov 2023 23:46:04 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: comment
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • ...
  • 151
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.