Attention is currently required from: dexter.
laforge has posted comments on this change by dexter. ( https://gerrit.osmocom.org/c/pysim/+/39199?usp=email )
Change subject: global_platform: add new command "install_cap"
......................................................................
Patch Set 3: Code-Review+1
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/39199?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: I6cbd37f0fad5579b20e83c27349bd5acc129e6d0
Gerrit-Change-Number: 39199
Gerrit-PatchSet: 3
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: dexter <pmaier(a)sysmocom.de>
Gerrit-Comment-Date: Fri, 03 Jan 2025 11:13:17 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Attention is currently required from: dexter.
laforge has posted comments on this change by laforge. ( https://gerrit.osmocom.org/c/pysim/+/37454?usp=email )
Change subject: global_platform: LOAD and INSTALL [for load] support
......................................................................
Patch Set 4: Code-Review+1
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/37454?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: I924aaeecbb3a72bdb65eefbff6135e4e9570579e
Gerrit-Change-Number: 37454
Gerrit-PatchSet: 4
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: dexter <pmaier(a)sysmocom.de>
Gerrit-Comment-Date: Fri, 03 Jan 2025 11:12:49 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Attention is currently required from: dexter.
laforge has posted comments on this change by dexter. ( https://gerrit.osmocom.org/c/pysim/+/39225?usp=email )
Change subject: global_platform: fix usage of the Key Version Number (kvn)
......................................................................
Patch Set 2:
(1 comment)
Commit Message:
https://gerrit.osmocom.org/c/pysim/+/39225/comment/71ff0037_95300485?usp=em… :
PS2, Line 19: sjs1
SJS is upper case in the product name.
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/39225?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: I42be2438c7f199b238f2ec7a9434cec5393210a7
Gerrit-Change-Number: 39225
Gerrit-PatchSet: 2
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: dexter <pmaier(a)sysmocom.de>
Gerrit-Comment-Date: Fri, 03 Jan 2025 11:12:16 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Attention is currently required from: dexter.
laforge has posted comments on this change by dexter. ( https://gerrit.osmocom.org/c/pysim/+/39225?usp=email )
Change subject: global_platform: fix usage of the Key Version Number (kvn)
......................................................................
Patch Set 2: Code-Review+1
(1 comment)
File pySim/global_platform/scp.py:
https://gerrit.osmocom.org/c/pysim/+/39225/comment/e567b425_4448729c?usp=em… :
PS2, Line 230: kvn_ranges = [[0x00, 0x00], [0x01, 0x01], [0x20, 0x2f], [0x70, 0x70]]
> This is something I do not fully understand, why do we have a hard restriction on the KVN range? Is […]
AFACT, the spec says [somewhere] that SCP02 uses 2x and SCP03 uses 3x - we just have some products that support other KVN (the 7x is a key that's used for both SCP80 and SCP02, AFAIR).
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/39225?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: I42be2438c7f199b238f2ec7a9434cec5393210a7
Gerrit-Change-Number: 39225
Gerrit-PatchSet: 2
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: dexter <pmaier(a)sysmocom.de>
Gerrit-Comment-Date: Fri, 03 Jan 2025 11:11:51 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: dexter <pmaier(a)sysmocom.de>
Attention is currently required from: dexter.
laforge has posted comments on this change by dexter. ( https://gerrit.osmocom.org/c/pysim/+/39198?usp=email )
Change subject: javacard: add parser for JAVA-card CAP file format
......................................................................
Patch Set 2:
(4 comments)
File pySim/javacard.py:
https://gerrit.osmocom.org/c/pysim/+/39198/comment/d23a8c26_74996a17?usp=em… :
PS2, Line 47: __component
AFAICT, you are basically declaring a _class_ variable here. It will be identical across all the instances of the class. However, it seems more like you're storing per-instance state in it?
https://gerrit.osmocom.org/c/pysim/+/39198/comment/0a1e56aa_74c4dc93?usp=em… :
PS2, Line 99:
I think a generic implementation of a CAP file support shouldn't return the loadfile as hex-string but as bytes. The fact that whatever downstream apdu user we have may need hexstr should not have implications on a generic CAP file parser. Also, the function signature is missing the declaration of the return type ("-> Hexstr" in the current one, "-> bytes" in my proposal).
https://gerrit.osmocom.org/c/pysim/+/39198/comment/336b0932_b5d57075?usp=em… :
PS2, Line 118: def get_loadfile_aid(self):
missing declaration of return type (-> Hexstr)
https://gerrit.osmocom.org/c/pysim/+/39198/comment/e63bc638_b2b51e22?usp=em… :
PS2, Line 127: def get_applet_aid(self, index:int = 0):
missing declaration of return type (-> Hexstr)
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/39198?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: I581483ccb9d8a254fcecc995fec3c811c5cf38eb
Gerrit-Change-Number: 39198
Gerrit-PatchSet: 2
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: laforge <laforge(a)osmocom.org>
Gerrit-Attention: dexter <pmaier(a)sysmocom.de>
Gerrit-Comment-Date: Fri, 03 Jan 2025 11:09:46 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Attention is currently required from: laforge.
dexter has posted comments on this change by dexter. ( https://gerrit.osmocom.org/c/pysim/+/39225?usp=email )
Change subject: global_platform: fix usage of the Key Version Number (kvn)
......................................................................
Patch Set 2:
(1 comment)
File pySim/global_platform/scp.py:
https://gerrit.osmocom.org/c/pysim/+/39225/comment/f71be127_ae786cb1?usp=em… :
PS2, Line 230: kvn_ranges = [[0x00, 0x00], [0x01, 0x01], [0x20, 0x2f], [0x70, 0x70]]
This is something I do not fully understand, why do we have a hard restriction on the KVN range? Is there any spec that explicitly restricts the ranges? Apparantly it is not uncommon to use a custom range/kvn (we do it). Maybe we should only print a warning and not throw an exception when the range is violated?
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/39225?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: I42be2438c7f199b238f2ec7a9434cec5393210a7
Gerrit-Change-Number: 39225
Gerrit-PatchSet: 2
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Comment-Date: Fri, 03 Jan 2025 10:30:35 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
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/+/39198?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: javacard: add parser for JAVA-card CAP file format
......................................................................
javacard: add parser for JAVA-card CAP file format
To install JAVA-card applets we need to be able to extract the executeable
loadfile and the AIDs of the applet and the loadfile. This patch adds the
parser and related unittests.
Related: OS#6679
Change-Id: I581483ccb9d8a254fcecc995fec3c811c5cf38eb
---
M pySim/javacard.py
A tests/unittests/test_javacard.cap
A tests/unittests/test_javacard.py
3 files changed, 139 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/98/39198/2
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/39198?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: I581483ccb9d8a254fcecc995fec3c811c5cf38eb
Gerrit-Change-Number: 39198
Gerrit-PatchSet: 2
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: laforge <laforge(a)osmocom.org>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Attention is currently required from: dexter, laforge.
Hello Jenkins Builder, laforge,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/pysim/+/39199?usp=email
to look at the new patch set (#2).
The following approvals got outdated and were removed:
Code-Review+1 by laforge, Verified-1 by Jenkins Builder
Change subject: global_platform: add new command "install_cap"
......................................................................
global_platform: add new command "install_cap"
Installing JAVA-card applets from a CAP file is a multi step process, which is
difficult when done manually. Fortunately it is easy to automate the process,
so let's add a dedicated command for that.
Change-Id: I6cbd37f0fad5579b20e83c27349bd5acc129e6d0
Related: OS#6679
---
M pySim/global_platform/__init__.py
A pySim/global_platform/install_param.py
M tests/unittests/test_globalplatform.py
3 files changed, 131 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/99/39199/2
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/39199?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: I6cbd37f0fad5579b20e83c27349bd5acc129e6d0
Gerrit-Change-Number: 39199
Gerrit-PatchSet: 2
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Attention: dexter <pmaier(a)sysmocom.de>
Attention is currently required from: laforge.
dexter has posted comments on this change by dexter. ( https://gerrit.osmocom.org/c/pysim/+/39198?usp=email )
Change subject: javacard: add parser for JAVA-card CAP file format
......................................................................
Patch Set 2:
(4 comments)
File pySim/javacard.py:
https://gerrit.osmocom.org/c/pysim/+/39198/comment/04b83e25_fb799e51?usp=em… :
PS1, Line 45:
> can we somehow check easily if a file is extended and in that case print a meaningful error message?
I think we could just check if there are any .capx components in the file. When this is the case, we can throw an exception.
https://gerrit.osmocom.org/c/pysim/+/39198/comment/3b0be06c_9ebd2329?usp=em… :
PS1, Line 47: __component_header = None
: __component_directory = None
: __component_applet = None #optional
: __component_import = None
: __component_constantPool = None
: __component_class = None
: __component_method = None
: __component_staticField = None
: __component_referenceLocation = None
: __component_export = None #optional
: __component_descriptor = None
: __component_debug = None #optional, since CAP format 2.2
> doesn't it make sense to use a dict here, indexed by the component type? Just a thought.
I think that is a great idea. Then we also won't need setattr()
https://gerrit.osmocom.org/c/pysim/+/39198/comment/86a4712a_7a4a6362?usp=em… :
PS1, Line 86: if filename.lower().endswith('header.cap'):
: self.__component_header = cap.read(filename)
: elif filename.lower().endswith('directory.cap'):
: self.__component_directory = cap.read(filename)
: elif filename.lower().endswith('applet.cap'):
: self.__component_applet = cap.read(filename)
: elif filename.lower().endswith('import.cap'):
: self.__component_import = cap.read(filename)
: elif filename.lower().endswith('constantpool.cap'):
: self.__component_constantPool = cap.read(filename)
: elif filename.lower().endswith('class.cap'):
: self.__component_class = cap.read(filename)
: elif filename.lower().endswith('method.cap'):
: self.__component_method = cap.read(filename)
: elif filename.lower().endswith('staticfield.cap'):
: self.__component_staticField = cap.read(filename)
: elif filename.lower().endswith('reflocation.cap'):
: self.__component_referenceLocation = cap.read(filename)
: elif filename.lower().endswith('export.cap'):
: self.__component_export = cap.read(filename)
: elif filename.lower().endswith('descriptor.cap'):
: self.__component_descriptor = cap.read(filename)
: elif filename.lower().endswith('debug.cap'):
: self.__component_debug = cap.read(filename)
> IMHO, this looks like a lot of copy+paste / typing work in something that can be implemented more el […]
Done
https://gerrit.osmocom.org/c/pysim/+/39198/comment/4a1825c4_8acf2da1?usp=em… :
PS1, Line 113: if self.__component_header is None:
: raise ValueError("invalid cap file, COMPONENT_Header missing!")
: if self.__component_directory is None:
: raise ValueError("invalid cap file, COMPONENT_Directory missing!")
: if self.__component_import is None:
: raise ValueError("invalid cap file, COMPONENT_Import missing!")
: if self.__component_constantPool is None:
: raise ValueError("invalid cap file, COMPONENT_ConstantPool missing!")
: if self.__component_class is None:
: raise ValueError("invalid cap file, COMPONENT_Class missing!")
: if self.__component_method is None:
: raise ValueError("invalid cap file, COMPONENT_Method missing!")
: if self.__component_staticField is None:
: raise ValueError("invalid cap file, COMPONENT_StaticField missing!")
: if self.__component_referenceLocation is None:
: raise ValueError("invalid cap file, COMPONENT_ReferenceLocation missing!")
: if self.__component_descriptor is None:
: raise ValueError("invalid cap file, COMPONENT_Descriptor missing!")
> likewise here, that's a lot of code to write. Why not simply have a […]
Done
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/39198?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: I581483ccb9d8a254fcecc995fec3c811c5cf38eb
Gerrit-Change-Number: 39198
Gerrit-PatchSet: 2
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: laforge <laforge(a)osmocom.org>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Comment-Date: Fri, 03 Jan 2025 09:45:18 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: laforge <laforge(a)osmocom.org>
dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/39225?usp=email )
Change subject: global_platform: fix usage of the Key Version Number (kvn)
......................................................................
global_platform: fix usage of the Key Version Number (kvn)
The kvn parameter is used to select a keyset when establishin a secure channel.
At the moment this is a mandatory parameter and it must be within a certain
range.
However GPC_SPE_034 explicitly defines a reserved kvn value 0, that always
refers to the first available key. That effectively makes it an optional
parameter and the commandline interface should have the --key-ver parameter
as an optional parameter.
The ranges also have to be extended to allow 0 as kvn value. We also have to
put a range to support the sysmoUSIM-sjs1, which uses kvn value 1, which is
a non standard value.
Related: OS#6679
Change-Id: I42be2438c7f199b238f2ec7a9434cec5393210a7
---
M pySim/global_platform/__init__.py
M pySim/global_platform/scp.py
2 files changed, 8 insertions(+), 4 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/25/39225/1
diff --git a/pySim/global_platform/__init__.py b/pySim/global_platform/__init__.py
index 023e7f9..04d254e 100644
--- a/pySim/global_platform/__init__.py
+++ b/pySim/global_platform/__init__.py
@@ -908,7 +908,7 @@
self._cmd.poutput("done.")
est_scp02_parser = argparse.ArgumentParser()
- est_scp02_parser.add_argument('--key-ver', type=auto_uint8, required=True, help='Key Version Number (KVN)')
+ est_scp02_parser.add_argument('--key-ver', type=auto_uint8, default=0, help='Key Version Number (KVN)')
est_scp02_parser.add_argument('--host-challenge', type=is_hexstr,
help='Hard-code the host challenge; default: random')
est_scp02_parser.add_argument('--security-level', type=auto_uint8, default=0x01,
@@ -1013,7 +1013,9 @@
class GpCardKeyset:
"""A single set of GlobalPlatform card keys and the associated KVN."""
def __init__(self, kvn: int, enc: bytes, mac: bytes, dek: bytes):
- assert 0 < kvn < 256
+ # The Key Version Number is an 8 bit integer number, where 0 refers to the first available key,
+ # see also: GPC_SPE_034, section E.5.1.3
+ assert 0 <= kvn < 256
assert len(enc) == len(mac) == len(dek)
self.kvn = kvn
self.enc = enc
diff --git a/pySim/global_platform/scp.py b/pySim/global_platform/scp.py
index 3fe7601..1540503 100644
--- a/pySim/global_platform/scp.py
+++ b/pySim/global_platform/scp.py
@@ -224,8 +224,10 @@
constr_iur = Struct('key_div_data'/Bytes(10), 'key_ver'/Int8ub, Const(b'\x02'),
'seq_counter'/Int16ub, 'card_challenge'/Bytes(6), 'card_cryptogram'/Bytes(8))
- # The 0x70 is a non-spec special-case of sysmoISIM-SJA2/SJA5 and possibly more sysmocom products
- kvn_ranges = [[0x20, 0x2f], [0x70, 0x70]]
+ # Key Version Number 0x00 refers to the first available key, see also: GPC_SPE_034, section E.5.1.3
+ # Key Version Number 0x70 is a non-spec special-case of sysmoISIM-SJA2/SJA5 and possibly more sysmocom products
+ # Key Version Number 0x01 is a non-spec special-case of sysmoUSIM-SJS1
+ kvn_ranges = [[0x00, 0x00], [0x01, 0x01], [0x20, 0x2f], [0x70, 0x70]]
def __init__(self, *args, **kwargs):
self.overhead = 8
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/39225?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: I42be2438c7f199b238f2ec7a9434cec5393210a7
Gerrit-Change-Number: 39225
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>