dexter has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/28218 )
Change subject: commands: add ".." notation to expand hexstrings
......................................................................
commands: add ".." notation to expand hexstrings
When updating files and records there are sometimes huge portions that
are just 0xff. Mostly this is at the end of a file or record that is not
completely used. Lets add a notation to tell PySim-shell how to fill
those sections.
Change-Id: Iedd7887bf7d706878f4a3beca8dbea456404610b
---
M pySim/commands.py
M pySim/utils.py
2 files changed, 64 insertions(+), 5 deletions(-)
Approvals:
Jenkins Builder: Verified
dexter: Looks good to me, approved
neels: Looks good to me, but someone else must approve
laforge: Looks good to me, but someone else must approve
diff --git a/pySim/commands.py b/pySim/commands.py
index a959851..7b50677 100644
--- a/pySim/commands.py
+++ b/pySim/commands.py
@@ -23,7 +23,7 @@
from construct import *
from pySim.construct import LV
-from pySim.utils import rpad, b2h, h2b, sw_match, bertlv_encode_len, Hexstr, h2i, str_sanitize
+from pySim.utils import rpad, b2h, h2b, sw_match, bertlv_encode_len, Hexstr, h2i, str_sanitize, expand_hex
from pySim.exceptions import SwMatchError
@@ -190,6 +190,10 @@
offset : byte offset in file from which to start writing
verify : Whether or not to verify data after write
"""
+
+ file_len = self.binary_size(ef)
+ data = expand_hex(data, file_len)
+
data_length = len(data) // 2
# Save write cycles by reading+comparing before write
@@ -255,16 +259,17 @@
verify : verify data by re-reading the record
conserve : read record and compare it with data, skip write on match
"""
+
res = self.select_path(ef)
+ rec_length = self.__record_len(res)
+ data = expand_hex(data, rec_length)
if force_len:
# enforce the record length by the actual length of the given data input
rec_length = len(data) // 2
else:
- # determine the record length from the select response of the file and pad
- # the input data with 0xFF if necessary. In cases where the input data
- # exceed we throw an exception.
- rec_length = self.__record_len(res)
+ # make sure the input data is padded to the record length using 0xFF.
+ # In cases where the input data exceed we throw an exception.
if (len(data) // 2 > rec_length):
raise ValueError('Data length exceeds record length (expected max %d, got %d)' % (
rec_length, len(data) // 2))
diff --git a/pySim/utils.py b/pySim/utils.py
index ef770f9..6b8ee37 100644
--- a/pySim/utils.py
+++ b/pySim/utils.py
@@ -1225,6 +1225,60 @@
return int(x, 0)
+def expand_hex(hexstring, length):
+ """Expand a given hexstring to a specified length by replacing "." or ".."
+ with a filler that is derived from the neighboring nibbles respective
+ bytes. Usually this will be the nibble respective byte before "." or
+ "..", execpt when the string begins with "." or "..", then the nibble
+ respective byte after "." or ".." is used.". In case the string cannot
+ be expanded for some reason, the input string is returned unmodified.
+
+ Args:
+ hexstring : hexstring to expand
+ length : desired length of the resulting hexstring.
+ Returns:
+ expanded hexstring
+ """
+
+ # expand digit aligned
+ if hexstring.count(".") == 1:
+ pos = hexstring.index(".")
+ if pos > 0:
+ filler = hexstring[pos - 1]
+ else:
+ filler = hexstring[pos + 1]
+
+ missing = length * 2 - (len(hexstring) - 1)
+ if missing <= 0:
+ return hexstring
+
+ return hexstring.replace(".", filler * missing)
+
+ # expand byte aligned
+ elif hexstring.count("..") == 1:
+ if len(hexstring) % 2:
+ return hexstring
+
+ pos = hexstring.index("..")
+
+ if pos % 2:
+ return hexstring
+
+ if pos > 1:
+ filler = hexstring[pos - 2:pos]
+ else:
+ filler = hexstring[pos + 2:pos+4]
+
+ missing = length * 2 - (len(hexstring) - 2)
+ if missing <= 0:
+ return hexstring
+
+ return hexstring.replace("..", filler * (missing // 2))
+
+ # no change
+ return hexstring
+
+
class JsonEncoder(json.JSONEncoder):
"""Extend the standard library JSONEncoder with support for more types."""
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/28218
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Iedd7887bf7d706878f4a3beca8dbea456404610b
Gerrit-Change-Number: 28218
Gerrit-PatchSet: 2
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de>
Gerrit-MessageType: merged
Attention is currently required from: fixeria.
dexter has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/28185 )
Change subject: ts_102_221: The BTLV IEs FILE SIZE and TOTAL FILE SIZE have a min length
......................................................................
Patch Set 8:
(1 comment)
File pySim/construct.py:
https://gerrit.osmocom.org/c/pysim/+/28185/comment/54bc2199_5d8eab9e
PS5, Line 241: if nbytes < minlen:
> I don't trust this. It now behaves differently.
Done
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/28185
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ief113ce8fe3bcae2c9fb2ff4138df9ccf98d26ff
Gerrit-Change-Number: 28185
Gerrit-PatchSet: 8
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Comment-Date: Fri, 10 Jun 2022 14:25:11 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: fixeria <vyanitskiy(a)sysmocom.de>
Comment-In-Reply-To: dexter <pmaier(a)sysmocom.de>
Gerrit-MessageType: comment
osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ci/+/28265 )
Change subject: repo-install-test: get OBS pub key from proper URL
......................................................................
repo-install-test: get OBS pub key from proper URL
The public OBS key expired on 2022-05-22 and was replaced with a key
that was only shortly valid until 2022-06-08. Shortly after it was
replaced with a key that is valid longer, until 2024-08-02.
On 2022-06-09, one of the osmocom-repo-install tests started failing.
For some reason, the key in the latest/Debian_10 directory was not
updated to the latest one:
https://download.opensuse.org/repositories/network:/osmocom:/latest/Debian_…
Since the key is the same for all of network:osmocom, adjust the
function to download it from a place that the OBS web UI links to when
attempting to download the public GPG key.
I guess the latest/Debian_10/Release.key will get updated once making a
new release and updating the packages in the repository. But sinc
there's a lot of other tasks to do, just use this practical solution for
now.
Change-Id: Idd0fb6e07cba959a36269244b0c7b5c62aaffeee
---
M scripts/repo-install-test/run-inside-docker.sh
1 file changed, 2 insertions(+), 3 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ci refs/changes/65/28265/1
diff --git a/scripts/repo-install-test/run-inside-docker.sh b/scripts/repo-install-test/run-inside-docker.sh
index e44c609..933adef 100755
--- a/scripts/repo-install-test/run-inside-docker.sh
+++ b/scripts/repo-install-test/run-inside-docker.sh
@@ -100,7 +100,6 @@
configure_osmocom_repo_debian() {
local proj="$1"
local obs_repo="download.opensuse.org/repositories/$(proj_with_slashes "$proj")/$DISTRO_OBSDIR/"
- local release_key="/var/cache/apt/${proj}_Release.key"
echo "Configuring Osmocom repository"
@@ -108,9 +107,9 @@
if ! [ -e "$release_key" ]; then
apt-get update
apt install -y wget
- wget -O "$release_key" "https://$obs_repo/Release.key"
+ wget -O /tmp/Release.key "https://build.opensuse.org/projects/network:osmocom/public_key"
fi
- apt-key add "$release_key"
+ apt-key add /tmp/Release.key
echo "deb http://$obs_repo ./" > "/etc/apt/sources.list.d/$proj.list"
apt-get update
--
To view, visit https://gerrit.osmocom.org/c/osmo-ci/+/28265
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-ci
Gerrit-Branch: master
Gerrit-Change-Id: Idd0fb6e07cba959a36269244b0c7b5c62aaffeee
Gerrit-Change-Number: 28265
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith(a)sysmocom.de>
Gerrit-MessageType: newchange
Attention is currently required from: neels.
pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-iuh/+/28264 )
Change subject: move new_transp_layer_addr to public API
......................................................................
Patch Set 1:
(1 comment)
Patchset:
PS1:
No Ic9bc30f322c4c6c6e82462d1da50cb15b336c63a in gerrit?
--
To view, visit https://gerrit.osmocom.org/c/osmo-iuh/+/28264
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-iuh
Gerrit-Branch: master
Gerrit-Change-Id: Icc61620b4d11c4ba6823b40abc7c300f0533c058
Gerrit-Change-Number: 28264
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Comment-Date: Fri, 10 Jun 2022 12:35:27 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
Attention is currently required from: laforge.
k_o_ has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/28248 )
Change subject: APDU parsing support for GlobalPlatform
......................................................................
Patch Set 1:
(1 comment)
Patchset:
PS1:
> quite interesting. […]
I think it is related the the Android carrier privileges using the GlobalPlatform access rules which is reusing commands, here STORE DATA from the GlobalPlatform card specification. In general all MNOs are free to install whatever applet is necessary for their business purposes, e.g. QoS applets, Multi IMSI applets, crypto applets, payment applets. These applets can use an arbitrary APDU command set, i.e. to be in general useful all APDUs have to be supported by the simtrace board. Would it be possible to generalize the APDU case code to support any ISO command or is this not possible because the whole command is not available?
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/28248
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Ib734fc852e7b63b9efdc414adccbd796a572eb55
Gerrit-Change-Number: 28248
Gerrit-PatchSet: 1
Gerrit-Owner: k_o_ <wider.stand(a)gmx.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Comment-Date: Fri, 10 Jun 2022 12:11:10 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: comment
pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/28258 )
Change subject: cbsp: Add enum and value string for Cause
......................................................................
Patch Set 2: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/28258
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I35592bb4fff2e7b442d0e0cd537b66687862baf2
Gerrit-Change-Number: 28258
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-Comment-Date: Fri, 10 Jun 2022 11:54:51 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment