lists.osmocom.org
Sign In Sign Up
Manage this list Sign In Sign Up

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

gerrit-log

Thread Start a new thread
Download
Threads by month
  • ----- 2026 -----
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2025 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2022 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
gerrit-log@lists.osmocom.org

February 2024

  • 1 participants
  • 1748 discussions
[M] Change in libosmocore[master]: osmo_io: Use poll/select to notify socket connection at osmo_io_uring.c
by daniel 22 Feb '24

22 Feb '24
Attention is currently required from: jolly, laforge, pespin. daniel has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/35910?usp=email ) Change subject: osmo_io: Use poll/select to notify socket connection at osmo_io_uring.c ...................................................................... Patch Set 5: Code-Review+1 (1 comment) File src/core/osmo_io_uring.c: https://gerrit.osmocom.org/c/libosmocore/+/35910/comment/b21038e3_d02b8dd3 PS5, Line 436: LOGP(DLIO, LOGL_DEBUG, "%s: %s\n", iofd->name, __func__); Use LOGPIO(iofd, ...) to log info about an iofd -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35910?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I4eca9ea72beb0d6ea4d44cce81ed620033f07270 Gerrit-Change-Number: 35910 Gerrit-PatchSet: 5 Gerrit-Owner: jolly <andreas(a)eversberg.eu> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-CC: pespin <pespin(a)sysmocom.de> Gerrit-Attention: jolly <andreas(a)eversberg.eu> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Thu, 22 Feb 2024 10:47:28 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[M] Change in libosmocore[master]: osmo_io: Move notify_connected function to backend
by daniel 22 Feb '24

22 Feb '24
Attention is currently required from: jolly, pespin. daniel has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/35909?usp=email ) Change subject: osmo_io: Move notify_connected function to backend ...................................................................... Patch Set 3: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35909?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I905ec85210570aff8addadfc9603335d04eb057a Gerrit-Change-Number: 35909 Gerrit-PatchSet: 3 Gerrit-Owner: jolly <andreas(a)eversberg.eu> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: jolly <andreas(a)eversberg.eu> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Thu, 22 Feb 2024 10:40:28 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[S] Change in pysim[master]: saip.personalization: automatically compute class 'name' attribute
by laforge 22 Feb '24

22 Feb '24
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/36027?usp=email ) Change subject: saip.personalization: automatically compute class 'name' attribute ...................................................................... saip.personalization: automatically compute class 'name' attribute We can use the metaclass to set a proper non-camel-case name attribute. Change-Id: If02df436c8f5ce01d21e9ee077ad3736e669d103 --- M pySim/esim/saip/personalization.py 1 file changed, 13 insertions(+), 2 deletions(-) Approvals: laforge: Looks good to me, approved Jenkins Builder: Verified diff --git a/pySim/esim/saip/personalization.py b/pySim/esim/saip/personalization.py index 7ac0dbd..3dad208 100644 --- a/pySim/esim/saip/personalization.py +++ b/pySim/esim/saip/personalization.py @@ -19,6 +19,7 @@ import io from typing import List, Tuple +from pySim.tlv import camel_to_snake from pySim.utils import enc_iccid, enc_imsi, h2b, rpad, sanitize_iccid from pySim.esim.saip import ProfileElement, ProfileElementSequence @@ -41,6 +42,7 @@ x = super().__new__(metacls, name, bases, namespace) for k, v in kwargs.items(): setattr(x, k, v) + setattr(x, 'name', camel_to_snake(name)) return x class ConfigurableParameter(abc.ABC, metaclass=ClassVarMeta): @@ -63,7 +65,6 @@ class Iccid(ConfigurableParameter): """Configurable ICCID. Expects the value to be a string of decimal digits. If the string of digits is only 18 digits long, a Luhn check digit will be added.""" - name = 'iccid' def validate(self): # convert to string as it migt be an integer @@ -83,7 +84,6 @@ class Imsi(ConfigurableParameter): """Configurable IMSI. Expects value to be a string of digits. Automatically sets the ACC to the last digit of the IMSI.""" - name = 'imsi' def validate(self): # convert to string as it migt be an integer -- To view, visit https://gerrit.osmocom.org/c/pysim/+/36027?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: If02df436c8f5ce01d21e9ee077ad3736e669d103 Gerrit-Change-Number: 36027 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-MessageType: merged
1 0
0 0
[S] Change in pysim[master]: saip.personalization: Fix encoding of ICCID in ProfileHeader
by laforge 22 Feb '24

22 Feb '24
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/36028?usp=email ) Change subject: saip.personalization: Fix encoding of ICCID in ProfileHeader ...................................................................... saip.personalization: Fix encoding of ICCID in ProfileHeader To make things exciting, they decided that the ICCID in the profile header is encoded different from the ICCID contained in EF.ICCID... Change-Id: I5eacdcdc6bd0ada431eb047bfae930d79d6e3af8 --- M pySim/esim/saip/personalization.py 1 file changed, 13 insertions(+), 1 deletion(-) Approvals: laforge: Looks good to me, approved Jenkins Builder: Verified diff --git a/pySim/esim/saip/personalization.py b/pySim/esim/saip/personalization.py index 3dad208..dc3435b 100644 --- a/pySim/esim/saip/personalization.py +++ b/pySim/esim/saip/personalization.py @@ -77,7 +77,7 @@ def apply(self, pes: ProfileElementSequence): # patch the header - pes.get_pe_for_type('header').decoded['iccid'] = self.value + pes.get_pe_for_type('header').decoded['iccid'] = h2b(rpad(self.value, 20)) # patch MF/EF.ICCID file_replace_content(pes.get_pe_for_type('mf').decoded['ef-iccid'], h2b(enc_iccid(self.value))) -- To view, visit https://gerrit.osmocom.org/c/pysim/+/36028?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I5eacdcdc6bd0ada431eb047bfae930d79d6e3af8 Gerrit-Change-Number: 36028 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-MessageType: merged
1 0
0 0
[M] Change in pysim[master]: saip.personalization: include encode/decode of value; add validation ...
by laforge 22 Feb '24

22 Feb '24
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/36014?usp=email ) Change subject: saip.personalization: include encode/decode of value; add validation method ...................................................................... saip.personalization: include encode/decode of value; add validation method Change-Id: Ia9fa39c25817448afb191061acd4be894300eeef --- M pySim/esim/saip/personalization.py M tests/test_esim_saip.py 2 files changed, 86 insertions(+), 14 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved diff --git a/pySim/esim/saip/personalization.py b/pySim/esim/saip/personalization.py index 5adaf2e..ac9089c 100644 --- a/pySim/esim/saip/personalization.py +++ b/pySim/esim/saip/personalization.py @@ -16,8 +16,10 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import abc +import io from typing import List, Tuple +from pySim.utils import enc_iccid, enc_imsi, h2b, rpad, sanitize_iccid from pySim.esim.saip import ProfileElement, ProfileElementSequence def remove_unwanted_tuples_from_list(l: List[Tuple], unwanted_keys: List[str]) -> List[Tuple]: @@ -47,26 +49,56 @@ def __init__(self, value): self.value = value + def validate(self): + """Optional validation method. Can be used by derived classes to perform validation + of the input value (self.value). Will raise an exception if validation fails.""" + pass + @abc.abstractmethod def apply(self, pes: ProfileElementSequence): pass class Iccid(ConfigurableParameter): - """Configurable ICCID. Expects the value to be in EF.ICCID format.""" + """Configurable ICCID. Expects the value to be a string of decimal digits. + If the string of digits is only 18 digits long, a Luhn check digit will be added.""" name = 'iccid' + + def validate(self): + # convert to string as it migt be an integer + iccid_str = str(self.value) + if len(iccid_str) < 18 or len(iccid_str) > 20: + raise ValueError('ICCID must be 18, 19 or 20 digits long') + if not iccid_str.isdecimal(): + raise ValueError('ICCID must only contain decimal digits') + def apply(self, pes: ProfileElementSequence): - # patch the header; FIXME: swap nibbles! - pes.get_pe_for_type('header').decoded['iccid'] = self.value + iccid_str = sanitize_iccid(self.value) + # patch the header + pes.get_pe_for_type('header').decoded['iccid'] = iccid_str # patch MF/EF.ICCID - file_replace_content(pes.get_pe_for_type('mf').decoded['ef-iccid'], bytes(self.value)) + file_replace_content(pes.get_pe_for_type('mf').decoded['ef-iccid'], h2b(enc_iccid(iccid_str))) class Imsi(ConfigurableParameter): - """Configurable IMSI. Expects value to be n EF.IMSI format.""" + """Configurable IMSI. Expects value to be a string of digits. Automatically sets the ACC to + the last digit of the IMSI.""" name = 'imsi' + + def validate(self): + # convert to string as it migt be an integer + imsi_str = str(self.value) + if len(imsi_str) < 6 or len(imsi_str) > 15: + raise ValueError('IMSI must be 6..15 digits long') + if not imsi_str.isdecimal(): + raise ValueError('IMSI must only contain decimal digits') + def apply(self, pes: ProfileElementSequence): + imsi_str = str(self.value) + # we always use the least significant byte of the IMSI as ACC + acc = (1 << int(imsi_str[-1])) # patch ADF.USIM/EF.IMSI - for pe in pes.get_pes_by_type('usim'): - file_replace_content(pe.decoded['ef-imsi'], self.value) + for pe in pes.get_pes_for_type('usim'): + file_replace_content(pe.decoded['ef-imsi'], h2b(enc_imsi(imsi_str))) + file_replace_content(pe.decoded['ef-acc'], acc.to_bytes(2, 'big')) # TODO: DF.GSM_ACCESS if not linked? def obtain_singleton_pe_from_pelist(l: List[ProfileElement], wanted_type: str) -> ProfileElement: @@ -81,12 +113,21 @@ class Puk(ConfigurableParameter, metaclass=ClassVarMeta): """Configurable PUK (Pin Unblock Code). String ASCII-encoded digits.""" keyReference = None + def validate(self): + if isinstance(self.value, int): + self.value = '%08d' % self.value + # FIXME: valid length? + if not self.value.isdecimal(): + raise ValueError('PUK must only contain decimal digits') + def apply(self, pes: ProfileElementSequence): + puk = ''.join(['%02x' % (ord(x)) for x in self.value]) + padded_puk = rpad(puk, 16) mf_pes = pes.pes_by_naa['mf'][0] pukCodes = obtain_singleton_pe_from_pelist(mf_pes, 'pukCodes') for pukCode in pukCodes.decoded['pukCodes']: if pukCode['keyReference'] == self.keyReference: - pukCode['pukValue'] = self.value + pukCode['pukValue'] = h2b(padded_puk) return raise ValueError('cannot find pukCode') class Puk1(Puk, keyReference=0x01): @@ -97,29 +138,46 @@ class Pin(ConfigurableParameter, metaclass=ClassVarMeta): """Configurable PIN (Personal Identification Number). String of digits.""" keyReference = None + def validate(self): + if isinstance(self.value, int): + self.value = '%04d' % self.value + if len(self.value) < 4 or len(self.value) > 8: + raise ValueError('PIN mus be 4..8 digits long') + if not self.value.isdecimal(): + raise ValueError('PIN must only contain decimal digits') def apply(self, pes: ProfileElementSequence): + pin = ''.join(['%02x' % (ord(x)) for x in self.value]) + padded_pin = rpad(pin, 16) mf_pes = pes.pes_by_naa['mf'][0] pinCodes = obtain_first_pe_from_pelist(mf_pes, 'pinCodes') if pinCodes.decoded['pinCodes'][0] != 'pinconfig': return for pinCode in pinCodes.decoded['pinCodes'][1]: if pinCode['keyReference'] == self.keyReference: - pinCode['pinValue'] = self.value + pinCode['pinValue'] = h2b(padded_pin) return raise ValueError('cannot find pinCode') class AppPin(ConfigurableParameter, metaclass=ClassVarMeta): """Configurable PIN (Personal Identification Number). String of digits.""" keyReference = None + def validate(self): + if isinstance(self.value, int): + self.value = '%04d' % self.value + if len(self.value) < 4 or len(self.value) > 8: + raise ValueError('PIN mus be 4..8 digits long') + if not self.value.isdecimal(): + raise ValueError('PIN must only contain decimal digits') def _apply_one(self, pe: ProfileElement): + pin = ''.join(['%02x' % (ord(x)) for x in self.value]) + padded_pin = rpad(pin, 16) pinCodes = obtain_first_pe_from_pelist(pe, 'pinCodes') if pinCodes.decoded['pinCodes'][0] != 'pinconfig': return for pinCode in pinCodes.decoded['pinCodes'][1]: if pinCode['keyReference'] == self.keyReference: - pinCode['pinValue'] = self.value + pinCode['pinValue'] = h2b(padded_pin) return raise ValueError('cannot find pinCode') - def apply(self, pes: ProfileElementSequence): for naa in pes.pes_by_naa: if naa not in ['usim','isim','csim','telecom']: @@ -140,6 +198,9 @@ class AlgoConfig(ConfigurableParameter, metaclass=ClassVarMeta): """Configurable Algorithm parameter. bytes.""" key = None + def validate(self): + if not isinstance(self.value, (io.BytesIO, bytes, bytearray)): + raise ValueError('Value must be of bytes-like type') def apply(self, pes: ProfileElementSequence): for pe in pes.get_pes_for_type('akaParameter'): algoConfiguration = pe.decoded['algoConfiguration'] @@ -152,5 +213,6 @@ class Opc(AlgoConfig, key='opc'): pass class AlgorithmID(AlgoConfig, key='algorithmID'): - pass - + def validate(self): + if self.value not in [1, 2, 3]: + raise ValueError('Invalid algorithmID %s' % (self.value)) diff --git a/tests/test_esim_saip.py b/tests/test_esim_saip.py index 9e7afb2..a70c149 100755 --- a/tests/test_esim_saip.py +++ b/tests/test_esim_saip.py @@ -55,9 +55,10 @@ def test_personalization(self): """Test some of the personalization operations.""" pes = copy.deepcopy(self.pes) - params = [Puk1(value=b'01234567'), Puk2(value=b'98765432'), Pin1(b'1111'), Pin2(b'2222'), Adm1(b'11111111'), + params = [Puk1('01234567'), Puk2(98765432), Pin1('1111'), Pin2(2222), Adm1('11111111'), K(h2b('000102030405060708090a0b0c0d0e0f')), Opc(h2b('101112131415161718191a1b1c1d1e1f'))] for p in params: + p.validate() p.apply(pes) # TODO: we don't actually test the results here, but we just verify there is no exception pes.to_der() -- To view, visit https://gerrit.osmocom.org/c/pysim/+/36014?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: Ia9fa39c25817448afb191061acd4be894300eeef Gerrit-Change-Number: 36014 Gerrit-PatchSet: 5 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-MessageType: merged
1 0
0 0
[M] Change in pysim[master]: saip.personalization: Add support for SCP80/81/02/03 keys
by laforge 22 Feb '24

22 Feb '24
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/36015?usp=email ) Change subject: saip.personalization: Add support for SCP80/81/02/03 keys ...................................................................... saip.personalization: Add support for SCP80/81/02/03 keys Those keys are normally per-card unique, and hence the personalization must be able to modify them in the profile. Change-Id: Ibe4806366f1cce8edb09d52613b1dd56250fa5ae --- M pySim/esim/saip/personalization.py 1 file changed, 106 insertions(+), 0 deletions(-) Approvals: laforge: Looks good to me, approved Jenkins Builder: Verified diff --git a/pySim/esim/saip/personalization.py b/pySim/esim/saip/personalization.py index ac9089c..84baddb 100644 --- a/pySim/esim/saip/personalization.py +++ b/pySim/esim/saip/personalization.py @@ -101,6 +101,100 @@ file_replace_content(pe.decoded['ef-acc'], acc.to_bytes(2, 'big')) # TODO: DF.GSM_ACCESS if not linked? + +class SdKey(ConfigurableParameter, metaclass=ClassVarMeta): + """Configurable Security Domain (SD) Key. Value is presented as bytes.""" + # these will be set by derived classes + key_type = None + key_id = None + kvn = None + key_usage_qual = None + permitted_len = None + + def validate(self): + if not isinstance(self.value, (io.BytesIO, bytes, bytearray)): + raise ValueError('Value must be of bytes-like type') + if self.permitted_len: + if len(self.value) not in self.permitted_len: + raise ValueError('Value length must be %s' % self.permitted_len) + + def _apply_sd(self, pe: ProfileElement): + assert pe.type == 'securityDomain' + for key in pe.decoded['keyList']: + if key['keyIdentifier'][0] == self.key_id and key['keyVersionNumber'][0] == self.kvn: + assert len(key['keyComponents']) == 1 + key['keyComponents'][0]['keyData'] = self.value + return + # Could not find matching key to patch, create a new one + key = { + 'keyUsageQualifier': bytes([self.key_usage_qual]), + 'keyIdentifier': bytes([self.key_id]), + 'keyVersionNumber': bytes([self.kvn]), + 'keyComponents': [ + { 'keyType': bytes([self.key_type]), 'keyData': self.value }, + ] + } + pe.decoded['keyList'].append(key) + + def apply(self, pes: ProfileElementSequence): + for pe in pes.get_pes_for_type('securityDomain'): + self._apply_sd(pe) + +class SdKeyScp80_01(SdKey, kvn=0x01, key_type=0x88, permitted_len=[16,24,32]): # AES key type + pass +class SdKeyScp80_01Kic(SdKeyScp80_01, key_id=0x01, key_usage_qual=0x18): # FIXME: ordering? + pass +class SdKeyScp80_01Kid(SdKeyScp80_01, key_id=0x02, key_usage_qual=0x14): + pass +class SdKeyScp80_01Kik(SdKeyScp80_01, key_id=0x03, key_usage_qual=0x48): + pass + +class SdKeyScp81_01(SdKey, kvn=0x81): # FIXME + pass +class SdKeyScp81_01Psk(SdKeyScp81_01, key_id=0x01, key_type=0x85, key_usage_qual=0x3C): + pass +class SdKeyScp81_01Dek(SdKeyScp81_01, key_id=0x02, key_type=0x88, key_usage_qual=0x48): + pass + +class SdKeyScp02_20(SdKey, kvn=0x20, key_type=0x88, permitted_len=[16,24,32]): # AES key type + pass +class SdKeyScp02_20Enc(SdKeyScp02_20, key_id=0x01, key_usage_qual=0x18): + pass +class SdKeyScp02_20Mac(SdKeyScp02_20, key_id=0x02, key_usage_qual=0x14): + pass +class SdKeyScp02_20Dek(SdKeyScp02_20, key_id=0x03, key_usage_qual=0x48): + pass + +class SdKeyScp03_30(SdKey, kvn=0x30, key_type=0x88, permitted_len=[16,24,32]): # AES key type + pass +class SdKeyScp03_30Enc(SdKeyScp03_30, key_id=0x01, key_usage_qual=0x18): + pass +class SdKeyScp03_30Mac(SdKeyScp03_30, key_id=0x02, key_usage_qual=0x14): + pass +class SdKeyScp03_30Dek(SdKeyScp03_30, key_id=0x03, key_usage_qual=0x48): + pass + +class SdKeyScp03_31(SdKey, kvn=0x31, key_type=0x88, permitted_len=[16,24,32]): # AES key type + pass +class SdKeyScp03_31Enc(SdKeyScp03_31, key_id=0x01, key_usage_qual=0x18): + pass +class SdKeyScp03_31Mac(SdKeyScp03_31, key_id=0x02, key_usage_qual=0x14): + pass +class SdKeyScp03_31Dek(SdKeyScp03_31, key_id=0x03, key_usage_qual=0x48): + pass + +class SdKeyScp03_32(SdKey, kvn=0x32, key_type=0x88, permitted_len=[16,24,32]): # AES key type + pass +class SdKeyScp03_32Enc(SdKeyScp03_32, key_id=0x01, key_usage_qual=0x18): + pass +class SdKeyScp03_32Mac(SdKeyScp03_32, key_id=0x02, key_usage_qual=0x14): + pass +class SdKeyScp03_32Dek(SdKeyScp03_32, key_id=0x03, key_usage_qual=0x48): + pass + + + + def obtain_singleton_pe_from_pelist(l: List[ProfileElement], wanted_type: str) -> ProfileElement: filtered = list(filter(lambda x: x.type == wanted_type, l)) assert len(filtered) == 1 -- To view, visit https://gerrit.osmocom.org/c/pysim/+/36015?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: Ibe4806366f1cce8edb09d52613b1dd56250fa5ae Gerrit-Change-Number: 36015 Gerrit-PatchSet: 5 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-MessageType: merged
1 0
0 0
[M] Change in pysim[master]: saip.personalization: differentiate input_value from value
by laforge 22 Feb '24

22 Feb '24
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/36016?usp=email ) Change subject: saip.personalization: differentiate input_value from value ...................................................................... saip.personalization: differentiate input_value from value When personalizing e.g. the ICCID, the input_value is the raw incrementing counter. From that, we calculate the Luhn check digit, and that "output" value is what we'll put in to the EF.ICCID specific encoder. However, we also store that output value in the instance in order to generate the output CSV file containig the card-specific personalization data. Change-Id: Idfcd26c8ca9d73a9c2955f7c97e711dd59a27c4e --- M pySim/esim/saip/personalization.py 1 file changed, 50 insertions(+), 20 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved diff --git a/pySim/esim/saip/personalization.py b/pySim/esim/saip/personalization.py index 84baddb..7ac0dbd 100644 --- a/pySim/esim/saip/personalization.py +++ b/pySim/esim/saip/personalization.py @@ -46,13 +46,15 @@ class ConfigurableParameter(abc.ABC, metaclass=ClassVarMeta): """Base class representing a part of the eSIM profile that is configurable during the personalization process (with dynamic data from elsewhere).""" - def __init__(self, value): - self.value = value + def __init__(self, input_value): + self.input_value = input_value # the raw input value as given by caller + self.value = None # the processed input value (e.g. with check digit) as produced by validate() def validate(self): """Optional validation method. Can be used by derived classes to perform validation of the input value (self.value). Will raise an exception if validation fails.""" - pass + # default implementation: simply copy input_value over to value + self.value = self.input_value @abc.abstractmethod def apply(self, pes: ProfileElementSequence): @@ -65,18 +67,18 @@ def validate(self): # convert to string as it migt be an integer - iccid_str = str(self.value) + iccid_str = str(self.input_value) if len(iccid_str) < 18 or len(iccid_str) > 20: raise ValueError('ICCID must be 18, 19 or 20 digits long') if not iccid_str.isdecimal(): raise ValueError('ICCID must only contain decimal digits') + self.value = sanitize_iccid(iccid_str) def apply(self, pes: ProfileElementSequence): - iccid_str = sanitize_iccid(self.value) # patch the header - pes.get_pe_for_type('header').decoded['iccid'] = iccid_str + pes.get_pe_for_type('header').decoded['iccid'] = self.value # patch MF/EF.ICCID - file_replace_content(pes.get_pe_for_type('mf').decoded['ef-iccid'], h2b(enc_iccid(iccid_str))) + file_replace_content(pes.get_pe_for_type('mf').decoded['ef-iccid'], h2b(enc_iccid(self.value))) class Imsi(ConfigurableParameter): """Configurable IMSI. Expects value to be a string of digits. Automatically sets the ACC to @@ -85,14 +87,15 @@ def validate(self): # convert to string as it migt be an integer - imsi_str = str(self.value) + imsi_str = str(self.input_value) if len(imsi_str) < 6 or len(imsi_str) > 15: raise ValueError('IMSI must be 6..15 digits long') if not imsi_str.isdecimal(): raise ValueError('IMSI must only contain decimal digits') + self.value = imsi_str def apply(self, pes: ProfileElementSequence): - imsi_str = str(self.value) + imsi_str = self.value # we always use the least significant byte of the IMSI as ACC acc = (1 << int(imsi_str[-1])) # patch ADF.USIM/EF.IMSI @@ -112,11 +115,12 @@ permitted_len = None def validate(self): - if not isinstance(self.value, (io.BytesIO, bytes, bytearray)): + if not isinstance(self.input_value, (io.BytesIO, bytes, bytearray)): raise ValueError('Value must be of bytes-like type') if self.permitted_len: - if len(self.value) not in self.permitted_len: + if len(self.input_value) not in self.permitted_len: raise ValueError('Value length must be %s' % self.permitted_len) + self.value = self.input_value def _apply_sd(self, pe: ProfileElement): assert pe.type == 'securityDomain' @@ -208,8 +212,10 @@ """Configurable PUK (Pin Unblock Code). String ASCII-encoded digits.""" keyReference = None def validate(self): - if isinstance(self.value, int): - self.value = '%08d' % self.value + if isinstance(self.input_value, int): + self.value = '%08d' % self.input_value + else: + self.value = self.input_value # FIXME: valid length? if not self.value.isdecimal(): raise ValueError('PUK must only contain decimal digits') @@ -233,8 +239,10 @@ """Configurable PIN (Personal Identification Number). String of digits.""" keyReference = None def validate(self): - if isinstance(self.value, int): - self.value = '%04d' % self.value + if isinstance(self.input_value, int): + self.value = '%04d' % self.input_value + else: + self.value = self.input_value if len(self.value) < 4 or len(self.value) > 8: raise ValueError('PIN mus be 4..8 digits long') if not self.value.isdecimal(): @@ -255,8 +263,10 @@ """Configurable PIN (Personal Identification Number). String of digits.""" keyReference = None def validate(self): - if isinstance(self.value, int): - self.value = '%04d' % self.value + if isinstance(self.input_value, int): + self.value = '%04d' % self.input_value + else: + self.value = self.input_value if len(self.value) < 4 or len(self.value) > 8: raise ValueError('PIN mus be 4..8 digits long') if not self.value.isdecimal(): @@ -293,8 +303,9 @@ """Configurable Algorithm parameter. bytes.""" key = None def validate(self): - if not isinstance(self.value, (io.BytesIO, bytes, bytearray)): + if not isinstance(self.input_value, (io.BytesIO, bytes, bytearray)): raise ValueError('Value must be of bytes-like type') + self.value = self.input_value def apply(self, pes: ProfileElementSequence): for pe in pes.get_pes_for_type('akaParameter'): algoConfiguration = pe.decoded['algoConfiguration'] @@ -308,5 +319,6 @@ pass class AlgorithmID(AlgoConfig, key='algorithmID'): def validate(self): - if self.value not in [1, 2, 3]: - raise ValueError('Invalid algorithmID %s' % (self.value)) + if self.input_value not in [1, 2, 3]: + raise ValueError('Invalid algorithmID %s' % (self.input_value)) + self.value = self.input_value -- To view, visit https://gerrit.osmocom.org/c/pysim/+/36016?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: Idfcd26c8ca9d73a9c2955f7c97e711dd59a27c4e Gerrit-Change-Number: 36016 Gerrit-PatchSet: 4 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-MessageType: merged
1 0
0 0
[S] Change in pysim[master]: saip.personalization: Fix encoding of ICCID in ProfileHeader
by laforge 22 Feb '24

22 Feb '24
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/36028?usp=email ) Change subject: saip.personalization: Fix encoding of ICCID in ProfileHeader ...................................................................... Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/pysim/+/36028?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I5eacdcdc6bd0ada431eb047bfae930d79d6e3af8 Gerrit-Change-Number: 36028 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Comment-Date: Thu, 22 Feb 2024 10:23:34 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[S] Change in pysim[master]: saip.personalization: automatically compute class 'name' attribute
by laforge 22 Feb '24

22 Feb '24
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/36027?usp=email ) Change subject: saip.personalization: automatically compute class 'name' attribute ...................................................................... Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/pysim/+/36027?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: If02df436c8f5ce01d21e9ee077ad3736e669d103 Gerrit-Change-Number: 36027 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Comment-Date: Thu, 22 Feb 2024 10:23:32 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[M] Change in pysim[master]: saip.personalization: differentiate input_value from value
by laforge 22 Feb '24

22 Feb '24
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/36016?usp=email ) Change subject: saip.personalization: differentiate input_value from value ...................................................................... Patch Set 4: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/pysim/+/36016?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: Idfcd26c8ca9d73a9c2955f7c97e711dd59a27c4e Gerrit-Change-Number: 36016 Gerrit-PatchSet: 4 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Comment-Date: Thu, 22 Feb 2024 10:23:30 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • ...
  • 175
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.