[L] Change in pysim[master]: Initial support for eUICC

2023-10-22 Thread laforge
Attention is currently required from: dexter, laforge.

Hello Jenkins Builder, dexter,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/pysim/+/34852?usp=email

to look at the new patch set (#4).


Change subject: Initial support for eUICC
..

Initial support for eUICC

This just adds basic support for the ISD-R application and its
associated STORE DATA command which is used for the ES10x interfaces
between off-card entities and the on-card ISD-R.

Change-Id: Ieab37b083e25d3f36c20f6e9ed3e4bdfdd14a42a
Closes: OS#5637
---
M pySim-shell.py
A pySim/euicc.py
M pySim/global_platform.py
3 files changed, 350 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/52/34852/4
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/34852?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: Ieab37b083e25d3f36c20f6e9ed3e4bdfdd14a42a
Gerrit-Change-Number: 34852
Gerrit-PatchSet: 4
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-Attention: laforge 
Gerrit-Attention: dexter 
Gerrit-MessageType: newpatchset


[L] Change in pysim[master]: Initial support for eUICC

2023-10-22 Thread laforge
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/+/34852?usp=email

to look at the new patch set (#2).

The following approvals got outdated and were removed:
Verified-1 by Jenkins Builder


Change subject: Initial support for eUICC
..

Initial support for eUICC

This just adds basic support for the ISD-R application and its
associated STORE DATA command which is used for the ES10x interfaces
between off-card entities and the on-card ISD-R.

Change-Id: Ieab37b083e25d3f36c20f6e9ed3e4bdfdd14a42a
Related: OS#6230
---
M pySim-shell.py
A pySim/euicc.py
M pySim/global_platform.py
3 files changed, 350 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/52/34852/2
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/34852?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: Ieab37b083e25d3f36c20f6e9ed3e4bdfdd14a42a
Gerrit-Change-Number: 34852
Gerrit-PatchSet: 2
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Attention: laforge 
Gerrit-MessageType: newpatchset


[S] Change in pysim[master]: utils: Fix bertlv_encode_tag() for multi-byte tags

2023-10-22 Thread laforge
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/+/34851?usp=email

to look at the new patch set (#2).

The following approvals got outdated and were removed:
Verified-1 by Jenkins Builder


Change subject: utils: Fix bertlv_encode_tag() for multi-byte tags
..

utils: Fix bertlv_encode_tag() for multi-byte tags

We used to support only single-byte tags in bertlv_encode_tag,
let's fix that.  The easy option is to simply call bertlv_parse_tag,
as that already supported multi-byte tags.

Change-Id: If0bd9137883c4c8b01c4dfcbb53cabeee5c1ce2b
---
M pySim/utils.py
1 file changed, 28 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/51/34851/2
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/34851?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: If0bd9137883c4c8b01c4dfcbb53cabeee5c1ce2b
Gerrit-Change-Number: 34851
Gerrit-PatchSet: 2
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Attention: laforge 
Gerrit-MessageType: newpatchset


[L] Change in pysim[master]: Initial support for eUICC

2023-10-22 Thread laforge
laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/pysim/+/34852?usp=email )


Change subject: Initial support for eUICC
..

Initial support for eUICC

This just adds basic support for the ISD-R application and its
associated STORE DATA command which is used for the ES10x interfaces
between off-card entities and the on-card ISD-R.

Change-Id: Ieab37b083e25d3f36c20f6e9ed3e4bdfdd14a42a
Related: OS#6230
---
M pySim-shell.py
A pySim/euicc.py
M pySim/global_platform.py
3 files changed, 352 insertions(+), 4 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/52/34852/1

diff --git a/pySim-shell.py b/pySim-shell.py
index 022b276..bbb14b2 100755
--- a/pySim-shell.py
+++ b/pySim-shell.py
@@ -77,6 +77,7 @@
 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

diff --git a/pySim/euicc.py b/pySim/euicc.py
new file mode 100644
index 000..c189aaf
--- /dev/null
+++ b/pySim/euicc.py
@@ -0,0 +1,330 @@
+# -*- coding: utf-8 -*-
+
+"""
+Various definitions related to GSMA eSIM / eUICC
+
+Related Specs: GSMA SGP.22, GSMA SGP.02, etc.
+"""
+
+# Copyright (C) 2023 Harald Welte 
+#
+# 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 .
+
+from pySim.tlv import *
+from pySim.construct import *
+from construct import Optional as COptional
+from construct import *
+import argparse
+from cmd2 import cmd2, CommandSet, with_default_category
+from pySim.commands import SimCardCommands
+from pySim.filesystem import CardADF, CardApplication
+from pySim.utils import Hexstr, SwHexstr
+import pySim.global_platform
+
+# Application Identifiers as defined in GSMA SGP.02 Annex H
+AID_ISD_R   = "A005591010890100"
+AID_ECASD   = "A005591010890200"
+AID_ISD_P_FILE  = "A005591010890D00"
+AID_ISD_P_MODULE= "A005591010890E00"
+
+sw_isdr = {
+'ISD-R': {
+'6a80': 'Incorrect values in command data',
+'6a82': 'Profile not found',
+'6a88': 'Reference data not found',
+'6985': 'Conditions of use not satisfied',
+}
+}
+
+class SupportedVersionNumber(BER_TLV_IE, tag=0x82):
+_construct = GreedyBytes
+
+class IsdrProprietaryApplicationTemplate(BER_TLV_IE, tag=0xe0, 
nested=[SupportedVersionNumber]):
+# FIXME: lpaeSupport - what kind of tag  would it have?
+pass
+
+# GlobalPlatform 2.1.1 Section 9.9.3.1 from pySim/global_platform.py extended 
with E0
+class FciTemplate(BER_TLV_IE, tag=0x6f, 
nested=pySim.global_platform.FciTemplateNestedList +
+   
[IsdrProprietaryApplicationTemplate]):
+pass
+
+
+# SGP.22 Section 5.7.3: GetEuiccConfiguredAddresses
+class DefaultDpAddress(BER_TLV_IE, tag=0x80):
+_construct = Utf8Adapter(GreedyBytes)
+class RootDsAddress(BER_TLV_IE, tag=0x81):
+_construct = Utf8Adapter(GreedyBytes)
+class EuiccConfiguredAddresses(BER_TLV_IE, tag=0xbf3c, 
nested=[DefaultDpAddress, RootDsAddress]):
+pass
+
+# SGP.22 Section 5.7.4: SetDefaultDpAddress
+class SetDefaultDpAddrRes(BER_TLV_IE, tag=0x80):
+_construct = Enum(Int8ub, ok=0, undefinedError=127)
+class SetDefaultDpAddress(BER_TLV_IE, tag=0xbf3f, nested=[DefaultDpAddress, 
SetDefaultDpAddrRes]):
+pass
+
+# SGP.22 Section 5.7.7: GetEUICCChallenge
+class EuiccChallenge(BER_TLV_IE, tag=0x80):
+_construct = HexAdapter(Bytes(16))
+class GetEuiccChallenge(BER_TLV_IE, tag=0xbf2e, nested=[EuiccChallenge]):
+pass
+
+# SGP.22 Section 5.7.9: ListNotification
+class ProfileMgmtOperation(BER_TLV_IE, tag=0x81):
+_construct = FlagsEnum(Byte, install=1, enable=2, disable=4, delete=8)
+class ListNotificationReq(BER_TLV_IE, tag=0xbf28, 
nested=[ProfileMgmtOperation]):
+pass
+class SeqNumber(BER_TLV_IE, tag=0x81):
+_construct = Int8ub
+class NotificationAddress(BER_TLV_IE, tag=0x82):
+_construct = Utf8Adapter(GreedyBytes)
+class Iccid(BER_TLV_IE, tag=0x5a):
+_construct = HexAdapter(GreedyBytes)
+class NotificationMetadata(BER_TLV_IE, tag=0xbf2f, nested=[SeqNumber, 
ProfileMgmtOperation,
+   
NotificationAddress, Iccid]):
+pass
+class 

[S] Change in pysim[master]: utils: Fix bertlv_encode_tag() for multi-byte tags

2023-10-22 Thread laforge
laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/pysim/+/34851?usp=email )


Change subject: utils: Fix bertlv_encode_tag() for multi-byte tags
..

utils: Fix bertlv_encode_tag() for multi-byte tags

We used to support only single-byte tags in bertlv_encode_tag,
let's fix that.  The easy option is to simply call bertlv_parse_tag,
as that already supported multi-byte tags.

Change-Id: If0bd9137883c4c8b01c4dfcbb53cabeee5c1ce2b
---
M pySim/utils.py
1 file changed, 28 insertions(+), 8 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/51/34851/1

diff --git a/pySim/utils.py b/pySim/utils.py
index 6cacdaa..666f728 100644
--- a/pySim/utils.py
+++ b/pySim/utils.py
@@ -262,15 +262,22 @@
 remainder = inp & ~ (inp << (remain_bits - bitcnt))
 return outp, remainder

+def count_int_bytes(inp: int) -> int:
+"""count the number of bytes require to represent the given integer."""
+i = 1
+inp = inp >> 8
+while inp:
+i += 1
+inp = inp >> 8
+return i
+
 if isinstance(t, int):
-# FIXME: multiple byte tags
-tag = t & 0x1f
-constructed = True if t & 0x20 else False
-cls = t >> 6
-else:
-tag = t['tag']
-constructed = t['constructed']
-cls = t['class']
+# first convert to a dict representation
+tag_size = count_int_bytes(t)
+t, remainder = bertlv_parse_tag(t.to_bytes(tag_size))
+tag = t['tag']
+constructed = t['constructed']
+cls = t['class']
 if tag <= 30:
 t = tag & 0x1f
 if constructed:

--
To view, visit https://gerrit.osmocom.org/c/pysim/+/34851?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: If0bd9137883c4c8b01c4dfcbb53cabeee5c1ce2b
Gerrit-Change-Number: 34851
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-MessageType: newchange


[M] Change in libosmocore[master]: gsmtap_util: Use Osmo IO instead of Osmo write queues

2023-10-22 Thread arehbein
Attention is currently required from: daniel, laforge, pespin.

arehbein has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/34743?usp=email )

Change subject: gsmtap_util: Use Osmo IO instead of Osmo write queues
..


Patch Set 5:

(1 comment)

File src/core/gsmtap_util.c:

https://gerrit.osmocom.org/c/libosmocore/+/34743/comment/c7aff446_40c571ac
PS5, Line 478:  osmo_iofd_setup(gti, gti->sink_fd, "gsmtap_inst.out", 
OSMO_IO_FD_MODE_READ_WRITE, _sink_ops, NULL);
I have (for now) fixed the memleak keeping Osmo IO, since it was a quick fix 
and I'm not entirely I understand what you mean by

> simply never read from that fd and just keep it open there so no ICMP errors 
> are sent

?


I would think it means returning after the `fd = 
gsmtap_source_add_sink_fd(gsmtap_inst_fd2(gti));` line in 
`gsmtap_source_add_sink()`, but then I wouldn't understand why the call to 
`read()` was added to the Osmo FD callback in the original code.

I can of course also just go back to what the code did before (regarding sink 
functionality), but I thought I'd ask, since you mentioned these two options.



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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Iadbbef74e3add7001d84dd6b68f51eac293e44d0
Gerrit-Change-Number: 34743
Gerrit-PatchSet: 5
Gerrit-Owner: arehbein 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel 
Gerrit-Reviewer: pespin 
Gerrit-CC: laforge 
Gerrit-Attention: laforge 
Gerrit-Attention: pespin 
Gerrit-Attention: daniel 
Gerrit-Comment-Date: Sun, 22 Oct 2023 13:51:16 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: daniel 
Gerrit-MessageType: comment


[M] Change in libosmocore[master]: gsmtap_util: Use Osmo IO instead of Osmo write queues

2023-10-22 Thread arehbein
Attention is currently required from: daniel, laforge, pespin.

arehbein has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/34743?usp=email )

Change subject: gsmtap_util: Use Osmo IO instead of Osmo write queues
..


Patch Set 6:

(1 comment)

File src/core/gsmtap_util.c:

https://gerrit.osmocom.org/c/libosmocore/+/34743/comment/ad6358bb_936cc4f4
PS5, Line 478:  osmo_iofd_setup(gti, gti->sink_fd, "gsmtap_inst.out", 
OSMO_IO_FD_MODE_READ_WRITE, _sink_ops, NULL);
> I have (for now) fixed the memleak keeping Osmo IO, since it was a quick fix 
> and I'm not entirely I  […]
P.s.: I assume this isn't anything Osmo IO should be implementing, because this 
is more of a fringe case (actually reading data just to discard it)?



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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Iadbbef74e3add7001d84dd6b68f51eac293e44d0
Gerrit-Change-Number: 34743
Gerrit-PatchSet: 6
Gerrit-Owner: arehbein 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel 
Gerrit-Reviewer: pespin 
Gerrit-CC: laforge 
Gerrit-Attention: laforge 
Gerrit-Attention: pespin 
Gerrit-Attention: daniel 
Gerrit-Comment-Date: Sun, 22 Oct 2023 13:53:27 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: arehbein 
Comment-In-Reply-To: daniel 
Gerrit-MessageType: comment


[M] Change in libosmocore[master]: gsmtap_util: Use Osmo IO instead of Osmo write queues

2023-10-22 Thread arehbein
Attention is currently required from: arehbein, laforge, pespin.

Hello Jenkins Builder, daniel, pespin,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/libosmocore/+/34743?usp=email

to look at the new patch set (#6).

The following approvals got outdated and were removed:
Code-Review+1 by pespin, Verified+1 by Jenkins Builder


Change subject: gsmtap_util: Use Osmo IO instead of Osmo write queues
..

gsmtap_util: Use Osmo IO instead of Osmo write queues

 - Adapt decl. of 'struct gsmtap_inst' for usage of Osmo IO while maintaining 
backwards compatibility
 - Maintain legacy behavior without any message queues if osmo_io_mode is zero

Related: OS#6213
Change-Id: Iadbbef74e3add7001d84dd6b68f51eac293e44d0
---
M src/core/gsmtap_util.c
1 file changed, 66 insertions(+), 64 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/43/34743/6
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/34743?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Iadbbef74e3add7001d84dd6b68f51eac293e44d0
Gerrit-Change-Number: 34743
Gerrit-PatchSet: 6
Gerrit-Owner: arehbein 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel 
Gerrit-Reviewer: pespin 
Gerrit-CC: laforge 
Gerrit-Attention: arehbein 
Gerrit-Attention: laforge 
Gerrit-Attention: pespin 
Gerrit-MessageType: newpatchset


[S] Change in pysim[master]: pySim-shell: Create/delete RuntimeLchan objects on open/close of channel

2023-10-22 Thread laforge
laforge has submitted this change. ( 
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(-)

Approvals:
  laforge: Looks good to me, approved
  fixeria: Looks good to me, but someone else must approve
  Jenkins Builder: Verified




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 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: laforge 
Gerrit-MessageType: merged


[S] Change in pysim[master]: cards.py: Fix type annotation

2023-10-22 Thread laforge
laforge has submitted this change. ( 
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(-)

Approvals:
  laforge: Looks good to me, approved
  fixeria: Looks good to me, but someone else must approve
  Jenkins Builder: Verified




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 = ""
@@ -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 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: laforge 
Gerrit-MessageType: merged


[S] Change in pysim[master]: RuntimeState: Add type annotation for 'card' argument

2023-10-22 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/34845?usp=email )

Change subject: RuntimeState: Add type annotation for 'card' argument
..


Patch Set 1: Code-Review+2


--
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 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Sun, 22 Oct 2023 08:38:52 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


[S] Change in pysim[master]: pySim-shell: Create/delete RuntimeLchan objects on open/close of channel

2023-10-22 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/34844?usp=email )

Change subject: pySim-shell: Create/delete RuntimeLchan objects on open/close 
of channel
..


Patch Set 1: Code-Review+2


--
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 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Sun, 22 Oct 2023 08:38:46 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


[S] Change in pysim[master]: cards.py: Fix type annotation

2023-10-22 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/34843?usp=email )

Change subject: cards.py: Fix type annotation
..


Patch Set 1: Code-Review+2


--
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 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Sun, 22 Oct 2023 08:38:43 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


[S] Change in pysim[master]: RuntimeState: Add type annotation for 'card' argument

2023-10-22 Thread laforge
laforge has submitted this change. ( 
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(-)

Approvals:
  fixeria: Looks good to me, but someone else must approve
  Jenkins Builder: Verified
  laforge: Looks good to me, approved




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 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: laforge 
Gerrit-MessageType: merged


[S] Change in pysim[master]: pySim-shell: Include current logical channel in prompt

2023-10-22 Thread laforge
laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/pysim/+/34850?usp=email )


Change subject: pySim-shell: Include current logical channel in prompt
..

pySim-shell: Include current logical channel in prompt

Now that pySim-shell can switch between logical channels, let's state
the currently used logical channel in the prompt.

Change-Id: I45781a6fba205eeb4ac7f58d5cb642b7131bdd88
Related: OS#6230
---
M pySim-shell.py
1 file changed, 14 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/50/34850/1

diff --git a/pySim-shell.py b/pySim-shell.py
index 2f97389..022b276 100755
--- a/pySim-shell.py
+++ b/pySim-shell.py
@@ -291,7 +291,7 @@
 def update_prompt(self):
 if self.lchan:
 path_str = self.lchan.selected_file.fully_qualified_path_str(not 
self.numeric_path)
-self.prompt = 'pySIM-shell (%s)> ' % (path_str)
+self.prompt = 'pySIM-shell (%02u:%s)> ' % (self.lchan.lchan_nr, 
path_str)
 else:
 if self.card:
 self.prompt = 'pySIM-shell (no card profile)> '

--
To view, visit https://gerrit.osmocom.org/c/pysim/+/34850?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: I45781a6fba205eeb4ac7f58d5cb642b7131bdd88
Gerrit-Change-Number: 34850
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-MessageType: newchange


[S] Change in pysim[master]: prevent SimCardCommands.select_adf_by_aid bypassing lchan

2023-10-22 Thread laforge
laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/pysim/+/34849?usp=email )


Change subject: prevent SimCardCommands.select_adf_by_aid bypassing lchan
..

prevent SimCardCommands.select_adf_by_aid bypassing lchan

Now that pySim-shell is aware of logical channels and issues almost
all of its APDUs on the currently selected channel, we must also make
sure that ADF selection by AID (implemented by the CardBase class)
issues the SELECT on the respective logical channel.

Before this patch, SELECT ADF by AID would always be issued on the
primary logical channel (0), irrespective of the currently active
RuntimeLchan.

Change-Id: Idf05c297e6a2e24ca539408b8912e348c0782bb4
Related: OS#6230
---
M pySim/cards.py
M pySim/runtime.py
2 files changed, 26 insertions(+), 5 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/49/34849/1

diff --git a/pySim/cards.py b/pySim/cards.py
index 84f53e1..a241d1c 100644
--- a/pySim/cards.py
+++ b/pySim/cards.py
@@ -146,8 +146,10 @@
 return True
 return False

-def select_adf_by_aid(self, adf: str = "usim") -> Tuple[Optional[Hexstr], 
Optional[SwHexstr]]:
+def select_adf_by_aid(self, adf: str = "usim", scc: SimCardCommands = 
None) -> Tuple[Optional[Hexstr], Optional[SwHexstr]]:
 """Select ADF.U/ISIM in the Card using its full AID"""
+# caller may pass a custom scc; we fall back to default
+scc = scc or self._scc
 if is_hex(adf):
 aid = adf
 else:
@@ -155,10 +157,10 @@
 if aid:
 aid_full = self._complete_aid(aid)
 if aid_full:
-return self._scc.select_adf(aid_full)
+return scc.select_adf(aid_full)
 else:
 # If we cannot get the full AID, try with short AID
-return self._scc.select_adf(aid)
+return scc.select_adf(aid)
 return (None, None)

 def card_detect(scc: SimCardCommands) -> Optional[CardBase]:
diff --git a/pySim/runtime.py b/pySim/runtime.py
index 27c2ef1..a54a1b6 100644
--- a/pySim/runtime.py
+++ b/pySim/runtime.py
@@ -299,7 +299,7 @@
 for p in inter_path:
 try:
 if isinstance(p, CardADF):
-(data, sw) = self.rs.card.select_adf_by_aid(p.aid)
+(data, sw) = self.rs.card.select_adf_by_aid(p.aid, 
scc=self.scc)
 self.selected_adf = p
 else:
 (data, sw) = self.scc.select_file(p.fid)
@@ -343,7 +343,7 @@
 f = sels[name]
 try:
 if isinstance(f, CardADF):
-(data, sw) = self.rs.card.select_adf_by_aid(f.aid)
+(data, sw) = self.rs.card.select_adf_by_aid(f.aid, 
scc=self.scc)
 else:
 (data, sw) = self.scc.select_file(f.fid)
 self.selected_file = f

--
To view, visit https://gerrit.osmocom.org/c/pysim/+/34849?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: Idf05c297e6a2e24ca539408b8912e348c0782bb4
Gerrit-Change-Number: 34849
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-MessageType: newchange


[M] Change in pysim[master]: commands.py: Add support for multiple logical channels.

2023-10-22 Thread fixeria
Attention is currently required from: laforge.

fixeria has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/34846?usp=email )

Change subject: commands.py: Add support for multiple logical channels.
..


Patch Set 1: Code-Review+1


--
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 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Attention: laforge 
Gerrit-Comment-Date: Sun, 22 Oct 2023 07:30:15 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


[S] Change in pysim[master]: RuntimeState: Add type annotation for 'card' argument

2023-10-22 Thread fixeria
Attention is currently required from: laforge.

fixeria has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/34845?usp=email )

Change subject: RuntimeState: Add type annotation for 'card' argument
..


Patch Set 1: Code-Review+1


--
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 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Attention: laforge 
Gerrit-Comment-Date: Sun, 22 Oct 2023 07:27:57 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


[S] Change in pysim[master]: pySim-shell: Create/delete RuntimeLchan objects on open/close of channel

2023-10-22 Thread fixeria
Attention is currently required from: laforge.

fixeria has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/34844?usp=email )

Change subject: pySim-shell: Create/delete RuntimeLchan objects on open/close 
of channel
..


Patch Set 1: Code-Review+1


--
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 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Attention: laforge 
Gerrit-Comment-Date: Sun, 22 Oct 2023 07:26:55 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


[S] Change in pysim[master]: cards.py: Fix type annotation

2023-10-22 Thread fixeria
Attention is currently required from: laforge.

fixeria has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/34843?usp=email )

Change subject: cards.py: Fix type annotation
..


Patch Set 1: Code-Review+1


--
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 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Attention: laforge 
Gerrit-Comment-Date: Sun, 22 Oct 2023 07:26:22 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment