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
[L] Change in libosmo-sccp[master]: Implement M3UA-over-TCP (in addition to SCTP)
by pespin 19 Feb '24

19 Feb '24
Attention is currently required from: fixeria, laforge. pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/35796?usp=email ) Change subject: Implement M3UA-over-TCP (in addition to SCTP) ...................................................................... Patch Set 6: (1 comment) File TODO-RELEASE: https://gerrit.osmocom.org/c/libosmo-sccp/+/35796/comment/cdf2ad63_3504059b PS6, Line 15: libosmo-sigtran ABI change struct osmo_ss7_asp: new field(s) > We always add new fields at the end, so I don't see the need to clarify this here. How many counterexamples should I provide? -- To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/35796?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Change-Id: I8c76d271472befacbeb998a93bbdc9e8660d9b5d Gerrit-Change-Number: 35796 Gerrit-PatchSet: 6 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-CC: jolly <andreas(a)eversberg.eu> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Comment-Date: Mon, 19 Feb 2024 14:46:31 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: fixeria <vyanitskiy(a)sysmocom.de> Comment-In-Reply-To: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: comment
1 0
0 0
[M] Change in pysim[master]: saip.personalization: include encode/decode of value; add validation ...
by laforge 19 Feb '24

19 Feb '24
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/+/36014?usp=email to look at the new patch set (#4). The following approvals got outdated and were removed: Verified-1 by Jenkins Builder 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(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/14/36014/4 -- 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: 4 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newpatchset
1 0
0 0
[M] Change in pysim[master]: saip.personalization: include encode/decode of value; add validation ...
by laforge 19 Feb '24

19 Feb '24
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/+/36014?usp=email to look at the new patch set (#3). The following approvals got outdated and were removed: Verified-1 by Jenkins Builder 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, 85 insertions(+), 13 deletions(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/14/36014/3 -- 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: 3 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newpatchset
1 0
0 0
[S] Change in libgtpnl[master]: gtp-link: close sockets on error
by pespin 19 Feb '24

19 Feb '24
Attention is currently required from: osmith. pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/libgtpnl/+/36017?usp=email ) Change subject: gtp-link: close sockets on error ...................................................................... Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/libgtpnl/+/36017?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libgtpnl Gerrit-Branch: master Gerrit-Change-Id: I9c437de9712ebe568528b4c9ee1e89a4ba5cd5d1 Gerrit-Change-Number: 36017 Gerrit-PatchSet: 1 Gerrit-Owner: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: osmith <osmith(a)sysmocom.de> Gerrit-Comment-Date: Mon, 19 Feb 2024 13:08:17 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[S] Change in libgtpnl[master]: gtp-link: close sockets on error
by osmith 19 Feb '24

19 Feb '24
osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/libgtpnl/+/36017?usp=email ) Change subject: gtp-link: close sockets on error ...................................................................... gtp-link: close sockets on error Avoid resource leaks. Fixes: CID#347578, CID#347579 Change-Id: I9c437de9712ebe568528b4c9ee1e89a4ba5cd5d1 --- M tools/gtp-link.c 1 file changed, 35 insertions(+), 7 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libgtpnl refs/changes/17/36017/1 diff --git a/tools/gtp-link.c b/tools/gtp-link.c index 0881f15..0b14bc5 100644 --- a/tools/gtp-link.c +++ b/tools/gtp-link.c @@ -80,16 +80,15 @@ static int setup_socket(struct gtp_server_sock *gtp_sock, int family) { - int fd1 = socket(family, SOCK_DGRAM, 0); - int fd2 = socket(family, SOCK_DGRAM, 0); int one = 1; - if (fd1 < 0 || fd2 < 0) + gtp_sock->fd1 = socket(family, SOCK_DGRAM, 0); + gtp_sock->fd2 = socket(family, SOCK_DGRAM, 0); + + if (gtp_sock->fd1 < 0 || gtp_sock->fd2 < 0) return -1; gtp_sock->family = family; - gtp_sock->fd1 = fd1; - gtp_sock->fd2 = fd2; switch (family) { case AF_INET: @@ -105,9 +104,9 @@ &gtp_sock->addr.v6, 3386); setup_sockaddr_in6(&gtp_sock->sockaddr.fd2.in6, &gtp_sock->addr.v6, 2152); - if (setsockopt(fd1, IPPROTO_IPV6, IPV6_V6ONLY, &one, sizeof(one)) < 0) + if (setsockopt(gtp_sock->fd1, IPPROTO_IPV6, IPV6_V6ONLY, &one, sizeof(one)) < 0) perror("setsockopt IPV6_V6ONLY: "); - if (setsockopt(fd2, IPPROTO_IPV6, IPV6_V6ONLY, &one, sizeof(one)) < 0) + if (setsockopt(gtp_sock->fd2, IPPROTO_IPV6, IPV6_V6ONLY, &one, sizeof(one)) < 0) perror("setsockopt IPV6_V6ONLY: "); break; } @@ -115,6 +114,19 @@ return 0; } +static void close_socket(struct gtp_server_sock *gtp_sock) +{ + if (gtp_sock->fd1 != -1) { + close(gtp_sock->fd1); + gtp_sock->fd1 = -1; + } + + if (gtp_sock->fd2 != -1) { + close(gtp_sock->fd2); + gtp_sock->fd2 = -1; + } +} + int main(int argc, char *argv[]) { char buf[MNL_SOCKET_BUFFER_SIZE]; @@ -186,15 +198,18 @@ if (setup_socket(&gtp_sock, family) < 0) { perror("socket"); + close_socket(&gtp_sock); exit(EXIT_FAILURE); } if (bind(gtp_sock.fd1, (struct sockaddr *) &gtp_sock.sockaddr.fd1, gtp_sock.len) < 0) { perror("bind"); + close_socket(&gtp_sock); exit(EXIT_FAILURE); } if (bind(gtp_sock.fd2, (struct sockaddr *) &gtp_sock.sockaddr.fd2, gtp_sock.len) < 0) { perror("bind"); + close_socket(&gtp_sock); exit(EXIT_FAILURE); } @@ -204,6 +219,7 @@ ret = gtp_dev_create(-1, argv[2], gtp_sock.fd1, gtp_sock.fd2); if (ret < 0) { perror("cannot create GTP device\n"); + close_socket(&gtp_sock); exit(EXIT_FAILURE); } -- To view, visit https://gerrit.osmocom.org/c/libgtpnl/+/36017?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libgtpnl Gerrit-Branch: master Gerrit-Change-Id: I9c437de9712ebe568528b4c9ee1e89a4ba5cd5d1 Gerrit-Change-Number: 36017 Gerrit-PatchSet: 1 Gerrit-Owner: osmith <osmith(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in pysim[master]: saip: improve docstrings
by laforge 19 Feb '24

19 Feb '24
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/36013?usp=email ) Change subject: saip: improve docstrings ...................................................................... saip: improve docstrings Change-Id: I0ca82a434e0bde3dc1b304dfc179d568588631c6 --- M pySim/esim/saip/__init__.py M pySim/esim/saip/personalization.py 2 files changed, 30 insertions(+), 3 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved diff --git a/pySim/esim/saip/__init__.py b/pySim/esim/saip/__init__.py index 82ed2b7..b8e41ce 100644 --- a/pySim/esim/saip/__init__.py +++ b/pySim/esim/saip/__init__.py @@ -30,7 +30,13 @@ asn1 = compile_asn1_subdir('saip') class File: - """Internal representation of a file in a profile filesystem.""" + """Internal representation of a file in a profile filesystem. + + Parameters: + pename: Name string of the profile element + l: List of tuples [fileDescriptor, fillFileContent, fillFileOffset profile elements] + template: Applicable FileTemplate describing defaults as per SAIP spec + """ def __init__(self, pename: str, l: Optional[List[Tuple]] = None, template: Optional[templates.FileTemplate] = None): self.pe_name = pename self.template = template @@ -103,7 +109,7 @@ @staticmethod def linearize_file_content(l: List[Tuple]) -> Optional[io.BytesIO]: - """linearize a list of fillFileContent + fillFileOffset tuples.""" + """linearize a list of fillFileContent / fillFileOffset tuples into a stream of bytes.""" stream = io.BytesIO() for k, v in l: if k == 'doNotCreate': @@ -125,6 +131,7 @@ return "File(%s): %s" % (self.pe_name, self.fileDescriptor) class ProfileElement: + """Class representing a Profile Element (PE) within a SAIP Profile.""" FILE_BEARING = ['mf', 'cd', 'telecom', 'usim', 'opt-usim', 'isim', 'opt-isim', 'phonebook', 'gsm-access', 'csim', 'opt-csim', 'eap', 'df-5gs', 'df-saip', 'df-snpn', 'df-5gprose', 'iot', 'opt-iot'] def _fixup_sqnInit_dec(self) -> None: @@ -162,6 +169,7 @@ @property def header_name(self) -> str: + """Return the name of the header field within the profile element.""" # unneccessarry compliaction by inconsistent naming :( if self.type.startswith('opt-'): return self.type.replace('-','') + '-header' @@ -169,10 +177,12 @@ @property def header(self): + """Return the decoded ProfileHeader.""" return self.decoded.get(self.header_name, None) @property def templateID(self): + """Return the decoded templateID used by this profile element (if any).""" return self.decoded.get('templateID', None) @property @@ -216,9 +226,12 @@ self.pes_by_naa: Dict = {} def get_pes_for_type(self, tname: str) -> List[ProfileElement]: + """Return list of profile elements present for given profile element type.""" return self.pe_by_type.get(tname, []) def get_pe_for_type(self, tname: str) -> Optional[ProfileElement]: + """Return a single profile element for given profile element type. Works only for + types of which there is only a signle instance in the PE Sequence!""" l = self.get_pes_for_type(tname) if len(l) == 0: return None diff --git a/pySim/esim/saip/personalization.py b/pySim/esim/saip/personalization.py index fd83387..5adaf2e 100644 --- a/pySim/esim/saip/personalization.py +++ b/pySim/esim/saip/personalization.py @@ -32,7 +32,8 @@ return file class ClassVarMeta(abc.ABCMeta): - """Metaclass that puts all additional keyword-args into the class.""" + """Metaclass that puts all additional keyword-args into the class. We use this to have one + class definition for something like a PIN, and then have derived classes for PIN1, PIN2, ...""" def __new__(metacls, name, bases, namespace, **kwargs): #print("Meta_new_(metacls=%s, name=%s, bases=%s, namespace=%s, kwargs=%s)" % (metacls, name, bases, namespace, kwargs)) x = super().__new__(metacls, name, bases, namespace) @@ -78,6 +79,7 @@ return filtered[0] class Puk(ConfigurableParameter, metaclass=ClassVarMeta): + """Configurable PUK (Pin Unblock Code). String ASCII-encoded digits.""" keyReference = None def apply(self, pes: ProfileElementSequence): mf_pes = pes.pes_by_naa['mf'][0] @@ -93,6 +95,7 @@ pass class Pin(ConfigurableParameter, metaclass=ClassVarMeta): + """Configurable PIN (Personal Identification Number). String of digits.""" keyReference = None def apply(self, pes: ProfileElementSequence): mf_pes = pes.pes_by_naa['mf'][0] @@ -105,6 +108,7 @@ return raise ValueError('cannot find pinCode') class AppPin(ConfigurableParameter, metaclass=ClassVarMeta): + """Configurable PIN (Personal Identification Number). String of digits.""" keyReference = None def _apply_one(self, pe: ProfileElement): pinCodes = obtain_first_pe_from_pelist(pe, 'pinCodes') @@ -134,6 +138,7 @@ class AlgoConfig(ConfigurableParameter, metaclass=ClassVarMeta): + """Configurable Algorithm parameter. bytes.""" key = None def apply(self, pes: ProfileElementSequence): for pe in pes.get_pes_for_type('akaParameter'): -- To view, visit https://gerrit.osmocom.org/c/pysim/+/36013?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: I0ca82a434e0bde3dc1b304dfc179d568588631c6 Gerrit-Change-Number: 36013 Gerrit-PatchSet: 2 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]: pylint: esim/saip/__init__.py
by laforge 19 Feb '24

19 Feb '24
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/36011?usp=email ) Change subject: pylint: esim/saip/__init__.py ...................................................................... pylint: esim/saip/__init__.py pySim/esim/saip/__init__.py:28:0: R0402: Use 'from pySim.esim.saip import templates' instead (consider-using-from-import) pySim/esim/saip/__init__.py:166:8: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return) pySim/esim/saip/__init__.py:206:4: W0612: Unused variable 'tagdict' (unused-variable) pySim/esim/saip/__init__.py:273:23: C1802: Do not use `len(SEQUENCE)` without comparison to determine if a sequence is empty (use-implicit-booleaness-not-len) Change-Id: I12ef46c847d197fb0c01e624818aeac14eb99e31 --- M pySim/esim/saip/__init__.py 1 file changed, 18 insertions(+), 5 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved diff --git a/pySim/esim/saip/__init__.py b/pySim/esim/saip/__init__.py index fb064a1..82ed2b7 100644 --- a/pySim/esim/saip/__init__.py +++ b/pySim/esim/saip/__init__.py @@ -25,7 +25,7 @@ from pySim.ts_102_221 import FileDescriptor from pySim.construct import build_construct from pySim.esim import compile_asn1_subdir -import pySim.esim.saip.templates as templates +from pySim.esim.saip import templates asn1 = compile_asn1_subdir('saip') @@ -165,8 +165,7 @@ # unneccessarry compliaction by inconsistent naming :( if self.type.startswith('opt-'): return self.type.replace('-','') + '-header' - else: - return self.type + '-header' + return self.type + '-header' @property def header(self): @@ -203,7 +202,7 @@ def bertlv_first_segment(binary: bytes) -> Tuple[bytes, bytes]: """obtain the first segment of a binary concatenation of BER-TLV objects. Returns: tuple of first TLV and remainder.""" - tagdict, remainder = bertlv_parse_tag(binary) + _tagdict, remainder = bertlv_parse_tag(binary) length, remainder = bertlv_parse_len(remainder) tl_length = len(binary) - len(remainder) tlv_length = tl_length + length @@ -270,7 +269,7 @@ cur_naa_list = [] cur_naa_list.append(pe) # append the final one - if cur_naa and len(cur_naa_list): + if cur_naa and len(cur_naa_list) > 0: if not cur_naa in self.pes_by_naa: self.pes_by_naa[cur_naa] = [] self.pes_by_naa[cur_naa].append(cur_naa_list) -- To view, visit https://gerrit.osmocom.org/c/pysim/+/36011?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: I12ef46c847d197fb0c01e624818aeac14eb99e31 Gerrit-Change-Number: 36011 Gerrit-PatchSet: 2 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]: pylint: esim/saip/validation.py
by laforge 19 Feb '24

19 Feb '24
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/36012?usp=email ) Change subject: pylint: esim/saip/validation.py ...................................................................... pylint: esim/saip/validation.py pySim/esim/saip/validation.py:95:42: C0117: Consider changing "not not ('usim' in m_svcs or 'isim' in m_svcs)" to "'usim' in m_svcs or 'isim' in m_svcs" (unnecessary-negation) pySim/esim/saip/validation.py:129:0: C0305: Trailing newlines (trailing-newlines) Change-Id: Idcc9871d6a7068e8aedbd8cd81f4156918af5e50 --- M pySim/esim/saip/validation.py 1 file changed, 13 insertions(+), 2 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved diff --git a/pySim/esim/saip/validation.py b/pySim/esim/saip/validation.py index acf1864..f9f5773 100644 --- a/pySim/esim/saip/validation.py +++ b/pySim/esim/saip/validation.py @@ -92,7 +92,7 @@ raise ProfileError('get-identity mandatory, but no usim or isim') if 'profile-a-x25519' in m_svcs and not ('usim' in m_svcs or 'isim' in m_svcs): raise ProfileError('profile-a-x25519 mandatory, but no usim or isim') - if 'profile-a-p256' in m_svcs and not not ('usim' in m_svcs or 'isim' in m_svcs): + if 'profile-a-p256' in m_svcs and not ('usim' in m_svcs or 'isim' in m_svcs): raise ProfileError('profile-a-p256 mandatory, but no usim or isim') FileChoiceList = List[Tuple] @@ -126,4 +126,3 @@ def check_forbidden(self, l: FileChoiceList): """Perform checks for forbidden parameters as described in Section 8.3.3.""" - -- To view, visit https://gerrit.osmocom.org/c/pysim/+/36012?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: Idcc9871d6a7068e8aedbd8cd81f4156918af5e50 Gerrit-Change-Number: 36012 Gerrit-PatchSet: 2 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]: utils: Add function to verify Luhn check digits and to sanitize ICCIDs
by laforge 19 Feb '24

19 Feb '24
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/36009?usp=email ) Change subject: utils: Add function to verify Luhn check digits and to sanitize ICCIDs ...................................................................... utils: Add function to verify Luhn check digits and to sanitize ICCIDs Change-Id: I7812420cf97984dd834fca6a38c5e5ae113243cb --- M pySim/utils.py M tests/test_utils.py 2 files changed, 56 insertions(+), 1 deletion(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved diff --git a/pySim/utils.py b/pySim/utils.py index 86874ba..afa476b 100644 --- a/pySim/utils.py +++ b/pySim/utils.py @@ -9,7 +9,7 @@ import datetime import argparse from io import BytesIO -from typing import Optional, List, Dict, Any, Tuple, NewType +from typing import Optional, List, Dict, Any, Tuple, NewType, Union # Copyright (C) 2009-2010 Sylvain Munaut <tnt(a)246tNt.com> # Copyright (C) 2021 Harald Welte <laforge(a)osmocom.org> @@ -446,6 +446,30 @@ def enc_iccid(iccid: str) -> Hexstr: return swap_nibbles(rpad(iccid, 20)) +def sanitize_iccid(iccid: Union[int, str]) -> str: + iccid = str(iccid) + if len(iccid) < 18: + raise ValueError('ICCID input value must be at least 18 digits') + if len(iccid) > 20: + raise ValueError('ICCID input value must be at most 20 digits') + if len(iccid) == 18: + # 18 digits means we must add a luhn check digit to reach 19 digits + iccid += str(calculate_luhn(iccid)) + if len(iccid) == 20: + # 20 digits means we're actually exceeding E.118 by one digit, and + # the luhn check digit must already be included + verify_luhn(iccid) + if len(iccid) == 19: + # 19 digits means that it's either an in-spec 19-digits ICCID with + # its luhn check digit already present, or it's an out-of-spec 20-digit + # ICCID without that check digit... + try: + verify_luhn(iccid) + except ValueError: + # 19th digit was not luhn check digit; we must add it + iccid += str(calculate_luhn(iccid)) + return iccid + def enc_plmn(mcc: Hexstr, mnc: Hexstr) -> Hexstr: """Converts integer MCC/MNC into 3 bytes for EF""" @@ -606,6 +630,11 @@ for d in num[::-2]]) % 10 return 0 if check_digit == 10 else check_digit +def verify_luhn(digits: str): + """Verify the Luhn check digit; raises ValueError if it is incorrect.""" + cd = calculate_luhn(digits[:-1]) + if str(cd) != digits[-1]: + raise ValueError('Luhn check digit mismatch: should be %s but is %s' % (str(cd), digits[-1])) def mcc_from_imsi(imsi: str) -> Optional[str]: """ diff --git a/tests/test_utils.py b/tests/test_utils.py index 7609f80..2c24e3e 100755 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -236,5 +236,22 @@ self.assertEqual(utils.dgi_parse_len(b'\xfe\x0b'), (254, b'\x0b')) self.assertEqual(utils.dgi_parse_len(b'\xff\x00\xff\x0b'), (255, b'\x0b')) +class TestLuhn(unittest.TestCase): + def test_verify(self): + utils.verify_luhn('8988211000000530082') + + def test_encode(self): + self.assertEqual(utils.calculate_luhn('898821100000053008'), 2) + + def test_sanitize_iccid(self): + # 19 digits with correct luhn; we expect no change + self.assertEqual(utils.sanitize_iccid('8988211000000530082'), '8988211000000530082') + # 20 digits with correct luhn; we expect no change + self.assertEqual(utils.sanitize_iccid('89882110000005300811'), '89882110000005300811') + # 19 digits without correct luhn; we expect check digit to be added + self.assertEqual(utils.sanitize_iccid('8988211000000530081'), '89882110000005300811') + # 18 digits; we expect luhn check digit to be added + self.assertEqual(utils.sanitize_iccid('898821100000053008'), '8988211000000530082') + if __name__ == "__main__": unittest.main() -- To view, visit https://gerrit.osmocom.org/c/pysim/+/36009?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: I7812420cf97984dd834fca6a38c5e5ae113243cb Gerrit-Change-Number: 36009 Gerrit-PatchSet: 2 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]: asn1/saip: Fix typo in original ASN.1: Compontents -> Components
by laforge 19 Feb '24

19 Feb '24
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/36010?usp=email ) ( 1 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: asn1/saip: Fix typo in original ASN.1: Compontents -> Components ...................................................................... asn1/saip: Fix typo in original ASN.1: Compontents -> Components Change-Id: I6bec5625579873a9ec267d896584608c9d5e3a2f --- M pySim/esim/asn1/saip/PE_Definitions-3.3.1.asn 1 file changed, 10 insertions(+), 1 deletion(-) Approvals: laforge: Looks good to me, approved Jenkins Builder: Verified diff --git a/pySim/esim/asn1/saip/PE_Definitions-3.3.1.asn b/pySim/esim/asn1/saip/PE_Definitions-3.3.1.asn index a9cccc9..f903ae8 100644 --- a/pySim/esim/asn1/saip/PE_Definitions-3.3.1.asn +++ b/pySim/esim/asn1/saip/PE_Definitions-3.3.1.asn @@ -983,7 +983,7 @@ keyIdentifier [2] OCTET STRING (SIZE (1)), keyVersionNumber [3] OCTET STRING (SIZE (1)), keyCounterValue [5] OCTET STRING OPTIONAL, -keyCompontents SEQUENCE (SIZE (1..MAX)) OF SEQUENCE { +keyComponents SEQUENCE (SIZE (1..MAX)) OF SEQUENCE { keyType [0] OCTET STRING, keyData [6] OCTET STRING, macLength[7] UInt8 DEFAULT 8 -- To view, visit https://gerrit.osmocom.org/c/pysim/+/36010?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: I6bec5625579873a9ec267d896584608c9d5e3a2f Gerrit-Change-Number: 36010 Gerrit-PatchSet: 2 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
  • ← Newer
  • 1
  • ...
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • ...
  • 175
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.