laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/41676?usp=email )
Change subject: unittests/test_files: Pass to-be-encoded length to encoder functions
......................................................................
unittests/test_files: Pass to-be-encoded length to encoder functions
Some of the encoders can only generate valid output if they are told
the expected output size. This is due to variable-length fields that
depend on the size of the total record (or file). Let's always pass
the expected length to the encoder methods.
Change-Id: I88f957e49b0c88a121a266d3582e79822fa0e214
---
M tests/unittests/test_files.py
1 file changed, 5 insertions(+), 5 deletions(-)
Approvals:
laforge: Looks good to me, approved
dexter: Looks good to me, but someone else must approve
Jenkins Builder: Verified
fixeria: Looks good to me, but someone else must approve
diff --git a/tests/unittests/test_files.py b/tests/unittests/test_files.py
index ab70771..5bbbddd 100755
--- a/tests/unittests/test_files.py
+++ b/tests/unittests/test_files.py
@@ -96,7 +96,7 @@
inst = c()
encoded, rec_num, decoded = self._parse_t(t)
logging.debug("Testing encode of %s", name)
- re_enc = inst.encode_record_hex(decoded, rec_num)
+ re_enc = inst.encode_record_hex(decoded, rec_num, len(encoded)//2)
self.assertEqual(encoded.upper(), re_enc.upper())
def test_de_encode_record(self):
@@ -122,7 +122,7 @@
self.assertEqual(decoded, re_dec)
# re-encode the decoded data
logging.debug("Testing re-encode of %s", name)
- re_enc = inst.encode_record_hex(re_dec, rec_num)
+ re_enc = inst.encode_record_hex(re_dec, rec_num, len(encoded)//2)
self.assertEqual(encoded.upper(), re_enc.upper())
if hasattr(c, '_test_no_pad') and c._test_no_pad:
continue
@@ -196,7 +196,7 @@
self.assertEqual(decoded, re_dec)
# re-encode the decoded data
logging.debug("Testing re-encode of %s", name)
- re_enc = inst.encode_record_hex(re_dec)
+ re_enc = inst.encode_record_hex(re_dec, len(encoded)//2)
self.assertEqual(encoded.upper(), re_enc.upper())
# there's no point in testing padded input, as TransRecEF have a fixed record
# size and we cannot ever receive more input data than that size.
@@ -256,7 +256,7 @@
encoded = t[0]
decoded = t[1]
logging.debug("Testing encode of %s", name)
- re_enc = inst.encode_hex(decoded)
+ re_enc = inst.encode_hex(decoded, len(encoded)//2)
self.assertEqual(encoded, re_enc)
def test_de_encode_file(self):
@@ -280,7 +280,7 @@
self.assertEqual(decoded, re_dec)
logging.debug("Testing re-encode of %s", name)
re_dec = inst.decode_hex(encoded)
- re_enc = inst.encode_hex(re_dec)
+ re_enc = inst.encode_hex(re_dec, len(encoded)//2)
self.assertEqual(encoded.upper(), re_enc.upper())
if hasattr(c, '_test_no_pad') and c._test_no_pad:
continue
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/41676?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I88f957e49b0c88a121a266d3582e79822fa0e214
Gerrit-Change-Number: 41676
Gerrit-PatchSet: 3
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/41675?usp=email )
Change subject: unittest/test_files.TransparentEF_Test: Actually test encoder
......................................................................
unittest/test_files.TransparentEF_Test: Actually test encoder
In the test_encode_file() method, we should actually test the encoder,
and not the decoder. I suppose this was a copy+paste mistake at some
point? In the LinearFixedEF_Test.test_encoder_record we were already
testing the encoder. Just TransparentEF_Test got it wrong...
Change-Id: Id23305a78ab9acd2e006f2b26b72408795844d23
---
M tests/unittests/test_files.py
1 file changed, 2 insertions(+), 2 deletions(-)
Approvals:
fixeria: Looks good to me, but someone else must approve
laforge: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/tests/unittests/test_files.py b/tests/unittests/test_files.py
index a3ccf06..ab70771 100755
--- a/tests/unittests/test_files.py
+++ b/tests/unittests/test_files.py
@@ -256,8 +256,8 @@
encoded = t[0]
decoded = t[1]
logging.debug("Testing encode of %s", name)
- re_dec = inst.decode_hex(encoded)
- self.assertEqual(decoded, re_dec)
+ re_enc = inst.encode_hex(decoded)
+ self.assertEqual(encoded, re_enc)
def test_de_encode_file(self):
"""Test the decoder and encoder for a transparent EF. Performs first a decoder
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/41675?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Id23305a78ab9acd2e006f2b26b72408795844d23
Gerrit-Change-Number: 41675
Gerrit-PatchSet: 3
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/41712?usp=email )
Change subject: pyshark_gsmtap: Adjust display filter for some wireshark versions
......................................................................
pyshark_gsmtap: Adjust display filter for some wireshark versions
On my debian unstable system with wireshark 4.6.2-3, the pyshark_gsmtap
APDU source misses to report any ATRs, as those are not part of what's
reported with the 'gsm_sim' display filter. This is due to
wireshark.git commit bcd82e2370d18e20983b378d494964d89c191cef first part
of the 4.6.0 release, which splits the ATR dissection into a separate
sub-dissector.
We cannot use the seemingly logical 'gsmtap.type == 4' instead, as old
wireshark simply bypasses any output for the gsmtap header if the SIM
sub-dissector is used.
Hence, 'gsm_sim || iso7816.atr' is something compatible with older and
newer wireshark versions.
Change-Id: I53c1c8ed58a82c37cd4be4af3890af21da839e86
---
M pySim/apdu_source/pyshark_gsmtap.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
laforge: Looks good to me, approved
Jenkins Builder: Verified
fixeria: Looks good to me, but someone else must approve
diff --git a/pySim/apdu_source/pyshark_gsmtap.py b/pySim/apdu_source/pyshark_gsmtap.py
index e8f5d18..13562d9 100644
--- a/pySim/apdu_source/pyshark_gsmtap.py
+++ b/pySim/apdu_source/pyshark_gsmtap.py
@@ -84,5 +84,5 @@
Args:
pcap_filename: File name of the pcap file to be opened
"""
- pyshark_inst = pyshark.FileCapture(pcap_filename, display_filter='gsm_sim', use_json=True, keep_packets=False)
+ pyshark_inst = pyshark.FileCapture(pcap_filename, display_filter='gsm_sim || iso7816.atr', use_json=True, keep_packets=False)
super().__init__(pyshark_inst)
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/41712?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I53c1c8ed58a82c37cd4be4af3890af21da839e86
Gerrit-Change-Number: 41712
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-CC: dexter <pmaier(a)sysmocom.de>
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/41690?usp=email )
Change subject: pySim.esim.saip.personalization: Support Milenage customization
......................................................................
pySim.esim.saip.personalization: Support Milenage customization
Milenage offers the capability for operators to modify the r1-r5
rotation constants as well as the c1-c5 xor-ing constants; let's
add ConfigurableParameters for that.
Change-Id: I397df6c0c708a8061e4adc0fde03a3f746bcb5b6
Related: SYS#7787
---
M pySim/esim/saip/personalization.py
1 file changed, 34 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/esim/saip/personalization.py b/pySim/esim/saip/personalization.py
index 053ea0c..71f115d 100644
--- a/pySim/esim/saip/personalization.py
+++ b/pySim/esim/saip/personalization.py
@@ -322,3 +322,37 @@
if self.input_value not in [1, 2, 3]:
raise ValueError('Invalid algorithmID %s' % (self.input_value))
self.value = self.input_value
+class MilenageRotationConstants(AlgoConfig, key='rotationConstants'):
+ """rotation constants r1,r2,r3,r4,r5 of Milenage, Range 0..127. See 3GPP TS 35.206 Sections 2.3 + 5.3.
+ Provided as octet-string concatenation of all 5 constants. Expects a bytes-like object of length 5, with
+ each byte in the range of 0..127. The default value by 3GPP is '4000204060' (hex notation)"""
+ def validate(self):
+ super().validate()
+ if len(self.input_value) != 5:
+ raise ValueError('Length of value must be 5 octets')
+ for r in self.input_value:
+ if r > 127:
+ raise ValueError('r values must be between 0 and 127')
+class MilenageXoringConstants(AlgoConfig, key='xoringConstants'):
+ """XOR-ing constants c1,c2,c3,c4,c5 of Milenage, 128bit each. See 3GPP TS 35.206 Sections 2.3 + 5.3.
+ Provided as octet-string concatenation of all 5 constants. The default value by 3GPP is the concetenation
+ of:
+ 00000000000000000000000000000000
+ 00000000000000000000000000000001
+ 00000000000000000000000000000002
+ 00000000000000000000000000000004
+ 00000000000000000000000000000008
+ """
+ def validate(self):
+ super().validate()
+ if len(self.input_value) != 80:
+ raise ValueError('Length of value must be 80 octets')
+class TuakNumberOfKeccak(AlgoConfig, key='numberOfKeccak'):
+ """Number of iterations of Keccak-f[1600] permuitation as recomended by Section 7.2 of 3GPP TS 35.231.
+ The default value by 3GPP is 1."""
+ def validate(self):
+ if not isinstance(self.input_value, int):
+ raise ValueError('Value must be an integer')
+ if self.input_value < 1 or self.input_value > 255:
+ raise ValueError('Value must be an integer between 1 and 255')
+ self.value = self.input_value
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/41690?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I397df6c0c708a8061e4adc0fde03a3f746bcb5b6
Gerrit-Change-Number: 41690
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de>