laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-pcu/+/33118 )
Change subject: pcu_utils.h: Replace software based bitcount impl with gcc builtin
......................................................................
pcu_utils.h: Replace software based bitcount impl with gcc builtin
The cast for different types it's not really needed, simply use the
unsigned long long version to make sure we don't drop 1s, in any case
__builtin_popcountll() will be quicker than what we used to have.
Change-Id: I80ae72d34d53564fc3da1601ee48c8b2ffe79735
---
M src/pcu_utils.h
1 file changed, 15 insertions(+), 9 deletions(-)
Approvals:
laforge: Looks good to me, approved
fixeria: Looks good to me, but someone else must approve
Jenkins Builder: Verified
diff --git a/src/pcu_utils.h b/src/pcu_utils.h
index a6beab0..0be37e9 100644
--- a/src/pcu_utils.h
+++ b/src/pcu_utils.h
@@ -67,17 +67,10 @@
return fn % GSM_MAX_FN;
}
-#ifdef __cplusplus
-template <typename T>
-inline unsigned int pcu_bitcount(T x)
+inline unsigned int pcu_bitcount(unsigned long long x)
{
- unsigned int count = 0;
- for (count = 0; x; count += 1)
- x &= x - 1;
-
- return count;
+ return __builtin_popcountll(x);
}
-#endif
static inline uint8_t pcu_lsb(uint8_t x)
{
--
To view, visit https://gerrit.osmocom.org/c/osmo-pcu/+/33118
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: I80ae72d34d53564fc3da1601ee48c8b2ffe79735
Gerrit-Change-Number: 33118
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Hoernchen <ewild(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: merged
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/33116 )
Change subject: OTA: Fix padding of AES CMAC
......................................................................
OTA: Fix padding of AES CMAC
When using AES CMAC for authentication of OTA messages, we must not pad
the user data before calling the CMAC function. This is unlike the DES
MAC, where padding to the DES block size is mandatory.
This bug was discovered when trying to talk OTA with AES to a
sysmoISIM-SJA5. This patch makes the OTA AES interoperate with the
card. Also, with this patch the cryptographic results of pySim/ota.py
are identical to those of the java code
org.opentelecoms.gsm0348.impl.crypto.CipheringManager
Change-Id: I4b40b5857f95ccb21c35795abe7a1995e368bac3
---
M pySim/ota.py
1 file changed, 21 insertions(+), 2 deletions(-)
Approvals:
fixeria: Looks good to me, but someone else must approve
dexter: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/pySim/ota.py b/pySim/ota.py
index 80c823e..83303a6 100644
--- a/pySim/ota.py
+++ b/pySim/ota.py
@@ -1,6 +1,6 @@
"""Code related to SIM/UICC OTA according to TS 102 225 + TS 31.115."""
-# (C) 2021-2022 by Harald Welte <laforge(a)osmocom.org>
+# (C) 2021-2023 by Harald Welte <laforge(a)osmocom.org>
#
# 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
@@ -305,7 +305,7 @@
class OtaAlgoAuthAES(OtaAlgoAuth):
name = 'AES'
enum_name = 'aes_cmac'
- blocksize = 16 # TODO: is this needed?
+ blocksize = 1 # AES CMAC doesn't need any padding by us
def _sign(self, data:bytes) -> bytes:
cmac = CMAC.new(self.otak.kid, ciphermod=AES, mac_len=8)
cmac.update(data)
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/33116
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I4b40b5857f95ccb21c35795abe7a1995e368bac3
Gerrit-Change-Number: 33116
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-MessageType: merged
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/33065 )
Change subject: ts_31_102: EF_SUPI_NAI: Decode/Encode GLI+GCI as UTF-8 strings
......................................................................
ts_31_102: EF_SUPI_NAI: Decode/Encode GLI+GCI as UTF-8 strings
According to TS 23.003 Section 28.15 and 28.16 both GLI and GCI
are NAI as defined in IETF RFC 7542, which in turn specifies they
are encoded in UTF-8.
Change-Id: I0a82bd0d0a2badd7bc4a1f8de2c3e3c144ee5b12
---
M pySim/ts_31_102.py
1 file changed, 15 insertions(+), 2 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/ts_31_102.py b/pySim/ts_31_102.py
index 73c5fd5..14e7cae 100644
--- a/pySim/ts_31_102.py
+++ b/pySim/ts_31_102.py
@@ -1066,11 +1066,11 @@
class GlobalLineIdentifier(TLV_IE, tag=0x81):
# TS 23.003 clause 28.16.2
- pass
+ _construct = GreedyString("utf8")
class GlobalCableIdentifier(TLV_IE, tag=0x82):
# TS 23.003 clause 28.15.2
- pass
+ _construct = GreedyString("utf8")
class NAI_TLV_Collection(TLV_IE_Collection,
nested=[NetworkSpecificIdentifier, GlobalLineIdentifier, GlobalCableIdentifier]):
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/33065
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I0a82bd0d0a2badd7bc4a1f8de2c3e3c144ee5b12
Gerrit-Change-Number: 33065
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>
Gerrit-MessageType: merged
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/33064 )
Change subject: ts_31_102: Add decoder/encoder for DF.5GS/EF.Routing_Indicator
......................................................................
ts_31_102: Add decoder/encoder for DF.5GS/EF.Routing_Indicator
This file is rather important for 5G SA operation, so we should have
a proper encoder/decoder in place.
Change-Id: I1b37fdfc2807976880b2cafb61951f08eebeb344
---
M docs/suci-tutorial.rst
M pySim/ts_31_102.py
2 files changed, 24 insertions(+), 5 deletions(-)
Approvals:
laforge: Looks good to me, approved
fixeria: Looks good to me, but someone else must approve
Jenkins Builder: Verified
diff --git a/docs/suci-tutorial.rst b/docs/suci-tutorial.rst
index 00c060f..fc6e911 100644
--- a/docs/suci-tutorial.rst
+++ b/docs/suci-tutorial.rst
@@ -132,10 +132,8 @@
::
- pySIM-shell (MF/ADF.USIM/DF.5GS/EF.Routing_Indicator)> update_binary 0071ffff
+ pySIM-shell (MF/ADF.USIM/DF.5GS/EF.Routing_Indicator)> update_binary 17ffffff
-(the encoding might be different, see `this
-comment <https://gist.github.com/mrlnc/01d6300f1904f154d969ff205136b753?permalink_co…>`__)
You can also set the routing indicator to **0x0**, which is *valid* and
means “routing indicator not specified”, leaving it to the modem.
diff --git a/pySim/ts_31_102.py b/pySim/ts_31_102.py
index 76f1358..73c5fd5 100644
--- a/pySim/ts_31_102.py
+++ b/pySim/ts_31_102.py
@@ -1080,6 +1080,16 @@
super().__init__(fid, sfid=sfid, name=name, desc=desc, **kwargs)
self._tlv = EF_SUPI_NAI.NAI_TLV_Collection
+# TS 31.102 Section 4.4.11.11
+class EF_Routing_Indicator(TransparentEF):
+ def __init__(self, fid='4f0a', sfid=0x0a, name='EF.Routing_Indicator', desc='Routing Indicator', **kwargs):
+ super().__init__(fid, sfid=sfid, name=name, desc=desc, **kwargs)
+ # 3GPP TS 24.501 Table 9.11.3.4.1:
+ # Routing Indicator shall consist of 1 to 4 digits. The coding of this field is the
+ # responsibility of home network operator but BCD coding shall be used. If a network
+ # operator decides to assign less than 4 digits to Routing Indicator, the remaining digits
+ # shall be coded as "1111" to fill the 4 digits coding of Routing Indicator
+ self._construct = Struct('routing_indicator'/BcdAdapter(Rpad(Bytes(2))), 'rfu'/HexAdapter(Bytes(2)))
# TS 31.102 Section 4.4.11.13
class EF_TN3GPPSNN(TransparentEF):
@@ -1434,8 +1444,7 @@
EF_SUCI_Calc_Info(service=124),
EF_OPL5G(service=129),
EF_SUPI_NAI(service=130),
- TransparentEF('4F0A', 0x0a, 'EF.Routing_Indicator',
- 'Routing Indicator', size=(4, 4), service=124),
+ EF_Routing_Indicator(service=124),
TransparentEF('4F0B', 0x0b, 'EF.URSP',
'UE Route Selector Policies per PLMN', service=132),
EF_TN3GPPSNN(service=133),
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/33064
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I1b37fdfc2807976880b2cafb61951f08eebeb344
Gerrit-Change-Number: 33064
Gerrit-PatchSet: 4
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: merlinchlosta <merlin.chlosta(a)rub.de>
Gerrit-MessageType: merged