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

October 2023

  • 1 participants
  • 1843 discussions
[S] Change in pysim[master]: pySim-shell: Add 'switch_channel' command
by laforge 21 Oct '23

21 Oct '23
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/34848?usp=email ) Change subject: pySim-shell: Add 'switch_channel' command ...................................................................... pySim-shell: Add 'switch_channel' command We've already had the 'open_channel' and 'close_channel' commands, which were sent to (and acknowledged by) the card. However, those commands didn't affect the pySim-shell state, i.e. all communication would still happen through the default channel '0'. With this patch we introduce a 'switch_channel' command, using which the user can determine which of the (previously opened) logical channels shall be used by pySim-shell. Change-Id: Ia76eb45c4925882ae6866e50b64d9610bd4d546d Closes: OS#6230 --- M docs/shell.rst M pySim-shell.py 2 files changed, 37 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/48/34848/1 diff --git a/docs/shell.rst b/docs/shell.rst index 73b988a..2c3d84d 100644 --- a/docs/shell.rst +++ b/docs/shell.rst @@ -199,6 +199,12 @@ :module: pySim-shell :func: Iso7816Commands.close_chan_parser +switch_channel +~~~~~~~~~~~~~~ +.. argparse:: + :module: pySim-shell + :func: Iso7816Commands.switch_chan_parser + TS 102 221 commands ------------------- diff --git a/pySim-shell.py b/pySim-shell.py index 8a1ad01..2f97389 100755 --- a/pySim-shell.py +++ b/pySim-shell.py @@ -963,6 +963,18 @@ # this is executed only in successful case, as unsuccessful raises exception self._cmd.rs.del_lchan(opts.chan_nr) + switch_chan_parser = argparse.ArgumentParser() + switch_chan_parser.add_argument( + 'chan_nr', type=int, default=0, help='Channel Number') + + @cmd2.with_argparser(switch_chan_parser) + def do_switch_channel(self, opts): + """Switch currently active logical channel.""" + self._cmd.lchan._select_pre(self._cmd) + self._cmd.lchan = self._cmd.rs.lchan[opts.chan_nr] + self._cmd.lchan._select_post(self._cmd) + self._cmd.update_prompt() + def do_status(self, opts): """Perform the STATUS command.""" fcp_dec = self._cmd.lchan.status() -- To view, visit https://gerrit.osmocom.org/c/pysim/+/34848?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: Ia76eb45c4925882ae6866e50b64d9610bd4d546d Gerrit-Change-Number: 34848 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newchange
1 0
0 0
[M] Change in pysim[master]: commands.py: Add support for multiple logical channels.
by laforge 21 Oct '23

21 Oct '23
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/34846?usp=email ) Change subject: commands.py: Add support for multiple logical channels. ...................................................................... commands.py: Add support for multiple logical channels. Historically we always only had one instance of SimCardCommands, but with this patch we can now have multiple instances, one for each lchan. The SimCardCommands class is aware of the logical channel it runs on and will patch the CLA byte accordingly. Change-Id: Ibe5650dedc0f7681acf82018a86f83377ba81d30 Related: OS#6230 --- M pySim/commands.py 1 file changed, 82 insertions(+), 10 deletions(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/46/34846/1 diff --git a/pySim/commands.py b/pySim/commands.py index e072069..e6a01e2 100644 --- a/pySim/commands.py +++ b/pySim/commands.py @@ -26,7 +26,7 @@ from construct import * from pySim.construct import LV -from pySim.utils import rpad, lpad, b2h, h2b, sw_match, bertlv_encode_len, Hexstr, h2i, str_sanitize, expand_hex +from pySim.utils import rpad, lpad, b2h, h2b, sw_match, bertlv_encode_len, Hexstr, h2i, i2h, str_sanitize, expand_hex from pySim.utils import Hexstr, SwHexstr, ResTuple from pySim.exceptions import SwMatchError from pySim.transport import LinkBase @@ -34,11 +34,67 @@ # A path can be either just a FID or a list of FID Path = typing.Union[Hexstr, List[Hexstr]] +def lchan_nr_to_cla(cla: int, lchan_nr: int) -> int: + """Embed a logical channel number into the CLA byte.""" + # TS 102 221 10.1.1 Coding of Class Byte + if lchan_nr < 4: + # standard logical channel number + if cla >> 4 in [0x0, 0xA, 0x8]: + return (cla & 0xFC) | (lchan_nr & 3) + else: + raise ValueError('Undefined how to use CLA %2X with logical channel %u' % (cla, lchan_nr)) + elif lchan_nr < 16: + # extended logical channel number + if cla >> 6 in [1, 3]: + return (cla & 0xF0) | ((lchan_nr - 4) & 0x0F) + else: + raise ValueError('Undefined how to use CLA %2X with logical channel %u' % (cla, lchan_nr)) + else: + raise ValueError('logical channel outside of range 0 .. 15') + +def cla_with_lchan(cla_byte: Hexstr, lchan_nr: int) -> Hexstr: + """Embed a logical channel number into the hex-string encoded CLA value.""" + cla_int = h2i(cla_byte)[0] + return i2h([lchan_nr_to_cla(cla_int, lchan_nr)]) + class SimCardCommands: - def __init__(self, transport: LinkBase): + """Class providing methods for various card-specific commands such as SELECT, READ BINARY, etc. + Historically one instance exists below CardBase, but with the introduction of multiple logical + channels there can be multiple instances. The lchan number will then be patched into the CLA + byte by the respective instance. """ + def __init__(self, transport: LinkBase, lchan_nr: int = 0): self._tp = transport - self.cla_byte = "a0" + self._cla_byte = None self.sel_ctrl = "0000" + self.lchan_nr = lchan_nr + # invokes the setter below + self.cla_byte = "a0" + + def fork_lchan(self, lchan_nr: int) -> 'SimCardCommands': + """Fork a per-lchan specific SimCardCommands instance off the current instance.""" + ret = SimCardCommands(transport = self._tp, lchan_nr = lchan_nr) + ret.cla_byte = self._cla_byte + return ret + + @property + def cla_byte(self) -> Hexstr: + """Return the (cached) patched default CLA byte for this card.""" + return self._cla4lchan + + @cla_byte.setter + def cla_byte(self, new_val: Hexstr): + """Set the (raw, without lchan) default CLA value for this card.""" + self._cla_byte = new_val + # compute cached result + self._cla4lchan = cla_with_lchan(self._cla_byte, self.lchan_nr) + + def cla4lchan(self, cla: Hexstr) -> Hexstr: + """Compute the lchan-patched value of the given CLA value.""" + if not cla: + # return cached result to avoid re-computing this over and over again + return self._cla4lchan + else: + return cla_with_lchan(cla, self.lchan_nr) # Extract a single FCP item from TLV def __parse_fcp(self, fcp: Hexstr): @@ -344,9 +400,9 @@ # TS 102 221 Section 11.3.1 low-level helper def _retrieve_data(self, tag: int, first: bool = True) -> ResTuple: if first: - pdu = '80cb008001%02x' % (tag) + pdu = self.cla4lchan('80') + 'cb008001%02x' % (tag) else: - pdu = '80cb000000' + pdu = self.cla4lchan('80') + 'cb000000' return self._tp.send_apdu_checksw(pdu) def retrieve_data(self, ef: Path, tag: int) -> ResTuple: @@ -376,7 +432,7 @@ p1 = 0x00 if isinstance(data, bytes) or isinstance(data, bytearray): data = b2h(data) - pdu = '80db00%02x%02x%s' % (p1, len(data)//2, data) + pdu = self.cla4lchan('80') + 'db00%02x%02x%s' % (p1, len(data)//2, data) return self._tp.send_apdu_checksw(pdu) def set_data(self, ef, tag: int, value: str, verify: bool = False, conserve: bool = False) -> ResTuple: @@ -419,7 +475,7 @@ if len(rand) != 32: raise ValueError('Invalid rand') self.select_path(['3f00', '7f20']) - return self._tp.send_apdu_checksw('a0' + '88000010' + rand, sw='9000') + return self._tp.send_apdu_checksw(self.cla4lchan('a0') + '88000010' + rand, sw='9000') def authenticate(self, rand: Hexstr, autn: Hexstr, context: str = '3g') -> ResTuple: """Execute AUTHENTICATE (USIM/ISIM). @@ -451,7 +507,7 @@ def status(self) -> ResTuple: """Execute a STATUS command as per TS 102 221 Section 11.1.2.""" - return self._tp.send_apdu_checksw('80F20000ff') + return self._tp.send_apdu_checksw(self.cla4lchan('80') + 'F20000ff') def deactivate_file(self) -> ResTuple: """Execute DECATIVATE FILE command as per TS 102 221 Section 11.1.14.""" @@ -467,11 +523,11 @@ def create_file(self, payload: Hexstr) -> ResTuple: """Execute CREEATE FILE command as per TS 102 222 Section 6.3""" - return self._tp.send_apdu_checksw(self.cla_byte + 'e00000%02x%s' % (len(payload)//2, payload)) + return self._tp.send_apdu_checksw(self.cla_byte + self.cla4lchan('e0') + '0000%02x%s' % (len(payload)//2, payload)) def resize_file(self, payload: Hexstr) -> ResTuple: """Execute RESIZE FILE command as per TS 102 222 Section 6.10""" - return self._tp.send_apdu_checksw('80d40000%02x%s' % (len(payload)//2, payload)) + return self._tp.send_apdu_checksw(self.cla4lchan('80') + 'd40000%02x%s' % (len(payload)//2, payload)) def delete_file(self, fid: Hexstr) -> ResTuple: """Execute DELETE FILE command as per TS 102 222 Section 6.4""" -- To view, visit https://gerrit.osmocom.org/c/pysim/+/34846?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: Ibe5650dedc0f7681acf82018a86f83377ba81d30 Gerrit-Change-Number: 34846 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newchange
1 0
0 0
[M] Change in pysim[master]: pySim-shell: Create + use per-RuntimeLchan SimCardCommands
by laforge 21 Oct '23

21 Oct '23
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/34847?usp=email ) Change subject: pySim-shell: Create + use per-RuntimeLchan SimCardCommands ...................................................................... pySim-shell: Create + use per-RuntimeLchan SimCardCommands This new approach will "fork" separate SimCardCommands instances for each RuntimeLchan. Higher-layer code should now always use the RuntimeLchan.scc rather than the RuntimeState.card._scc in order to make sure commands use the correct logical channel. Change-Id: I13e2e871f2afc2460d9fd1cd566de42267c7d389 Related: OS#6230 --- M pySim-shell.py M pySim/ara_m.py M pySim/global_platform.py M pySim/runtime.py M pySim/ts_102_222.py M pySim/ts_31_102.py M pySim/ts_51_011.py 7 files changed, 59 insertions(+), 43 deletions(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/47/34847/1 diff --git a/pySim-shell.py b/pySim-shell.py index 867795c..8a1ad01 100755 --- a/pySim-shell.py +++ b/pySim-shell.py @@ -326,7 +326,7 @@ DANGEROUS: pySim-shell will not know any card state changes, and not continue to work as expected if you e.g. select a different file.""" - data, sw = self.card._scc._tp.send_apdu(opts.APDU) + data, sw = self.lchan.scc._tp.send_apdu(opts.APDU) if data: self.poutput("SW: %s, RESP: %s" % (sw, data)) else: @@ -790,7 +790,7 @@ "cannot find ADM-PIN for ICCID '%s'" % (self._cmd.iccid)) if pin_adm: - self._cmd.card._scc.verify_chv(self._cmd.card._adm_chv_num, h2b(pin_adm)) + self._cmd.lchan.scc.verify_chv(self._cmd.card._adm_chv_num, h2b(pin_adm)) else: raise ValueError("error: cannot authenticate, no adm-pin!") @@ -798,10 +798,10 @@ """Display information about the currently inserted card""" self._cmd.poutput("Card info:") self._cmd.poutput(" Name: %s" % self._cmd.card.name) - self._cmd.poutput(" ATR: %s" % b2h(self._cmd.card._scc.get_atr())) + self._cmd.poutput(" ATR: %s" % b2h(self._cmd.lchan.scc.get_atr())) self._cmd.poutput(" ICCID: %s" % self._cmd.iccid) - self._cmd.poutput(" Class-Byte: %s" % self._cmd.card._scc.cla_byte) - self._cmd.poutput(" Select-Ctrl: %s" % self._cmd.card._scc.sel_ctrl) + self._cmd.poutput(" Class-Byte: %s" % self._cmd.lchan.scc.cla_byte) + self._cmd.poutput(" Select-Ctrl: %s" % self._cmd.lchan.scc.sel_ctrl) self._cmd.poutput(" AIDs:") for a in self._cmd.rs.mf.applications: self._cmd.poutput(" %s" % a) @@ -859,7 +859,7 @@ call it if you authenticate yourself using the specified PIN. There usually is at least PIN1 and PIN2.""" pin = self.get_code(opts.pin_code) - (data, sw) = self._cmd.card._scc.verify_chv(opts.pin_nr, h2b(pin)) + (data, sw) = self._cmd.lchan.scc.verify_chv(opts.pin_nr, h2b(pin)) self._cmd.poutput("CHV verification successful") unblock_chv_parser = argparse.ArgumentParser() @@ -875,7 +875,7 @@ """Unblock PIN code using specified PUK code""" new_pin = self.get_code(opts.new_pin_code) puk = self.get_code(opts.puk_code) - (data, sw) = self._cmd.card._scc.unblock_chv( + (data, sw) = self._cmd.lchan.scc.unblock_chv( opts.pin_nr, h2b(puk), h2b(new_pin)) self._cmd.poutput("CHV unblock successful") @@ -892,7 +892,7 @@ """Change PIN code to a new PIN code""" new_pin = self.get_code(opts.new_pin_code) pin = self.get_code(opts.pin_code) - (data, sw) = self._cmd.card._scc.change_chv( + (data, sw) = self._cmd.lchan.scc.change_chv( opts.pin_nr, h2b(pin), h2b(new_pin)) self._cmd.poutput("CHV change successful") @@ -906,7 +906,7 @@ def do_disable_chv(self, opts): """Disable PIN code using specified PIN code""" pin = self.get_code(opts.pin_code) - (data, sw) = self._cmd.card._scc.disable_chv(opts.pin_nr, h2b(pin)) + (data, sw) = self._cmd.lchan.scc.disable_chv(opts.pin_nr, h2b(pin)) self._cmd.poutput("CHV disable successful") enable_chv_parser = argparse.ArgumentParser() @@ -919,12 +919,12 @@ def do_enable_chv(self, opts): """Enable PIN code using specified PIN code""" pin = self.get_code(opts.pin_code) - (data, sw) = self._cmd.card._scc.enable_chv(opts.pin_nr, h2b(pin)) + (data, sw) = self._cmd.lchan.scc.enable_chv(opts.pin_nr, h2b(pin)) self._cmd.poutput("CHV enable successful") def do_deactivate_file(self, opts): """Deactivate the currently selected EF""" - (data, sw) = self._cmd.card._scc.deactivate_file() + (data, sw) = self._cmd.lchan.scc.deactivate_file() activate_file_parser = argparse.ArgumentParser() activate_file_parser.add_argument('NAME', type=str, help='File name or FID of file to activate') @@ -946,7 +946,7 @@ @cmd2.with_argparser(open_chan_parser) def do_open_channel(self, opts): """Open a logical channel.""" - (data, sw) = self._cmd.card._scc.manage_channel( + (data, sw) = self._cmd.lchan.scc.manage_channel( mode='open', lchan_nr=opts.chan_nr) # this is executed only in successful case, as unsuccessful raises exception self._cmd.lchan.add_lchan(opts.chan_nr) @@ -958,7 +958,7 @@ @cmd2.with_argparser(close_chan_parser) def do_close_channel(self, opts): """Close a logical channel.""" - (data, sw) = self._cmd.card._scc.manage_channel( + (data, sw) = self._cmd.lchan.scc.manage_channel( mode='close', lchan_nr=opts.chan_nr) # this is executed only in successful case, as unsuccessful raises exception self._cmd.rs.del_lchan(opts.chan_nr) diff --git a/pySim/ara_m.py b/pySim/ara_m.py index 8144381..b4ac747 100644 --- a/pySim/ara_m.py +++ b/pySim/ara_m.py @@ -306,13 +306,13 @@ def do_aram_get_all(self, opts): """GET DATA [All] on the ARA-M Applet""" - res_do = ADF_ARAM.get_all(self._cmd.card._scc._tp) + res_do = ADF_ARAM.get_all(self._cmd.lchan.scc._tp) if res_do: self._cmd.poutput_json(res_do.to_dict()) def do_aram_get_config(self, opts): """Perform GET DATA [Config] on the ARA-M Applet: Tell it our version and retrieve its version.""" - res_do = ADF_ARAM.get_config(self._cmd.card._scc._tp) + res_do = ADF_ARAM.get_config(self._cmd.lchan.scc._tp) if res_do: self._cmd.poutput_json(res_do.to_dict()) @@ -373,14 +373,14 @@ d = [{'ref_ar_do': [{'ref_do': ref_do_content}, {'ar_do': ar_do_content}]}] csrado = CommandStoreRefArDO() csrado.from_dict(d) - res_do = ADF_ARAM.store_data(self._cmd.card._scc._tp, csrado) + res_do = ADF_ARAM.store_data(self._cmd.lchan.scc._tp, csrado) if res_do: self._cmd.poutput_json(res_do.to_dict()) def do_aram_delete_all(self, opts): """Perform STORE DATA [Command-Delete[all]] to delete all access rules.""" deldo = CommandDelete() - res_do = ADF_ARAM.store_data(self._cmd.card._scc._tp, deldo) + res_do = ADF_ARAM.store_data(self._cmd.lchan.scc._tp, deldo) if res_do: self._cmd.poutput_json(res_do.to_dict()) diff --git a/pySim/global_platform.py b/pySim/global_platform.py index ea8b70d..bfa2adf 100644 --- a/pySim/global_platform.py +++ b/pySim/global_platform.py @@ -238,7 +238,7 @@ self._cmd.poutput('Unknown data object "%s", available options: %s' % (tlv_cls_name, do_names)) return - (data, sw) = self._cmd.card._scc.get_data(cla=0x80, tag=tlv_cls.tag) + (data, sw) = self._cmd.lchan.scc.get_data(cla=0x80, tag=tlv_cls.tag) ie = tlv_cls() ie.from_tlv(h2b(data)) self._cmd.poutput_json(ie.to_dict()) diff --git a/pySim/runtime.py b/pySim/runtime.py index 88de69e..27c2ef1 100644 --- a/pySim/runtime.py +++ b/pySim/runtime.py @@ -167,6 +167,7 @@ self.selected_adf = None self.selected_file_fcp = None self.selected_file_fcp_hex = None + self.scc = self.rs.card._scc.fork_lchan(lchan_nr) def add_lchan(self, lchan_nr: int) -> 'RuntimeLchan': """Add a new logical channel from the current logical channel. Just affects @@ -246,7 +247,7 @@ "Cannot select unknown file by name %s, only hexadecimal 4 digit FID is allowed" % fid) try: - (data, sw) = self.rs.card._scc.select_file(fid) + (data, sw) = self.scc.select_file(fid) except SwMatchError as swm: k = self.interpret_sw(swm.sw_actual) if not k: @@ -301,7 +302,7 @@ (data, sw) = self.rs.card.select_adf_by_aid(p.aid) self.selected_adf = p else: - (data, sw) = self.rs.card._scc.select_file(p.fid) + (data, sw) = self.scc.select_file(p.fid) self.selected_file = p except SwMatchError as swm: self._select_post(cmd_app) @@ -344,7 +345,7 @@ if isinstance(f, CardADF): (data, sw) = self.rs.card.select_adf_by_aid(f.aid) else: - (data, sw) = self.rs.card._scc.select_file(f.fid) + (data, sw) = self.scc.select_file(f.fid) self.selected_file = f except SwMatchError as swm: k = self.interpret_sw(swm.sw_actual) @@ -364,7 +365,7 @@ def status(self): """Request STATUS (current selected file FCP) from card.""" - (data, sw) = self.rs.card._scc.status() + (data, sw) = self.scc.status() return self.selected_file.decode_select_response(data) def get_file_for_selectable(self, name: str): @@ -375,7 +376,7 @@ """Request ACTIVATE FILE of specified file.""" sels = self.selected_file.get_selectables() f = sels[name] - data, sw = self.rs.card._scc.activate_file(f.fid) + data, sw = self.scc.activate_file(f.fid) return data, sw def read_binary(self, length: int = None, offset: int = 0): @@ -389,7 +390,7 @@ """ if not isinstance(self.selected_file, TransparentEF): raise TypeError("Only works with TransparentEF") - return self.rs.card._scc.read_binary(self.selected_file.fid, length, offset) + return self.scc.read_binary(self.selected_file.fid, length, offset) def read_binary_dec(self) -> Tuple[dict, str]: """Read [part of] a transparent EF binary data and decode it. @@ -413,7 +414,7 @@ """ if not isinstance(self.selected_file, TransparentEF): raise TypeError("Only works with TransparentEF") - return self.rs.card._scc.update_binary(self.selected_file.fid, data_hex, offset, conserve=self.rs.conserve_write) + return self.scc.update_binary(self.selected_file.fid, data_hex, offset, conserve=self.rs.conserve_write) def update_binary_dec(self, data: dict): """Update transparent EF from abstract data. Encodes the data to binary and @@ -436,7 +437,7 @@ if not isinstance(self.selected_file, LinFixedEF): raise TypeError("Only works with Linear Fixed EF") # returns a string of hex nibbles - return self.rs.card._scc.read_record(self.selected_file.fid, rec_nr) + return self.scc.read_record(self.selected_file.fid, rec_nr) def read_record_dec(self, rec_nr: int = 0) -> Tuple[dict, str]: """Read a record and decode it to abstract data. @@ -458,7 +459,7 @@ """ if not isinstance(self.selected_file, LinFixedEF): raise TypeError("Only works with Linear Fixed EF") - return self.rs.card._scc.update_record(self.selected_file.fid, rec_nr, data_hex, + return self.scc.update_record(self.selected_file.fid, rec_nr, data_hex, conserve=self.rs.conserve_write, leftpad=self.selected_file.leftpad) @@ -484,7 +485,7 @@ if not isinstance(self.selected_file, BerTlvEF): raise TypeError("Only works with BER-TLV EF") # returns a string of hex nibbles - return self.rs.card._scc.retrieve_data(self.selected_file.fid, tag) + return self.scc.retrieve_data(self.selected_file.fid, tag) def retrieve_tags(self): """Retrieve tags available on BER-TLV EF. @@ -494,7 +495,7 @@ """ if not isinstance(self.selected_file, BerTlvEF): raise TypeError("Only works with BER-TLV EF") - data, sw = self.rs.card._scc.retrieve_data(self.selected_file.fid, 0x5c) + data, sw = self.scc.retrieve_data(self.selected_file.fid, 0x5c) tag, length, value, remainder = bertlv_parse_one(h2b(data)) return list(value) @@ -507,7 +508,7 @@ """ if not isinstance(self.selected_file, BerTlvEF): raise TypeError("Only works with BER-TLV EF") - return self.rs.card._scc.set_data(self.selected_file.fid, tag, data_hex, conserve=self.rs.conserve_write) + return self.scc.set_data(self.selected_file.fid, tag, data_hex, conserve=self.rs.conserve_write) def unregister_cmds(self, cmd_app=None): """Unregister all file specific commands.""" diff --git a/pySim/ts_102_222.py b/pySim/ts_102_222.py index a4ea453..372d67f 100644 --- a/pySim/ts_102_222.py +++ b/pySim/ts_102_222.py @@ -49,7 +49,7 @@ self._cmd.perror("Refusing to permanently delete the file, please read the help text.") return f = self._cmd.lchan.get_file_for_selectable(opts.NAME) - (data, sw) = self._cmd.card._scc.delete_file(f.fid) + (data, sw) = self._cmd.lchan.scc.delete_file(f.fid) def complete_delete_file(self, text, line, begidx, endidx) -> List[str]: """Command Line tab completion for DELETE FILE""" @@ -70,7 +70,7 @@ self._cmd.perror("Refusing to terminate the file, please read the help text.") return f = self._cmd.lchan.get_file_for_selectable(opts.NAME) - (data, sw) = self._cmd.card._scc.terminate_df(f.fid) + (data, sw) = self._cmd.lchan.scc.terminate_df(f.fid) def complete_terminate_df(self, text, line, begidx, endidx) -> List[str]: """Command Line tab completion for TERMINATE DF""" @@ -86,7 +86,7 @@ self._cmd.perror("Refusing to terminate the file, please read the help text.") return f = self._cmd.lchan.get_file_for_selectable(opts.NAME) - (data, sw) = self._cmd.card._scc.terminate_ef(f.fid) + (data, sw) = self._cmd.lchan.scc.terminate_ef(f.fid) def complete_terminate_ef(self, text, line, begidx, endidx) -> List[str]: """Command Line tab completion for TERMINATE EF""" @@ -104,7 +104,7 @@ if not opts.force_terminate_card: self._cmd.perror("Refusing to permanently terminate the card, please read the help text.") return - (data, sw) = self._cmd.card._scc.terminate_card_usage() + (data, sw) = self._cmd.lchan.scc.terminate_card_usage() create_parser = argparse.ArgumentParser() create_parser.add_argument('FILE_ID', type=str, help='File Identifier as 4-character hex string') @@ -149,7 +149,7 @@ ShortFileIdentifier(decoded=opts.short_file_id), ] fcp = FcpTemplate(children=ies) - (data, sw) = self._cmd.card._scc.create_file(b2h(fcp.to_tlv())) + (data, sw) = self._cmd.lchan.scc.create_file(b2h(fcp.to_tlv())) # the newly-created file is automatically selected but our runtime state knows nothing of it self._cmd.lchan.select_file(self._cmd.lchan.selected_file) @@ -200,7 +200,7 @@ } ies.append(ProprietaryInformation(children=[ToolkitAccessConditions(decoded=toolkit_ac)])) fcp = FcpTemplate(children=ies) - (data, sw) = self._cmd.card._scc.create_file(b2h(fcp.to_tlv())) + (data, sw) = self._cmd.lchan.scc.create_file(b2h(fcp.to_tlv())) # the newly-created file is automatically selected but our runtime state knows nothing of it self._cmd.lchan.select_file(self._cmd.lchan.selected_file) @@ -217,7 +217,7 @@ ies = [FileIdentifier(decoded=f.fid), FileSize(decoded=opts.file_size)] fcp = FcpTemplate(children=ies) - (data, sw) = self._cmd.card._scc.resize_file(b2h(fcp.to_tlv())) + (data, sw) = self._cmd.lchan.scc.resize_file(b2h(fcp.to_tlv())) # the resized file is automatically selected but our runtime state knows nothing of it self._cmd.lchan.select_file(self._cmd.lchan.selected_file) diff --git a/pySim/ts_31_102.py b/pySim/ts_31_102.py index 54ff4c8..cd0d99c 100644 --- a/pySim/ts_31_102.py +++ b/pySim/ts_31_102.py @@ -1512,7 +1512,7 @@ @cmd2.with_argparser(authenticate_parser) def do_authenticate(self, opts): """Perform Authentication and Key Agreement (AKA).""" - (data, sw) = self._cmd.card._scc.authenticate(opts.rand, opts.autn) + (data, sw) = self._cmd.lchan.scc.authenticate(opts.rand, opts.autn) self._cmd.poutput_json(data) term_prof_parser = argparse.ArgumentParser() @@ -1526,7 +1526,7 @@ in the context of SIM Toolkit, Proactive SIM and OTA. You must specify a hex-string with the encoded terminal profile you want to send to the card.""" - (data, sw) = self._cmd.card._scc.terminal_profile(opts.PROFILE) + (data, sw) = self._cmd.lchan.scc.terminal_profile(opts.PROFILE) self._cmd.poutput('SW: %s, data: %s' % (sw, data)) envelope_parser = argparse.ArgumentParser() @@ -1538,7 +1538,7 @@ variety of information is communicated from the terminal (modem/phone) to the card, particularly in the context of SIM Toolkit, Proactive SIM and OTA.""" - (data, sw) = self._cmd.card._scc.envelope(opts.PAYLOAD) + (data, sw) = self._cmd.lchan.scc.envelope(opts.PAYLOAD) self._cmd.poutput('SW: %s, data: %s' % (sw, data)) envelope_sms_parser = argparse.ArgumentParser() @@ -1556,7 +1556,7 @@ dev_ids = DeviceIdentities( decoded={'source_dev_id': 'network', 'dest_dev_id': 'uicc'}) sms_dl = SMSPPDownload(children=[dev_ids, tpdu_ie]) - (data, sw) = self._cmd.card._scc.envelope(b2h(sms_dl.to_tlv())) + (data, sw) = self._cmd.lchan.scc.envelope(b2h(sms_dl.to_tlv())) self._cmd.poutput('SW: %s, data: %s' % (sw, data)) get_id_parser = argparse.ArgumentParser() @@ -1570,7 +1570,7 @@ context = 0x01 # SUCI if opts.nswo_context: context = 0x02 # SUCI 5G NSWO - (data, sw) = self._cmd.card._scc.get_identity(context) + (data, sw) = self._cmd.lchan.scc.get_identity(context) do = SUCI_TlvDataObject() do.from_tlv(h2b(data)) do_d = do.to_dict() diff --git a/pySim/ts_51_011.py b/pySim/ts_51_011.py index 14db686..7413098 100644 --- a/pySim/ts_51_011.py +++ b/pySim/ts_51_011.py @@ -1001,7 +1001,7 @@ @cmd2.with_argparser(authenticate_parser) def do_authenticate(self, opts): """Perform GSM Authentication.""" - (data, sw) = self._cmd.card._scc.run_gsm(opts.rand) + (data, sw) = self._cmd.lchan.scc.run_gsm(opts.rand) self._cmd.poutput_json(data) -- To view, visit https://gerrit.osmocom.org/c/pysim/+/34847?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: I13e2e871f2afc2460d9fd1cd566de42267c7d389 Gerrit-Change-Number: 34847 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in ...osmo-epdg[master]: diameter_3gpp_ts29_273_swx.dia: Fix whitespace
by pespin 21 Oct '23

21 Oct '23
pespin has submitted this change. ( https://gerrit.osmocom.org/c/erlang/osmo-epdg/+/34842?usp=email ) ( 1 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: diameter_3gpp_ts29_273_swx.dia: Fix whitespace ...................................................................... diameter_3gpp_ts29_273_swx.dia: Fix whitespace Change-Id: I2966070ee1bd7709565ab7b568ae6f23a3b6954f --- M dia/diameter_3gpp_ts29_273_swx.dia 1 file changed, 10 insertions(+), 2 deletions(-) Approvals: Jenkins Builder: Verified fixeria: Looks good to me, approved diff --git a/dia/diameter_3gpp_ts29_273_swx.dia b/dia/diameter_3gpp_ts29_273_swx.dia index d6f91da..d6d446c 100644 --- a/dia/diameter_3gpp_ts29_273_swx.dia +++ b/dia/diameter_3gpp_ts29_273_swx.dia @@ -33,7 +33,6 @@ @vendor 10415 3GPP @inherits diameter_gen_base_rfc6733 - @inherits diameter_3gpp_base @inherits diameter_3gpp_break_circles @inherits diameter_3gpp_ts29_212 @@ -113,7 +112,7 @@ *[ Supported-Features ] *[ AVP ] -;; 8.2.2.2 Push-Profile-Answer +;; 8.2.2.2 Push-Profile-Answer PPA ::= < Diameter Header: 305, PXY > < Session-Id > { Auth-Session-State } -- To view, visit https://gerrit.osmocom.org/c/erlang/osmo-epdg/+/34842?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: erlang/osmo-epdg Gerrit-Branch: master Gerrit-Change-Id: I2966070ee1bd7709565ab7b568ae6f23a3b6954f Gerrit-Change-Number: 34842 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
[S] Change in pysim[master]: cards.py: Fix type annotation
by laforge 21 Oct '23

21 Oct '23
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/34843?usp=email ) Change subject: cards.py: Fix type annotation ...................................................................... cards.py: Fix type annotation The CardBaes 'scc' member refers to a SimCardCommands instance, not to a LinkBase. Change-Id: If4c0dfbd8c9a03d1a0bc4129bb3c5d5fa492d4cb --- M pySim/cards.py 1 file changed, 17 insertions(+), 6 deletions(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/43/34843/1 diff --git a/pySim/cards.py b/pySim/cards.py index b1adcf2..84f53e1 100644 --- a/pySim/cards.py +++ b/pySim/cards.py @@ -25,15 +25,14 @@ from typing import Optional, Dict, Tuple from pySim.ts_102_221 import EF_DIR from pySim.ts_51_011 import DF_GSM -from pySim.transport import LinkBase import abc from pySim.utils import * -from pySim.commands import Path +from pySim.commands import Path, SimCardCommands class CardBase: """General base class for some kind of telecommunications card.""" - def __init__(self, scc: LinkBase): + def __init__(self, scc: SimCardCommands): self._scc = scc self._aids = [] @@ -75,7 +74,7 @@ any higher-layer processing.""" name = 'SIM' - def __init__(self, scc: LinkBase): + def __init__(self, scc: SimCardCommands): super(SimCardBase, self).__init__(scc) self._scc.cla_byte = "A0" self._scc.sel_ctrl = "0000" @@ -88,7 +87,7 @@ class UiccCardBase(SimCardBase): name = 'UICC' - def __init__(self, scc: LinkBase): + def __init__(self, scc: SimCardCommands): super(UiccCardBase, self).__init__(scc) self._scc.cla_byte = "00" self._scc.sel_ctrl = "0004" # request an FCP @@ -162,7 +161,7 @@ return self._scc.select_adf(aid) return (None, None) -def card_detect(scc: LinkBase) -> Optional[CardBase]: +def card_detect(scc: SimCardCommands) -> Optional[CardBase]: # UICC always has higher preference, as a UICC might also contain a SIM application uicc = UiccCardBase(scc) if uicc.probe(): -- To view, visit https://gerrit.osmocom.org/c/pysim/+/34843?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: If4c0dfbd8c9a03d1a0bc4129bb3c5d5fa492d4cb Gerrit-Change-Number: 34843 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in pysim[master]: pySim-shell: Create/delete RuntimeLchan objects on open/close of channel
by laforge 21 Oct '23

21 Oct '23
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/34844?usp=email ) Change subject: pySim-shell: Create/delete RuntimeLchan objects on open/close of channel ...................................................................... pySim-shell: Create/delete RuntimeLchan objects on open/close of channel We already have the open channel and close_channel commands in pySim-shell. They are sent to the card and acknowledged, respectively. We also already do have code that can track multiple different logical channels (the rs.lchan array). However, this is currently only used by pySim-trace, and not by pySim-shell. Let's change that. Change-Id: Idacee2dc57e8afe85c79bc85b259064e7f5b83a2 Related: OS#6230 --- M pySim-shell.py 1 file changed, 21 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/44/34844/1 diff --git a/pySim-shell.py b/pySim-shell.py index a79949c..867795c 100755 --- a/pySim-shell.py +++ b/pySim-shell.py @@ -948,6 +948,8 @@ """Open a logical channel.""" (data, sw) = self._cmd.card._scc.manage_channel( mode='open', lchan_nr=opts.chan_nr) + # this is executed only in successful case, as unsuccessful raises exception + self._cmd.lchan.add_lchan(opts.chan_nr) close_chan_parser = argparse.ArgumentParser() close_chan_parser.add_argument( @@ -958,6 +960,8 @@ """Close a logical channel.""" (data, sw) = self._cmd.card._scc.manage_channel( mode='close', lchan_nr=opts.chan_nr) + # this is executed only in successful case, as unsuccessful raises exception + self._cmd.rs.del_lchan(opts.chan_nr) def do_status(self, opts): """Perform the STATUS command.""" -- To view, visit https://gerrit.osmocom.org/c/pysim/+/34844?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: Idacee2dc57e8afe85c79bc85b259064e7f5b83a2 Gerrit-Change-Number: 34844 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in pysim[master]: RuntimeState: Add type annotation for 'card' argument
by laforge 21 Oct '23

21 Oct '23
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/34845?usp=email ) Change subject: RuntimeState: Add type annotation for 'card' argument ...................................................................... RuntimeState: Add type annotation for 'card' argument Change-Id: I3c5138a918f7e45aabe3972883714d05ee704877 --- M pySim/runtime.py 1 file changed, 10 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/45/34845/1 diff --git a/pySim/runtime.py b/pySim/runtime.py index d6c6d19..88de69e 100644 --- a/pySim/runtime.py +++ b/pySim/runtime.py @@ -38,7 +38,7 @@ class RuntimeState: """Represent the runtime state of a session with a card.""" - def __init__(self, card, profile: 'CardProfile'): + def __init__(self, card: 'CardBase', profile: 'CardProfile'): """ Args: card : pysim.cards.Card instance -- To view, visit https://gerrit.osmocom.org/c/pysim/+/34845?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: I3c5138a918f7e45aabe3972883714d05ee704877 Gerrit-Change-Number: 34845 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in ...osmo-epdg[master]: diameter_3gpp_ts29_273_swx.dia: Fix whitespace
by fixeria 21 Oct '23

21 Oct '23
Attention is currently required from: pespin. fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/erlang/osmo-epdg/+/34842?usp=email ) Change subject: diameter_3gpp_ts29_273_swx.dia: Fix whitespace ...................................................................... Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/erlang/osmo-epdg/+/34842?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: erlang/osmo-epdg Gerrit-Branch: master Gerrit-Change-Id: I2966070ee1bd7709565ab7b568ae6f23a3b6954f Gerrit-Change-Number: 34842 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Sat, 21 Oct 2023 04:44:09 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[S] Change in osmo-ttcn3-hacks[master]: ggsn: log start of test in SUT
by fixeria 21 Oct '23

21 Oct '23
Attention is currently required from: osmith. fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/34839?usp=email ) Change subject: ggsn: log start of test in SUT ...................................................................... Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/34839?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: I2baccc2b49e8bcbf0d1ca6dae41624b2d18fc0fa Gerrit-Change-Number: 34839 Gerrit-PatchSet: 1 Gerrit-Owner: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Attention: osmith <osmith(a)sysmocom.de> Gerrit-Comment-Date: Sat, 21 Oct 2023 04:35:54 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[M] Change in osmo-ttcn3-hacks[master]: library: deduplicate f_logp
by fixeria 21 Oct '23

21 Oct '23
Attention is currently required from: osmith. fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/34838?usp=email ) Change subject: library: deduplicate f_logp ...................................................................... Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/34838?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: Ie84a8a75e9f162fcbef0d07d0bc75e47a5303fa3 Gerrit-Change-Number: 34838 Gerrit-PatchSet: 1 Gerrit-Owner: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Attention: osmith <osmith(a)sysmocom.de> Gerrit-Comment-Date: Sat, 21 Oct 2023 04:35:27 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • ...
  • 185
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.