laforge has posted comments on this change by laforge. ( https://gerrit.osmocom.org/c/pysim/+/37833?usp=email )
Change subject: saip-tool: Set default log level to INFO (instead of DEBUG)
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/37833?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I54ae558cf8d87bf64cc75431cc4edcc694fa9084
Gerrit-Change-Number: 37833
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Comment-Date: Fri, 16 Aug 2024 16:51:59 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
laforge has posted comments on this change by laforge. ( https://gerrit.osmocom.org/c/pysim/+/37832?usp=email )
Change subject: pySim.filesystem: Permit Path object construction from FID integer list
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/37832?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ia7e9375b3258d1fbfdc892cefba3e3bbe841c550
Gerrit-Change-Number: 37832
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Comment-Date: Fri, 16 Aug 2024 16:51:55 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
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/+/37834?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: pySim.esim.saip.oid: Allow OID instance in prefix_match()
......................................................................
pySim.esim.saip.oid: Allow OID instance in prefix_match()
So far the prefix_match() required a string argument; let's also
permit another OID object to be passed; we internally convert that
to string.
Change-Id: I0feb7782d1813cc46ec78f170eb0fce804aebe3a
---
M pySim/esim/saip/oid.py
1 file changed, 2 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/34/37834/2
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/37834?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I0feb7782d1813cc46ec78f170eb0fce804aebe3a
Gerrit-Change-Number: 37834
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Attention: laforge <laforge(a)osmocom.org>
dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/37838?usp=email )
Change subject: pySim-shell: fix CardKeyProvider for chv management commands
......................................................................
pySim-shell: fix CardKeyProvider for chv management commands
The CardKeyProvider support for the commands enable_chv, disable_chv,
verify_chv, change_chv and unblock_chv is broken. The reason for this
is the annotation "type=is_decimal" in the argument parser. This annotation
prevents the usage of string placeholders ("PIN1", "PUK1", etc).
Let's fix this by finding a better solution. We can also replace any
missing PIN/PUK code by checking if it is supplied or not. If not,
we query the CardKeyProvider. This also makes the usage of the *_chv
commands more uniform with the verify_adm command.
Related: OS#6531
Change-Id: I565b56ac608e801c67ca53d337bdec9efa3f3817
---
M pySim-shell.py
1 file changed, 27 insertions(+), 30 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/38/37838/1
diff --git a/pySim-shell.py b/pySim-shell.py
index 3a89f2d..630d54a 100755
--- a/pySim-shell.py
+++ b/pySim-shell.py
@@ -851,50 +851,47 @@
index_dict = {1: self._cmd.lchan.selected_file.get_selectable_names()}
return self._cmd.index_based_complete(text, line, begidx, endidx, index_dict=index_dict)
- def get_code(self, code):
- """Use code either directly or try to get it from external data source"""
- auto = ('PIN1', 'PIN2', 'PUK1', 'PUK2')
-
- if str(code).upper() not in auto:
+ def get_code(self, code, field):
+ """Use code either directly or try to get it from external data source using the provided field name"""
+ if code is not None:
return sanitize_pin_adm(code)
-
iccid = self._cmd.rs.identity['ICCID']
- result = card_key_provider_get_field(str(code), key='ICCID', value=iccid)
+ result = card_key_provider_get_field(field, key='ICCID', value=iccid)
result = sanitize_pin_adm(result)
if result:
- self._cmd.poutput("found %s '%s' for ICCID '%s'" % (code.upper(), result, iccid))
+ self._cmd.poutput("found %s '%s' for ICCID '%s'" % (field, result, iccid))
else:
- self._cmd.poutput("cannot find %s for ICCID '%s'" % (code.upper(), iccid))
+ raise RuntimeError("cannot find %s for ICCID '%s'" % (field, iccid))
return result
verify_chv_parser = argparse.ArgumentParser()
+ verify_chv_parser.add_argument('PIN', nargs='?', type=is_decimal,
+ help='PIN code value. If none given, CSV file will be queried')
verify_chv_parser.add_argument(
'--pin-nr', type=int, default=1, help='PIN Number, 1=PIN1, 2=PIN2 or custom value (decimal)')
- verify_chv_parser.add_argument(
- 'pin_code', type=is_decimal, help='PIN code digits, \"PIN1\" or \"PIN2\" to get PIN code from external data source')
@cmd2.with_argparser(verify_chv_parser)
def do_verify_chv(self, opts):
"""Verify (authenticate) using specified CHV (PIN) code, which is how the specifications
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)
+ pin = self.get_code(opts.PIN, "PIN" + str(opts.pin_nr))
(data, sw) = self._cmd.lchan.scc.verify_chv(opts.pin_nr, h2b(pin))
self._cmd.poutput("CHV verification successful")
unblock_chv_parser = argparse.ArgumentParser()
+ unblock_chv_parser.add_argument('PUK', nargs='?', type=is_decimal,
+ help='PUK code value. If none given, CSV file will be queried')
+ unblock_chv_parser.add_argument('NEWPIN', nargs='?', type=is_decimal,
+ help='PIN code value. If none given, CSV file will be queried')
unblock_chv_parser.add_argument(
'--pin-nr', type=int, default=1, help='PUK Number, 1=PIN1, 2=PIN2 or custom value (decimal)')
- unblock_chv_parser.add_argument(
- 'puk_code', type=is_decimal, help='PUK code digits \"PUK1\" or \"PUK2\" to get PUK code from external data source')
- unblock_chv_parser.add_argument(
- 'new_pin_code', type=is_decimal, help='PIN code digits \"PIN1\" or \"PIN2\" to get PIN code from external data source')
@cmd2.with_argparser(unblock_chv_parser)
def do_unblock_chv(self, opts):
"""Unblock PIN code using specified PUK code"""
- new_pin = self.get_code(opts.new_pin_code)
- puk = self.get_code(opts.puk_code)
+ new_pin = self.get_code(opts.NEWPIN, "PIN" + str(opts.pin_nr))
+ puk = self.get_code(opts.PUK, "PUK" + str(opts.pin_nr))
(data, sw) = self._cmd.lchan.scc.unblock_chv(
opts.pin_nr, h2b(puk), h2b(new_pin))
self._cmd.poutput("CHV unblock successful")
@@ -902,43 +899,43 @@
change_chv_parser = argparse.ArgumentParser()
change_chv_parser.add_argument(
'--pin-nr', type=int, default=1, help='PUK Number, 1=PIN1, 2=PIN2 or custom value (decimal)')
- change_chv_parser.add_argument(
- 'pin_code', type=is_decimal, help='PIN code digits \"PIN1\" or \"PIN2\" to get PIN code from external data source')
- change_chv_parser.add_argument(
- 'new_pin_code', type=is_decimal, help='PIN code digits \"PIN1\" or \"PIN2\" to get PIN code from external data source')
+ change_chv_parser.add_argument('NEWPIN', nargs='?', type=is_decimal,
+ help='PIN code value. If none given, CSV file will be queried')
+ change_chv_parser.add_argument('PIN', nargs='?', type=is_decimal,
+ help='PIN code value. If none given, CSV file will be queried')
@cmd2.with_argparser(change_chv_parser)
def do_change_chv(self, opts):
"""Change PIN code to a new PIN code"""
- new_pin = self.get_code(opts.new_pin_code)
- pin = self.get_code(opts.pin_code)
+ new_pin = self.get_code(opts.NEWPIN, "PIN" + str(opts.pin_nr))
+ pin = self.get_code(opts.PIN, "PIN" + str(opts.pin_nr))
(data, sw) = self._cmd.lchan.scc.change_chv(
opts.pin_nr, h2b(pin), h2b(new_pin))
self._cmd.poutput("CHV change successful")
disable_chv_parser = argparse.ArgumentParser()
+ disable_chv_parser.add_argument('PIN', nargs='?', type=is_decimal,
+ help='PIN code value. If none given, CSV file will be queried')
disable_chv_parser.add_argument(
'--pin-nr', type=int, default=1, help='PIN Number, 1=PIN1, 2=PIN2 or custom value (decimal)')
- disable_chv_parser.add_argument(
- 'pin_code', type=is_decimal, help='PIN code digits, \"PIN1\" or \"PIN2\" to get PIN code from external data source')
@cmd2.with_argparser(disable_chv_parser)
def do_disable_chv(self, opts):
"""Disable PIN code using specified PIN code"""
- pin = self.get_code(opts.pin_code)
+ pin = self.get_code(opts.PIN, "PIN" + str(opts.pin_nr))
(data, sw) = self._cmd.lchan.scc.disable_chv(opts.pin_nr, h2b(pin))
self._cmd.poutput("CHV disable successful")
enable_chv_parser = argparse.ArgumentParser()
+ enable_chv_parser.add_argument('PIN', nargs='?', type=is_decimal,
+ help='PIN code value. If none given, CSV file will be queried')
enable_chv_parser.add_argument(
'--pin-nr', type=int, default=1, help='PIN Number, 1=PIN1, 2=PIN2 or custom value (decimal)')
- enable_chv_parser.add_argument(
- 'pin_code', type=is_decimal, help='PIN code digits, \"PIN1\" or \"PIN2\" to get PIN code from external data source')
@cmd2.with_argparser(enable_chv_parser)
def do_enable_chv(self, opts):
"""Enable PIN code using specified PIN code"""
- pin = self.get_code(opts.pin_code)
+ pin = self.get_code(opts.PIN, "PIN" + str(opts.pin_nr))
(data, sw) = self._cmd.lchan.scc.enable_chv(opts.pin_nr, h2b(pin))
self._cmd.poutput("CHV enable successful")
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/37838?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I565b56ac608e801c67ca53d337bdec9efa3f3817
Gerrit-Change-Number: 37838
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/37839?usp=email )
Change subject: pySim-shell: prevent opening/closing logical channel 0
......................................................................
pySim-shell: prevent opening/closing logical channel 0
The basic logical channel 0 is always present. It cannot be created or
closed. In case someone tries to create or close it anyway, we should
reject such a command immediately since it might cause unexpected
effects.
Related: OS#6531
Change-Id: I4eebd9f15fadd18e1caeb033fda36c59446fcab8
---
M pySim-shell.py
1 file changed, 4 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/39/37839/1
diff --git a/pySim-shell.py b/pySim-shell.py
index 630d54a..5d99d48 100755
--- a/pySim-shell.py
+++ b/pySim-shell.py
@@ -970,6 +970,8 @@
@cmd2.with_argparser(open_chan_parser)
def do_open_channel(self, opts):
"""Open a logical channel."""
+ if opts.chan_nr == 0:
+ raise RuntimeError("Cannot create (always existing) basic logical lchan 0")
(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
@@ -982,6 +984,8 @@
@cmd2.with_argparser(close_chan_parser)
def do_close_channel(self, opts):
"""Close a logical channel."""
+ if opts.chan_nr == 0:
+ raise RuntimeError("Cannot close (always existing) basic logical lchan 0")
(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
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/37839?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I4eebd9f15fadd18e1caeb033fda36c59446fcab8
Gerrit-Change-Number: 37839
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/37832?usp=email )
Change subject: pySim.filesystem: Permit Path object construction from FID integer list
......................................................................
pySim.filesystem: Permit Path object construction from FID integer list
we so far supported construction of the Path object from a string or
a list of strings. Let's also add the option of constructing it from a
path consisting of a list of integer FID values.
Change-Id: Ia7e9375b3258d1fbfdc892cefba3e3bbe841c550
---
M pySim/filesystem.py
1 file changed, 4 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/32/37832/1
diff --git a/pySim/filesystem.py b/pySim/filesystem.py
index 624619b..805983b 100644
--- a/pySim/filesystem.py
+++ b/pySim/filesystem.py
@@ -1481,10 +1481,12 @@
class Path:
"""Representation of a file-system path."""
- def __init__(self, p: Union[str, List[str]]):
+ def __init__(self, p: Union[str, List[str], List[int]]):
# split if given as single string with slahes
if isinstance(p, str):
p = p.split('/')
+ elif len(p) and isinstance(p[0], int):
+ p = ['%04x' % x for x in p]
# make sure internal representation alwas is uppercase only
self.list = [x.upper() for x in p]
@@ -1514,7 +1516,7 @@
def relative_to_mf(self) -> 'Path':
"""Return a path relative to MF, i.e. without initial explicit MF."""
- if self.list[0] == 'MF':
+ if len(self.list) and self.list[0] in ['MF', '3F00']:
return Path(self.list[1:])
return self
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/37832?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ia7e9375b3258d1fbfdc892cefba3e3bbe841c550
Gerrit-Change-Number: 37832
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/37833?usp=email )
Change subject: saip-tool: Set default log level to INFO (instead of DEBUG)
......................................................................
saip-tool: Set default log level to INFO (instead of DEBUG)
most users don't want to debug the program.
Change-Id: I54ae558cf8d87bf64cc75431cc4edcc694fa9084
---
M contrib/saip-tool.py
1 file changed, 1 insertion(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/33/37833/1
diff --git a/contrib/saip-tool.py b/contrib/saip-tool.py
index d9d33c0..22b913e 100755
--- a/contrib/saip-tool.py
+++ b/contrib/saip-tool.py
@@ -31,7 +31,7 @@
pp = HexBytesPrettyPrinter(indent=4,width=500)
-logging.basicConfig(level=logging.DEBUG)
+logging.basicConfig(level=logging.INFO)
parser = argparse.ArgumentParser(description="""
Utility program to work with eSIM SAIP (SimAlliance Interoperable Profile) files.""")
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/37833?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I54ae558cf8d87bf64cc75431cc4edcc694fa9084
Gerrit-Change-Number: 37833
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/37834?usp=email )
Change subject: pySim.esim.saip.oid: Allow OID instance in prefix_match()
......................................................................
pySim.esim.saip.oid: Allow OID instance in prefix_match()
So far the prefix_match() required a string argument; let's also
permit another OID object to be passed; we internally convert that
to string.
Change-Id: I0feb7782d1813cc46ec78f170eb0fce804aebe3a
---
M pySim/esim/saip/oid.py
1 file changed, 2 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/34/37834/1
diff --git a/pySim/esim/saip/oid.py b/pySim/esim/saip/oid.py
index f201ffe..c7804b1 100644
--- a/pySim/esim/saip/oid.py
+++ b/pySim/esim/saip/oid.py
@@ -77,9 +77,9 @@
if self.cmp(other) > 0:
return True
- def prefix_match(self, oid_str):
+ def prefix_match(self, oid_str: Union[str, OID]):
"""determine if oid_str is equal or below our OID."""
- return oid_str.startswith(str(self))
+ return str(oid_str).startswith(str(self))
class eOID(OID):
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/37834?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I0feb7782d1813cc46ec78f170eb0fce804aebe3a
Gerrit-Change-Number: 37834
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>