[S] Change in pysim[master]: Allow logger to do lazy evaluation of format strings

2024-01-07 Thread fixeria
Attention is currently required from: laforge.

fixeria has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/35495?usp=email )

Change subject: Allow logger to do lazy evaluation of format strings
..


Patch Set 4: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35495?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: I39d26cdd5b85a61a06fd8c7a9d0a046e398819bd
Gerrit-Change-Number: 35495
Gerrit-PatchSet: 4
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Attention: laforge 
Gerrit-Comment-Date: Sun, 07 Jan 2024 21:34:55 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


[L] Change in pysim[master]: Add pySim.esim.bsp module implementing BSP (BPP Protection Protocol)

2024-01-07 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/pysim/+/35488?usp=email )

Change subject: Add pySim.esim.bsp module implementing BSP (BPP Protection 
Protocol)
..

Add pySim.esim.bsp module implementing BSP (BPP Protection Protocol)

This is the protocol used for the ES8+ interface between SM-DP+ and the
eUICC in the GSMA eSIM system.

Change-Id: Ic461936f2e68e1e6f7faab33d06acf3063e261e7
---
A pySim/esim/__init__.py
A pySim/esim/bsp.py
M requirements.txt
A tests/test_esim_bsp.py
4 files changed, 382 insertions(+), 0 deletions(-)

Approvals:
  Jenkins Builder: Verified
  fixeria: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved




diff --git a/pySim/esim/__init__.py b/pySim/esim/__init__.py
new file mode 100644
index 000..e69de29
--- /dev/null
+++ b/pySim/esim/__init__.py
diff --git a/pySim/esim/bsp.py b/pySim/esim/bsp.py
new file mode 100644
index 000..cf2104a
--- /dev/null
+++ b/pySim/esim/bsp.py
@@ -0,0 +1,297 @@
+# Early proof-of-concept implementation of
+# GSMA eSIM RSP (Remote SIM Provisioning BSP (BPP Protection Protocol),
+# where BPP is the Bound  Profile Package.  So the full expansion is the
+# "GSMA eSIM Remote SIM Provisioning Bound Profile Packate Protection Protocol"
+#
+# Originally (SGP.22 v2.x) this was called SCP03t, but it has since been
+# renamed to BSP.
+#
+# (C) 2023 by Harald Welte 
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see .
+
+# SGP.22 v3.0 Section 2.5.3:
+# That block of data is split into segments of a maximum size of 1020 bytes 
(including the tag, length field and MAC).
+MAX_SEGMENT_SIZE = 1020
+
+import abc
+from typing import List
+import logging
+
+# for BSP key derivation
+from cryptography.hazmat.primitives import hashes
+from cryptography.hazmat.primitives.kdf.x963kdf import X963KDF
+
+from Cryptodome.Cipher import AES
+from Cryptodome.Hash import CMAC
+
+from pySim.utils import bertlv_encode_len, bertlv_parse_one, b2h
+
+# don't log by default
+logger = logging.getLogger(__name__)
+logger.addHandler(logging.NullHandler())
+
+class BspAlgo(abc.ABC):
+blocksize: int
+
+def _get_padding(self, in_len: int, multiple: int, padding: int = 0) -> 
bytes:
+"""Return padding bytes towards multiple of N."""
+if in_len % multiple == 0:
+return b''
+pad_cnt = multiple - (in_len % multiple)
+return b'\x00' * pad_cnt
+
+def _pad_to_multiple(self, indat: bytes, multiple: int, padding: int = 0) 
-> bytes:
+"""Pad the input data to multiples of 'multiple'."""
+return indat + self._get_padding(len(indat), self.blocksize, padding)
+
+def __str__(self):
+return self.__class__.__name__
+
+class BspAlgoCrypt(BspAlgo, abc.ABC):
+
+def __init__(self, s_enc: bytes):
+self.s_enc = s_enc
+self.block_nr = 1
+
+def encrypt(self, data:bytes) -> bytes:
+"""Encrypt given input bytes using the key material given in 
constructor."""
+padded_data = self._pad_to_multiple(data, self.blocksize)
+block_nr = self.block_nr
+ciphertext = self._encrypt(padded_data)
+logger.debug("encrypt(block_nr=%u, s_enc=%s, plaintext=%s, padded=%s) 
-> %s",
+ block_nr, b2h(self.s_enc), b2h(data), b2h(padded_data), 
b2h(ciphertext))
+return ciphertext
+
+def decrypt(self, data:bytes) -> bytes:
+"""Decrypt given input bytes using the key material given in 
constructor."""
+return self._unpad(self._decrypt(data))
+
+@abc.abstractmethod
+def _unpad(self, padded: bytes) -> bytes:
+"""Remove the padding from padded data."""
+pass
+
+@abc.abstractmethod
+def _encrypt(self, data:bytes) -> bytes:
+"""Actual implementation, to be implemented by derived class."""
+pass
+
+@abc.abstractmethod
+def _decrypt(self, data:bytes) -> bytes:
+"""Actual implementation, to be implemented by derived class."""
+pass
+
+class BspAlgoCryptAES128(BspAlgoCrypt):
+name = 'AES-CBC-128'
+blocksize = 16
+
+def _get_padding(self, in_len: int, multiple: int, padding: int = 0):
+# SGP.22 section 2.6.4.4
+# Append a byte with value '80' to the right of the data block;
+# Append 0 to 15 bytes with value '00' so that 

[M] Change in pysim[master]: ts_102_310: Add file definitions resembling ETSI TS 102 310 (EAP)

2024-01-07 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/pysim/+/35486?usp=email )

Change subject: ts_102_310: Add file definitions resembling ETSI TS 102 310 
(EAP)
..

ts_102_310: Add file definitions resembling ETSI TS 102 310 (EAP)

The definitions are not used yet, as one would have to add that
dynamically based on which EF.DIR entries contain the 0x73 discretionary
template.  As I don't have any cards implementing this so far, I'll skip
that part.

Change-Id: I532ff2c94021ab1b4520fe2b6988c8960319d208
---
A pySim/ts_102_310.py
1 file changed, 128 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/ts_102_310.py b/pySim/ts_102_310.py
new file mode 100644
index 000..ea3a448
--- /dev/null
+++ b/pySim/ts_102_310.py
@@ -0,0 +1,114 @@
+# coding=utf-8
+"""Utilities / Functions related to ETSI TS 102 310, the EAP UICC spec.
+
+(C) 2024 by Harald Welte 
+
+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
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see .
+"""
+
+from pySim.construct import *
+from construct import *
+from construct import Optional as COptional
+
+#from pySim.utils import *
+from pySim.filesystem import CardDF, TransparentEF
+from pySim.tlv import BER_TLV_IE, TLV_IE_Collection
+
+# TS102 310 Section 7.1
+class EF_EAPKEYS(TransparentEF):
+class Msk(BER_TLV_IE, tag=0x80):
+_construct = HexAdapter(GreedyBytes)
+class Emsk(BER_TLV_IE, tag=0x81):
+_construct = HexAdapter(GreedyBytes)
+class MskCollection(TLV_IE_Collection, nested=[EF_EAPKEYS.Msk, 
EF_EAPKEYS.Emsk]):
+pass
+
+def __init__(self, fid='4f01', name='EF.EAPKEYS', desc='EAP derived keys'):
+super().__init__(fid, sfid=0x01, name=name, desc=desc, size=(1,None))
+self._tlv = EF_EAPKEYS.MskCollection
+
+# TS 102 310 Section 7.2
+class EF_EAPSTATUS(TransparentEF):
+def __init__(self, fid='4f02', name='EF.EAPSTATUS', desc='EAP 
Authentication Status'):
+super().__init__(fid, sfid=0x02, name=name, desc=desc, size=(1,1))
+self._construct = Enum(Int8ub, no_auth_started=0, authenticating=1,
+   authenticated=2, held_auth_failure=3)
+
+# TS 102 310 Section 7.3
+class EF_PUId(TransparentEF):
+def __init__(self, fid='4f03', name='EF.PUId', desc='Permanent User 
Identity'):
+super().__init__(fid, sfid=0x03, name=name, desc=desc, size=(10,None))
+self._construct = GreedyBytes
+
+# TS 102 310 Section 7.4
+class EF_Ps(TransparentEF):
+def __init__(self, fid='4f04', name='EF.Ps', desc='Pseudonym'):
+super().__init__(fid, sfid=0x04, name=name, desc=desc, size=(1,None))
+self._construct = GreedyBytes
+
+# TS 102 310 Section 7.5
+class EF_CurID(TransparentEF):
+def __init__(self, fid='4f20', name='EF.CurID', desc='Current Identity'):
+super().__init__(fid, sfid=0x10, name=name, desc=desc, size=(1,None))
+self._construct = Struct('type'/Enum(Int8ub, permanent=0, pseudonym=1, 
re_authentication=2, should_not_be_revealed=255),
+ '_len'/Int8ub,
+ 'value'/Utf8Adapter(this._len))
+
+
+# TS 102 310 Section 7.6
+class EF_ReID(TransparentEF):
+class Identity(BER_TLV_IE, tag=0x80):
+_construct = Utf8Adapter(GreedyBytes)
+class Counter(BER_TLV_IE, tag=0x81):
+_construct = GreedyInteger
+class Collection(TLV_IE_Collection, nested=[EF_ReID.Identity, 
EF_ReID.Counter]):
+pass
+
+def __init__(self, fid='4f21', name='EF.ReID', desc='Re-Authentication 
Identity'):
+super().__init__(fid, sfid=0x11, name=name, desc=desc, size=(1,None))
+self._tlv = EF_ReID.Collection
+
+# TS 102 310 Section 7.7
+class EF_Realm(TransparentEF):
+def __init__(self, fid='4f22', name='EF.Realm', desc='Relm value of the 
identity'):
+super().__init__(fid, sfid=0x12, name=name, desc=desc, size=(1,None))
+self._construct = Struct('_len'/Int8ub,
+ 'realm'/Utf8Adapter(Bytes(this._len)))
+
+class DF_EAP(CardDF):
+# DF.EAP has no default FID; it always must be discovered via the EF.DIR 
entry
+# and the 0x73 "discretionary template"
+def __init__(self, fid, name='DF.EAP', desc='EAP client', **kwargs):
+super().__init__(fid=fid, 

[L] Change in pysim[master]: Add pySim.esim.bsp module implementing BSP (BPP Protection Protocol)

2024-01-07 Thread laforge
Attention is currently required from: dexter.

laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/35488?usp=email )

Change subject: Add pySim.esim.bsp module implementing BSP (BPP Protection 
Protocol)
..


Patch Set 5: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35488?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: Ic461936f2e68e1e6f7faab33d06acf3063e261e7
Gerrit-Change-Number: 35488
Gerrit-PatchSet: 5
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: laforge 
Gerrit-Attention: dexter 
Gerrit-Comment-Date: Sun, 07 Jan 2024 19:42:17 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


[XL] Change in pysim[master]: Initial proof-of-concept SM-DP+ for GSMA consumer eSIM RSP

2024-01-07 Thread Jenkins Builder
Attention is currently required from: dexter, fixeria, lynxis lazus.

Jenkins Builder has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/35461?usp=email )

Change subject: Initial proof-of-concept SM-DP+ for GSMA consumer eSIM RSP
..


Patch Set 10:

(1 comment)

File docs/osmo-smdpp.rst:

Robot Comment from checkpatch (run ID jenkins-gerrit-lint-13488):
https://gerrit.osmocom.org/c/pysim/+/35461/comment/0a44c5aa_03117f5a
PS10, Line 7: At least at this point, it is intended to be used for reasearch 
and development, and not as a
'reasearch' may be misspelled - perhaps 'research'?



--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35461?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: I6232847432dc6920cd2bd08c84d7099c29ca1c11
Gerrit-Change-Number: 35461
Gerrit-PatchSet: 10
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: lynxis lazus 
Gerrit-Attention: fixeria 
Gerrit-Attention: lynxis lazus 
Gerrit-Attention: dexter 
Gerrit-Comment-Date: Sun, 07 Jan 2024 19:42:19 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment


[M] Change in pysim[master]: ts_102_310: Add file definitions resembling ETSI TS 102 310 (EAP)

2024-01-07 Thread laforge
Attention is currently required from: dexter.

laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/35486?usp=email )

Change subject: ts_102_310: Add file definitions resembling ETSI TS 102 310 
(EAP)
..


Patch Set 4: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35486?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: I532ff2c94021ab1b4520fe2b6988c8960319d208
Gerrit-Change-Number: 35486
Gerrit-PatchSet: 4
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: laforge 
Gerrit-Attention: dexter 
Gerrit-Comment-Date: Sun, 07 Jan 2024 19:42:07 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


[XL] Change in pysim[master]: Initial proof-of-concept SM-DP+ for GSMA consumer eSIM RSP

2024-01-07 Thread laforge
Attention is currently required from: dexter, fixeria, lynxis lazus.

Hello Jenkins Builder, dexter, fixeria, lynxis lazus,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/pysim/+/35461?usp=email

to look at the new patch set (#10).

The following approvals got outdated and were removed:
Verified+1 by Jenkins Builder


Change subject: Initial proof-of-concept SM-DP+ for GSMA consumer eSIM RSP
..

Initial proof-of-concept SM-DP+ for GSMA consumer eSIM RSP

This commit introduces

* the osmo-smdpp.py program implementing the main procedures and the
  HTTP/REST based ES9+
* python modules for ES8+ and non-volatile RSP Session State storage
* the ASN.1 source files required to parse/encode RSP
* 3GPP test certificates from SGP.26
* an unsigned profile package (UPP) of a SAIP v2.3 TS48 test profile

As I couldn't get the 'Klein' tls support to work, the SM-DP+ code
currently does not support HTTPS/TLS but plan HTTP, so you either have
to modify your LPA to use HTTP instead of HTTPS, or put a TLS proxy in
front.

I have successfully installed an eSIM profile on a test eUICC that
contains certificate/key data within the test CI defined in GSMA SGP.26

Change-Id: I6232847432dc6920cd2bd08c84d7099c29ca1c11
---
A .checkpatch.conf
M docs/index.rst
A docs/osmo-smdpp.rst
A osmo-smdpp.py
M pySim/esim/__init__.py
A pySim/esim/asn1/rsp/PKIX1Explicit88.asn
A pySim/esim/asn1/rsp/PKIX1Implicit88.asn
A pySim/esim/asn1/rsp/rsp.asn
A pySim/esim/es8p.py
A pySim/esim/rsp.py
M requirements.txt
A smdpp-data/certs/CertificateIssuer/CERT_CI_ECDSA_BRP.der
A smdpp-data/certs/CertificateIssuer/CERT_CI_ECDSA_BRP.pem
A smdpp-data/certs/CertificateIssuer/CERT_CI_ECDSA_NIST.der
A smdpp-data/certs/CertificateIssuer/CERT_CI_ECDSA_NIST.pem
A smdpp-data/certs/CertificateIssuer/CI-csr.cnf
A smdpp-data/certs/DPauth/CERT_S_SM_DP2auth_ECDSA_BRP.der
A smdpp-data/certs/DPauth/CERT_S_SM_DP2auth_ECDSA_NIST.der
A smdpp-data/certs/DPauth/CERT_S_SM_DPauth_ECDSA_BRP.der
A smdpp-data/certs/DPauth/CERT_S_SM_DPauth_ECDSA_NIST.der
A smdpp-data/certs/DPauth/PK_S_SM_DP2auth_ECDSA_BRP.pem
A smdpp-data/certs/DPauth/PK_S_SM_DP2auth_ECDSA_NIST.pem
A smdpp-data/certs/DPauth/PK_S_SM_DPauth_ECDSA_BRP.pem
A smdpp-data/certs/DPauth/PK_S_SM_DPauth_ECDSA_NIST.pem
A smdpp-data/certs/DPauth/SK_S_SM_DP2auth_ECDSA_BRP.pem
A smdpp-data/certs/DPauth/SK_S_SM_DP2auth_ECDSA_NIST.pem
A smdpp-data/certs/DPauth/SK_S_SM_DPauth_ECDSA_BRP.pem
A smdpp-data/certs/DPauth/SK_S_SM_DPauth_ECDSA_NIST.pem
A smdpp-data/certs/DPauth/data_sig.der
A smdpp-data/certs/DPpb/CERT_S_SM_DP2pb_ECDSA_BRP.der
A smdpp-data/certs/DPpb/CERT_S_SM_DP2pb_ECDSA_NIST.der
A smdpp-data/certs/DPpb/CERT_S_SM_DPpb_ECDSA_BRP.der
A smdpp-data/certs/DPpb/CERT_S_SM_DPpb_ECDSA_NIST.der
A smdpp-data/certs/DPpb/PK_S_SM_DP2pb_ECDSA_BRP.pem
A smdpp-data/certs/DPpb/PK_S_SM_DP2pb_ECDSA_NIST.pem
A smdpp-data/certs/DPpb/PK_S_SM_DPpb_ECDSA_BRP.pem
A smdpp-data/certs/DPpb/PK_S_SM_DPpb_ECDSA_NIST.pem
A smdpp-data/certs/DPpb/SK_S_SM_DP2pb_ECDSA_BRP.pem
A smdpp-data/certs/DPpb/SK_S_SM_DP2pb_ECDSA_NIST.pem
A smdpp-data/certs/DPpb/SK_S_SM_DPpb_ECDSA_BRP.pem
A smdpp-data/certs/DPpb/SK_S_SM_DPpb_ECDSA_NIST.pem
A smdpp-data/certs/DPtls/CERT_S_SM_DP2_TLS.csr.cnf
A smdpp-data/certs/DPtls/CERT_S_SM_DP2_TLS.der
A smdpp-data/certs/DPtls/CERT_S_SM_DP2_TLS.ext.cnf
A smdpp-data/certs/DPtls/CERT_S_SM_DP4_TLS.csr.cnf
A smdpp-data/certs/DPtls/CERT_S_SM_DP4_TLS.der
A smdpp-data/certs/DPtls/CERT_S_SM_DP4_TLS.ext.cnf
A smdpp-data/certs/DPtls/CERT_S_SM_DP8_TLS.csr.cnf
A smdpp-data/certs/DPtls/CERT_S_SM_DP8_TLS.der
A smdpp-data/certs/DPtls/CERT_S_SM_DP8_TLS.ext.cnf
A smdpp-data/certs/DPtls/CERT_S_SM_DP_TLS.csr.cnf
A smdpp-data/certs/DPtls/CERT_S_SM_DP_TLS.ext.cnf
A smdpp-data/certs/DPtls/CERT_S_SM_DP_TLS_BRP.der
A smdpp-data/certs/DPtls/CERT_S_SM_DP_TLS_NIST.der
A smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2021/CERT_S_SM_DP2_TLS.der
A smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2021/CERT_S_SM_DP4_TLS.der
A smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2021/CERT_S_SM_DP8_TLS.der
A smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2021/CERT_S_SM_DP_TLS_BRP.der
A smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2021/CERT_S_SM_DP_TLS_NIST.der
A smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2022/CERT_S_SM_DP2_TLS.der
A smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2022/CERT_S_SM_DP4_TLS.der
A smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2022/CERT_S_SM_DP8_TLS.der
A smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2022/CERT_S_SM_DP_TLS_BRP.der
A smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2022/CERT_S_SM_DP_TLS_NIST.der
A smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2023/CERT_S_SM_DP2_TLS.der
A smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2023/CERT_S_SM_DP4_TLS.der
A smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2023/CERT_S_SM_DP8_TLS.der
A smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2023/CERT_S_SM_DP_TLS_BRP.der
A 

[XL] Change in pysim[master]: Initial proof-of-concept SM-DP+ for GSMA consumer eSIM RSP

2024-01-07 Thread laforge
Attention is currently required from: dexter, fixeria, lynxis lazus.

Hello Jenkins Builder, dexter, fixeria, lynxis lazus,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/pysim/+/35461?usp=email

to look at the new patch set (#9).

The following approvals got outdated and were removed:
Verified+1 by Jenkins Builder


Change subject: Initial proof-of-concept SM-DP+ for GSMA consumer eSIM RSP
..

Initial proof-of-concept SM-DP+ for GSMA consumer eSIM RSP

This commit introduces

* the osmo-smdpp.py program implementing the main procedures and the
  HTTP/REST based ES9+
* python modules for ES8+ and non-volatile RSP Session State storage
* the ASN.1 source files required to parse/encode RSP
* 3GPP test certificates from SGP.26
* an unsigned profile package (UPP) of a SAIP v2.3 TS48 test profile

As I couldn't get the 'Klein' tls support to work, the SM-DP+ code
currently does not support HTTPS/TLS but plan HTTP, so you either have
to modify your LPA to use HTTP instead of HTTPS, or put a TLS proxy in
front.

I have successfully installed an eSIM profile on a test eUICC that
contains certificate/key data within the test CI defined in GSMA SGP.26

Change-Id: I6232847432dc6920cd2bd08c84d7099c29ca1c11
---
A .checkpatch.conf
A osmo-smdpp.py
M pySim/esim/__init__.py
A pySim/esim/asn1/rsp/PKIX1Explicit88.asn
A pySim/esim/asn1/rsp/PKIX1Implicit88.asn
A pySim/esim/asn1/rsp/rsp.asn
A pySim/esim/es8p.py
A pySim/esim/rsp.py
M requirements.txt
A smdpp-data/certs/CertificateIssuer/CERT_CI_ECDSA_BRP.der
A smdpp-data/certs/CertificateIssuer/CERT_CI_ECDSA_BRP.pem
A smdpp-data/certs/CertificateIssuer/CERT_CI_ECDSA_NIST.der
A smdpp-data/certs/CertificateIssuer/CERT_CI_ECDSA_NIST.pem
A smdpp-data/certs/CertificateIssuer/CI-csr.cnf
A smdpp-data/certs/DPauth/CERT_S_SM_DP2auth_ECDSA_BRP.der
A smdpp-data/certs/DPauth/CERT_S_SM_DP2auth_ECDSA_NIST.der
A smdpp-data/certs/DPauth/CERT_S_SM_DPauth_ECDSA_BRP.der
A smdpp-data/certs/DPauth/CERT_S_SM_DPauth_ECDSA_NIST.der
A smdpp-data/certs/DPauth/PK_S_SM_DP2auth_ECDSA_BRP.pem
A smdpp-data/certs/DPauth/PK_S_SM_DP2auth_ECDSA_NIST.pem
A smdpp-data/certs/DPauth/PK_S_SM_DPauth_ECDSA_BRP.pem
A smdpp-data/certs/DPauth/PK_S_SM_DPauth_ECDSA_NIST.pem
A smdpp-data/certs/DPauth/SK_S_SM_DP2auth_ECDSA_BRP.pem
A smdpp-data/certs/DPauth/SK_S_SM_DP2auth_ECDSA_NIST.pem
A smdpp-data/certs/DPauth/SK_S_SM_DPauth_ECDSA_BRP.pem
A smdpp-data/certs/DPauth/SK_S_SM_DPauth_ECDSA_NIST.pem
A smdpp-data/certs/DPauth/data_sig.der
A smdpp-data/certs/DPpb/CERT_S_SM_DP2pb_ECDSA_BRP.der
A smdpp-data/certs/DPpb/CERT_S_SM_DP2pb_ECDSA_NIST.der
A smdpp-data/certs/DPpb/CERT_S_SM_DPpb_ECDSA_BRP.der
A smdpp-data/certs/DPpb/CERT_S_SM_DPpb_ECDSA_NIST.der
A smdpp-data/certs/DPpb/PK_S_SM_DP2pb_ECDSA_BRP.pem
A smdpp-data/certs/DPpb/PK_S_SM_DP2pb_ECDSA_NIST.pem
A smdpp-data/certs/DPpb/PK_S_SM_DPpb_ECDSA_BRP.pem
A smdpp-data/certs/DPpb/PK_S_SM_DPpb_ECDSA_NIST.pem
A smdpp-data/certs/DPpb/SK_S_SM_DP2pb_ECDSA_BRP.pem
A smdpp-data/certs/DPpb/SK_S_SM_DP2pb_ECDSA_NIST.pem
A smdpp-data/certs/DPpb/SK_S_SM_DPpb_ECDSA_BRP.pem
A smdpp-data/certs/DPpb/SK_S_SM_DPpb_ECDSA_NIST.pem
A smdpp-data/certs/DPtls/CERT_S_SM_DP2_TLS.csr.cnf
A smdpp-data/certs/DPtls/CERT_S_SM_DP2_TLS.der
A smdpp-data/certs/DPtls/CERT_S_SM_DP2_TLS.ext.cnf
A smdpp-data/certs/DPtls/CERT_S_SM_DP4_TLS.csr.cnf
A smdpp-data/certs/DPtls/CERT_S_SM_DP4_TLS.der
A smdpp-data/certs/DPtls/CERT_S_SM_DP4_TLS.ext.cnf
A smdpp-data/certs/DPtls/CERT_S_SM_DP8_TLS.csr.cnf
A smdpp-data/certs/DPtls/CERT_S_SM_DP8_TLS.der
A smdpp-data/certs/DPtls/CERT_S_SM_DP8_TLS.ext.cnf
A smdpp-data/certs/DPtls/CERT_S_SM_DP_TLS.csr.cnf
A smdpp-data/certs/DPtls/CERT_S_SM_DP_TLS.ext.cnf
A smdpp-data/certs/DPtls/CERT_S_SM_DP_TLS_BRP.der
A smdpp-data/certs/DPtls/CERT_S_SM_DP_TLS_NIST.der
A smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2021/CERT_S_SM_DP2_TLS.der
A smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2021/CERT_S_SM_DP4_TLS.der
A smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2021/CERT_S_SM_DP8_TLS.der
A smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2021/CERT_S_SM_DP_TLS_BRP.der
A smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2021/CERT_S_SM_DP_TLS_NIST.der
A smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2022/CERT_S_SM_DP2_TLS.der
A smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2022/CERT_S_SM_DP4_TLS.der
A smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2022/CERT_S_SM_DP8_TLS.der
A smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2022/CERT_S_SM_DP_TLS_BRP.der
A smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2022/CERT_S_SM_DP_TLS_NIST.der
A smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2023/CERT_S_SM_DP2_TLS.der
A smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2023/CERT_S_SM_DP4_TLS.der
A smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2023/CERT_S_SM_DP8_TLS.der
A smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2023/CERT_S_SM_DP_TLS_BRP.der
A smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 

[S] Change in pysim[master]: euicc: Fix eUICC list_notifications command

2024-01-07 Thread laforge
laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/pysim/+/35498?usp=email )


Change subject: euicc: Fix eUICC list_notifications command
..

euicc: Fix eUICC list_notifications command

Prior to this patch, the command would always raise exceptions.

Change-Id: I75a7840c3f4b68bfc164a43908b100dd6e41e575
---
M pySim/euicc.py
1 file changed, 15 insertions(+), 3 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/98/35498/1

diff --git a/pySim/euicc.py b/pySim/euicc.py
index e45476f..e405f30 100644
--- a/pySim/euicc.py
+++ b/pySim/euicc.py
@@ -141,12 +141,13 @@

 # SGP.22 Section 5.7.9: ListNotification
 class ProfileMgmtOperation(BER_TLV_IE, tag=0x81):
-_construct = FlagsEnum(Byte, install=1, enable=2, disable=4, delete=8)
+# we have to ignore the first byte which tells us how many padding bits 
are used in the last octet
+_construct = Struct(Byte, "pmo"/FlagsEnum(Byte, install=0x80, enable=0x40, 
disable=0x20, delete=0x10))
 class ListNotificationReq(BER_TLV_IE, tag=0xbf28, 
nested=[ProfileMgmtOperation]):
 pass
 class SeqNumber(BER_TLV_IE, tag=0x80):
-_construct = GreedyInteger
-class NotificationAddress(BER_TLV_IE, tag=0x82):
+_construct = GreedyInteger()
+class NotificationAddress(BER_TLV_IE, tag=0x0c):
 _construct = Utf8Adapter(GreedyBytes)
 class Iccid(BER_TLV_IE, tag=0x5a):
 _construct = BcdAdapter(GreedyBytes)

--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35498?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: I75a7840c3f4b68bfc164a43908b100dd6e41e575
Gerrit-Change-Number: 35498
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-MessageType: newchange


[M] Change in pysim[master]: pySim-shell: Update manual with examples for using with eUICC ISD-R

2024-01-07 Thread laforge
laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/pysim/+/35499?usp=email )


Change subject: pySim-shell: Update manual with examples for using with eUICC 
ISD-R
..

pySim-shell: Update manual with examples for using with eUICC ISD-R

Change-Id: I4a0acdad5c7478ee76f92c7610c0e2a5331dea46
---
M docs/shell.rst
1 file changed, 215 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/99/35499/1

diff --git a/docs/shell.rst b/docs/shell.rst
index 313d6d9..4742b8e 100644
--- a/docs/shell.rst
+++ b/docs/shell.rst
@@ -942,7 +942,7 @@
 * open a new logical channel (and start to use it)
 * select the ISD-R application

-::
+Example::

   pySIM-shell (00:MF)> open_channel 2
   pySIM-shell (00:MF)> switch_channel 2
@@ -973,6 +973,13 @@

 Obtain the configured SM-DP+ and/or SM-DS addresses using the ES10a 
GetEuiccConfiguredAddresses() function.

+Example::
+
+  pySIM-shell (00:MF/ADF.ISD-R)> get_euicc_configured_addresses
+  {
+  "root_ds_address": "testrootsmds.gsma.com"
+  }
+
 set_default_dp_address
 ~~

@@ -985,21 +992,137 @@

 Obtain an authentication challenge from the eUICC using the ES10b 
GetEUICCChallenge() function.

+Example::
+
+  pySIM-shell (00:MF/ADF.ISD-R)> get_euicc_challenge
+  {
+  "euicc_challenge": "3668f20d4e6c8e85609bbca8c14873fd"
+  }
+
 get_euicc_info1
 ~~~

 Obtain EUICC Information (1) from the eUICC using the ES10b GetEUICCCInfo() 
function.

+Example::
+
+  pySIM-shell (00:MF/ADF.ISD-R)> get_euicc_info1
+  {
+  "svn": "2.2.0",
+  "euicc_ci_pki_list_for_verification": [
+  {
+  "subject_key_identifier_seq": {
+  "unknown_ber_tlv_ie_c0": null
+  }
+  },
+  {
+  "subject_key_identifier_seq": {
+  "unknown_ber_tlv_ie_f5": {
+  "raw": "72bdf98a95d65cbeb88a38a1c11d800a85c3"
+  }
+  }
+  }
+  ],
+  "euicc_ci_pki_list_for_signing": [
+  {
+  "subject_key_identifier_seq": {
+  "unknown_ber_tlv_ie_c0": null
+  }
+  },
+  {
+  "subject_key_identifier_seq": {
+  "unknown_ber_tlv_ie_f5": {
+  "raw": "72bdf98a95d65cbeb88a38a1c11d800a85c3"
+  }
+  }
+  }
+  ]
+  }
+
+
 get_euicc_info2
 ~~~

 Obtain EUICC Information (2) from the eUICC using the ES10b GetEUICCCInfo() 
function.

+Example::
+
+  pySIM-shell (00:MF/ADF.ISD-R)> get_euicc_info2
+  {
+  "profile_version": "2.1.0",
+  "svn": "2.2.0",
+  "euicc_firmware_ver": "4.4.0",
+  "ext_card_resource": "81010082040006ddc6830416e0",
+  "uicc_capability": "067f36c0",
+  "ts102241_version": "9.2.0",
+  "global_platform_version": "2.3.0",
+  "rsp_capability": "0490",
+  "euicc_ci_pki_list_for_verification": [
+  {
+  "subject_key_identifier_seq": {
+  "unknown_ber_tlv_ie_c0": null
+  }
+  },
+  {
+  "subject_key_identifier_seq": {
+  "unknown_ber_tlv_ie_f5": {
+  "raw": "72bdf98a95d65cbeb88a38a1c11d800a85c3"
+  }
+  }
+  }
+  ],
+  "euicc_ci_pki_list_for_signing": [
+  {
+  "subject_key_identifier_seq": {
+  "unknown_ber_tlv_ie_c0": null
+  }
+  },
+  {
+  "subject_key_identifier_seq": {
+  "unknown_ber_tlv_ie_f5": {
+  "raw": "72bdf98a95d65cbeb88a38a1c11d800a85c3"
+  }
+  }
+  }
+  ],
+  "unknown_ber_tlv_ie_99": {
+  "raw": "06c0"
+  },
+  "pp_version": "0.0.1",
+  "ss_acreditation_number": "G",
+  "unknown_ber_tlv_ie_ac": {
+  "raw": 
"801f312e322e3834302e313233343536372f6d79506c6174666f726d4c6162656c812568747470733a2f2f6d79636f6d70616e792e636f6d2f6d79444c4f41526567697374726172"
+  }
+  }
+
+
 list_notification
 ~

 Obtain the list of notifications from the eUICC using the ES10b 
ListNotification() function.

+Example::
+
+  pySIM-shell (00:MF/ADF.ISD-R)> list_notification
+  {
+  "notification_metadata_list": {
+  "notification_metadata": {
+  "seq_number": 61,
+  "profile_mgmt_operation": {
+  "pmo": {
+  "install": true,
+  "enable": false,
+  "disable": false,
+  "delete": false
+  }
+  },
+  "notification_address": "testsmdpplus1.example.com",
+  "iccid": "89000123456789012358"
+  }
+  }
+  }
+
+
 remove_notification_from_list
 ~

@@ -1007,11 

[S] Change in pysim[master]: euicc: Fix delete_profile command

2024-01-07 Thread laforge
laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/pysim/+/35497?usp=email )


Change subject: euicc: Fix delete_profile command
..

euicc: Fix delete_profile command

Contrary to {enable,disable}_profile, the delete_profile does not use
the ProfileIdentifier TLV, but directly the Iccid / IsdpAid.

Change-Id: I43e298524048703264e16cbdd0b76d82ba976985
---
M pySim/euicc.py
1 file changed, 15 insertions(+), 3 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/97/35497/1

diff --git a/pySim/euicc.py b/pySim/euicc.py
index 19b1c57..e45476f 100644
--- a/pySim/euicc.py
+++ b/pySim/euicc.py
@@ -231,7 +231,7 @@
 class DeleteResult(BER_TLV_IE, tag=0x80):
 _construct = Enum(Int8ub, ok=0, iccidOrAidNotFound=1, 
profileNotInDisabledState=2,
   disallowedByPolicy=3, undefinedError=127)
-class DeleteProfileReq(BER_TLV_IE, tag=0xbf33, nested=[ProfileIdentifier]):
+class DeleteProfileReq(BER_TLV_IE, tag=0xbf33, nested=[IsdpAid, Iccid]):
 pass
 class DeleteProfileResp(BER_TLV_IE, tag=0xbf33, nested=[DeleteResult]):
 pass
@@ -444,9 +444,9 @@
 def do_delete_profile(self, opts):
 """Perform an ES10c DeleteProfile function."""
 if opts.isdp_aid:
-p_id = 
ProfileIdentifier(children=[IsdpAid(decoded=opts.isdp_aid)])
+p_id = IsdpAid(decoded=opts.isdp_aid)
 if opts.iccid:
-p_id = ProfileIdentifier(children=[Iccid(decoded=opts.iccid)])
+p_id = Iccid(decoded=opts.iccid)
 dp_cmd_contents = [p_id]
 dp_cmd = DeleteProfileReq(children=dp_cmd_contents)
 dp = ADF_ISDR.store_data_tlv(self._cmd.lchan.scc, dp_cmd, 
DeleteProfileResp)

--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35497?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: I43e298524048703264e16cbdd0b76d82ba976985
Gerrit-Change-Number: 35497
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-MessageType: newchange


[S] Change in pysim[master]: Allow logger to do lazy evaluation of format strings

2024-01-07 Thread laforge
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/+/35495?usp=email

to look at the new patch set (#2).

The following approvals got outdated and were removed:
Verified-1 by Jenkins Builder


Change subject: Allow logger to do lazy evaluation of format strings
..

Allow logger to do lazy evaluation of format strings

Change-Id: I39d26cdd5b85a61a06fd8c7a9d0a046e398819bd
---
M pySim-trace.py
M pySim/apdu/ts_102_221.py
M pySim/apdu_source/pyshark_rspro.py
3 files changed, 16 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/95/35495/2
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35495?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: I39d26cdd5b85a61a06fd8c7a9d0a046e398819bd
Gerrit-Change-Number: 35495
Gerrit-PatchSet: 2
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Attention: laforge 
Gerrit-MessageType: newpatchset


[L] Change in pysim[master]: Add pySim.esim.bsp module implementing BSP (BPP Protection Protocol)

2024-01-07 Thread fixeria
Attention is currently required from: dexter, laforge.

fixeria has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/35488?usp=email )

Change subject: Add pySim.esim.bsp module implementing BSP (BPP Protection 
Protocol)
..


Patch Set 5: Code-Review+1

(3 comments)

File pySim/esim/bsp.py:

https://gerrit.osmocom.org/c/pysim/+/35488/comment/6d4bdc1c_143ff193
PS4, Line 46: blocksize
> Assigning it during init would be wrong for any non-singleton, right?
> Those are, after all, class variables and not instance variables?

Ack. In this particular case it's indeed a class variable because it should not 
vary between instances of a child class. Fortunately, pylint does not complain 
about your change.


File tests/test_esim_bsp.py:

https://gerrit.osmocom.org/c/pysim/+/35488/comment/cad1f153_b2f3cf7c
PS4, Line 62: segment0 = 
h2b('a048800102810101821a53494d616c6c69616e63652053616d706c652050726f66696c65830a89000123456789012341a506810084008b00a610060667810f010201060667810f010204b08201f8a0058000810101810667810f010201a207a105c60301020aa305a1038b010fa40c830a98001032547698103214a527a109820442210026800198831a61184f10a000871002ff33ff0189010050045553494da682019ea10a8204422100258002022b831b8001019000800102a406830101950108800158a40683010a95010882010a8316800101a40683010195010880015aa40683010a95010882010f830b80015ba40683010a95010882011a830a800101900080015a970082011b8316800103a406830101950108800158a40683010a95010882010f8316800111a40683010195010880014aa40683010a95010882010f8321800103a406830101950108800158a40683010a950108840132a4068301019501088201048321800101a406830101950108800102a406830181950108800158a40683010a950108820104831b800101900080011aa406830101950108800140a40683010a95010882010a8310800101900080015aa40683010a95010882011583158001019000800118a40683010a95010880014297008201108310800101a40683010195010880015a97008201158316800113a406830101950108800148a40683010a95010882010f830b80015ea40683010a95010882011a83258001019000800102a010a406830101950108a406830102950108800158a40683010a950108a33fa0058000810102a13630118001018108303030303030303082020099300d800102810831323334353637383012800200818108313233343536373882020088a241a0058000810103a138a03630108001018108313233348201013010800102810830303030820102301080010a810835363738830101a182029ea0058000810104a18202933082028f62228202782183027ff18410a000871002ff33ff018901008b010ac60301810a62118202412183026f078b01028001098801388109082943019134876765621482044221002583026f068b010a8801b8c7022f06621a8202412183026f088b0105800121880140a507c00180c10207ff621a8202412183026f098b0105800121880148a507c00180c10207ff62168202412183026f318b0102800101880190a503c1010a62118202412183026f388b010280010e880120810d0a2e178ce73204621982044221001a83026f3b8b0108800202088800a504c10200ff62198204422100b083026f3c8b0105800206e08800a504c10200ff621282044221002683026f428b0105800126')
> I think it's too much effort (and potentially error prone) for test data that 
> is copy+pasted from so […]
Ack


https://gerrit.osmocom.org/c/pysim/+/35488/comment/7781fa09_76404f0d
PS4, Line 72:
> cosmetic: tabs vs spaces
Done



--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35488?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: Ic461936f2e68e1e6f7faab33d06acf3063e261e7
Gerrit-Change-Number: 35488
Gerrit-PatchSet: 5
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-Reviewer: fixeria 
Gerrit-Attention: laforge 
Gerrit-Attention: dexter 
Gerrit-Comment-Date: Sun, 07 Jan 2024 10:01:27 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: laforge 
Comment-In-Reply-To: fixeria 
Gerrit-MessageType: comment


[S] Change in libosmocore[master]: gsm48_ie: fix various issues in doxygen docs

2024-01-07 Thread fixeria
fixeria has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmocore/+/35496?usp=email )


Change subject: gsm48_ie: fix various issues in doxygen docs
..

gsm48_ie: fix various issues in doxygen docs

Change-Id: Id168c5115588b2dbc48605ee0bba13ccc9913bbe
---
M src/gsm/gsm48_ie.c
1 file changed, 17 insertions(+), 7 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/96/35496/1

diff --git a/src/gsm/gsm48_ie.c b/src/gsm/gsm48_ie.c
index bb86cf4..b95609f 100644
--- a/src/gsm/gsm48_ie.c
+++ b/src/gsm/gsm48_ie.c
@@ -44,10 +44,11 @@
 };

 /*! Like gsm48_decode_bcd_number2() but with less airtight bounds checking.
- *  \param[out] Caller-provided output buffer
+ *  \param[out] output Caller-provided output buffer
+ *  \param[in] output_len sizeof(output)
  *  \param[in] bcd_lv Length-Value portion of to-be-decoded IE
  *  \param[in] h_len Length of an optional heder between L and V portion
- *  \returns - in case of success; negative on error */
+ *  \returns 0 in case of success; negative on error */
 int gsm48_decode_bcd_number(char *output, int output_len,
const uint8_t *bcd_lv, int h_len)
 {
@@ -139,7 +140,7 @@
  *  \param[in] max_len Maximum Length of \a bcd_lv
  *  \param[in] h_len Length of an optional heder between L and V portion
  *  \param[in] input phone number as 0-terminated ASCII
- *  \returns number of bytes used in \a bcd_lv
+ *  \returns number of bytes used in \a bcd_lv; negative on error
  *
  * Depending on a context (e.g. called or calling party BCD number), the
  * optional header between L and V parts can contain TON (Type Of Number),
@@ -179,8 +180,8 @@
 }

 /*! Decode TS 04.08 Bearer Capability IE (10.5.4.5)
- *  \param[out] Caller-provided memory for decoded output
- *  \[aram[in] LV portion of TS 04.08 Bearer Capability
+ *  \param[out] bcap Caller-provided memory for decoded output
+ *  \param[in] lv LV portion of TS 04.08 Bearer Capability
  *  \returns 0 on success; negative on error */
 int gsm48_decode_bearer_cap(struct gsm_mncc_bearer_cap *bcap,
 const uint8_t *lv)
@@ -371,7 +372,7 @@
 }

 /*! Decode TS 04.08 Call Control Capabilities IE (10.5.4.5a)
- *  \param[out] Caller-provided memory for decoded CC capabilities
+ *  \param[out] ccap Caller-provided memory for decoded CC capabilities
  *  \param[in] lv Length-Value of IE
  *  \returns 0 on success; negative on error */
 int gsm48_decode_cccap(struct gsm_mncc_cccap *ccap, const uint8_t *lv)
@@ -457,7 +458,7 @@
 }

 /*! Decode TS 04.08 Caller ID
- *  \param[out] called Caller-provided memory for decoded number
+ *  \param[out] callerid Caller-provided memory for decoded number
  *  \param[in] lv Length-Value portion of IE
  *  \returns 0 on success; negative on error */
 int gsm48_decode_callerid(struct gsm_mncc_number *callerid,

--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35496?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: Id168c5115588b2dbc48605ee0bba13ccc9913bbe
Gerrit-Change-Number: 35496
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria 
Gerrit-MessageType: newchange


[L] Change in pysim[master]: Add pySim.esim.bsp module implementing BSP (BPP Protection Protocol)

2024-01-07 Thread laforge
Attention is currently required from: dexter, fixeria.

laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/35488?usp=email )

Change subject: Add pySim.esim.bsp module implementing BSP (BPP Protection 
Protocol)
..


Patch Set 4:

(11 comments)

File pySim/esim/bsp.py:

https://gerrit.osmocom.org/c/pysim/+/35488/comment/bec36162_9ad70d18 
PS4, Line 46: blocksize
> You can simply do a type declaration here: […]
My experience in other situations that if you don't assign it None, pylint will 
complain if you start using it in parent classes' methods (Even if 'abc.ABC').  
But I'll add the type annotation.

Assigning it during init would be wrong for any non-singleton, right? Those 
are, after all, class variables and not instance variables?


https://gerrit.osmocom.org/c/pysim/+/35488/comment/144d22a3_99b9f3e9
PS4, Line 47: enum_name
> unused?
Done


https://gerrit.osmocom.org/c/pysim/+/35488/comment/8aee4ba9_35d16cae
PS4, Line 60: __init__
> can be removed?
Done


https://gerrit.osmocom.org/c/pysim/+/35488/comment/c4994dd2_8cb6aa86
PS4, Line 95: abc.abstractmethod
> why commented out?
Done


https://gerrit.osmocom.org/c/pysim/+/35488/comment/d4e4be28_66905bae
PS4, Line 104: _get_padding
> Can we re-use the parent's implementation here? […]
Done


https://gerrit.osmocom.org/c/pysim/+/35488/comment/3c390d54_c6d60f21
PS4, Line 124: _get_icv
> Can we pre-calculate the ICV once (e.g. in `__init__()`) and then just use it 
> in `self. […]
_get_icv() depends on self.block_nr which increments every time you cal it.  So 
yes, the ICV changes for each block of encrypted/decrypted data and it cannot 
be pre-computed in __init__.


https://gerrit.osmocom.org/c/pysim/+/35488/comment/c8f95664_bce64647
PS4, Line 132: % (self.block_nr, b2h(data), b2h(icv
> JFYI: when using Python's logging, you can pass format string arguments 
> directly to the logging func […]
Done


https://gerrit.osmocom.org/c/pysim/+/35488/comment/d07ac98c_ab27ac32
PS4, Line 153: tag <= 255
> This still permits negative values, maybe `assert tag in range(256)`?
Done


https://gerrit.osmocom.org/c/pysim/+/35488/comment/7d074536_e71ce899
PS4, Line 299: return b''.join(plaintext_list)
> Maybe use list-comprehension here? […]
Done


https://gerrit.osmocom.org/c/pysim/+/35488/comment/87c5a559_7bffc6cf
PS4, Line 310: return b''.join(plaintext_list)
> Maybe use list-comprehension here? […]
I decided to make it two lines (but use list comprhension) to reduce complexity 
in one line.


File tests/test_esim_bsp.py:

https://gerrit.osmocom.org/c/pysim/+/35488/comment/0c6f30c1_21564414
PS4, Line 62: segment0 = 
h2b('a048800102810101821a53494d616c6c69616e63652053616d706c652050726f66696c65830a89000123456789012341a506810084008b00a610060667810f010201060667810f010204b08201f8a0058000810101810667810f010201a207a105c60301020aa305a1038b010fa40c830a98001032547698103214a527a109820442210026800198831a61184f10a000871002ff33ff0189010050045553494da682019ea10a8204422100258002022b831b8001019000800102a406830101950108800158a40683010a95010882010a8316800101a40683010195010880015aa40683010a95010882010f830b80015ba40683010a95010882011a830a800101900080015a970082011b8316800103a406830101950108800158a40683010a95010882010f8316800111a40683010195010880014aa40683010a95010882010f8321800103a406830101950108800158a40683010a950108840132a4068301019501088201048321800101a406830101950108800102a406830181950108800158a40683010a950108820104831b800101900080011aa406830101950108800140a40683010a95010882010a8310800101900080015aa40683010a95010882011583158001019000800118a40683010a95010880014297008201108310800101a40683010195010880015a97008201158316800113a406830101950108800148a40683010a95010882010f830b80015ea40683010a95010882011a83258001019000800102a010a406830101950108a406830102950108800158a40683010a950108a33fa0058000810102a13630118001018108303030303030303082020099300d800102810831323334353637383012800200818108313233343536373882020088a241a0058000810103a138a03630108001018108313233348201013010800102810830303030820102301080010a810835363738830101a182029ea0058000810104a18202933082028f62228202782183027ff18410a000871002ff33ff018901008b010ac60301810a62118202412183026f078b01028001098801388109082943019134876765621482044221002583026f068b010a8801b8c7022f06621a8202412183026f088b0105800121880140a507c00180c10207ff621a8202412183026f098b0105800121880148a507c00180c10207ff62168202412183026f318b0102800101880190a503c1010a62118202412183026f388b010280010e880120810d0a2e178ce73204621982044221001a83026f3b8b0108800202088800a504c10200ff62198204422100b083026f3c8b0105800206e08800a504c10200ff621282044221002683026f428b0105800126')
> not critical, but maybe use multi-line strings (`''' ... […]
I think it's too much effort (and potentially error prone) for test data that 
is copy+pasted from some logs.



--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35488?usp=email
To unsubscribe, or 

[L] Change in pysim[master]: Add pySim.esim.bsp module implementing BSP (BPP Protection Protocol)

2024-01-07 Thread laforge
Attention is currently required from: dexter, laforge.

Hello Jenkins Builder, dexter, fixeria,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/pysim/+/35488?usp=email

to look at the new patch set (#5).

The following approvals got outdated and were removed:
Verified+1 by Jenkins Builder


Change subject: Add pySim.esim.bsp module implementing BSP (BPP Protection 
Protocol)
..

Add pySim.esim.bsp module implementing BSP (BPP Protection Protocol)

This is the protocol used for the ES8+ interface between SM-DP+ and the
eUICC in the GSMA eSIM system.

Change-Id: Ic461936f2e68e1e6f7faab33d06acf3063e261e7
---
A pySim/esim/__init__.py
A pySim/esim/bsp.py
M requirements.txt
A tests/test_esim_bsp.py
4 files changed, 382 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/88/35488/5
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35488?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: Ic461936f2e68e1e6f7faab33d06acf3063e261e7
Gerrit-Change-Number: 35488
Gerrit-PatchSet: 5
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-Reviewer: fixeria 
Gerrit-Attention: laforge 
Gerrit-Attention: dexter 
Gerrit-MessageType: newpatchset


[S] Change in pysim[master]: Allow logger to do lazy evaluation of format strings

2024-01-07 Thread laforge
laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/pysim/+/35495?usp=email )


Change subject: Allow logger to do lazy evaluation of format strings
..

Allow logger to do lazy evaluation of format strings

Change-Id: I39d26cdd5b85a61a06fd8c7a9d0a046e398819bd
---
M pySim-trace.py
M pySim/apdu/ts_102_221.py
M pySim/apdu_source/pyshark_rspro.py
3 files changed, 16 insertions(+), 7 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/95/35495/1

diff --git a/pySim-trace.py b/pySim-trace.py
index eb29ed1..91f50a3 100755
--- a/pySim-trace.py
+++ b/pySim-trace.py
@@ -182,7 +182,7 @@

 opts = option_parser.parse_args()

-logger.info('Opening source %s...' % opts.source)
+logger.info('Opening source %s...', opts.source)
 if opts.source == 'gsmtap-udp':
 s = GsmtapApduSource(opts.bind_ip, opts.bind_port)
 elif opts.source == 'rspro-pyshark-pcap':
diff --git a/pySim/apdu/ts_102_221.py b/pySim/apdu/ts_102_221.py
index 2d3ad82..443ae1e 100644
--- a/pySim/apdu/ts_102_221.py
+++ b/pySim/apdu/ts_102_221.py
@@ -77,7 +77,7 @@
 pass
 # iterate to next element in path
 continue
-logger.warning('SELECT UNKNOWN FID %s (%s)' % (file_hex, 
'/'.join([b2h(x) for x in path])))
+logger.warning('SELECT UNKNOWN FID %s (%s)', file_hex, 
'/'.join([b2h(x) for x in path]))
 elif mode == 'df_ef_or_mf_by_file_id':
 if len(self.cmd_data) != 2:
 raise ValueError('Expecting a 2-byte FID')
@@ -91,7 +91,7 @@
 #print("\tSELECT %s FAILED" % sels[file_hex])
 pass
 else:
-logger.warning('SELECT UNKNOWN FID %s' % (file_hex))
+logger.warning('SELECT UNKNOWN FID %s', file_hex)
 elif mode == 'df_name':
 # Select by AID (can be sub-string!)
 aid = self.cmd_dict['body']
@@ -102,7 +102,7 @@
 lchan.selected_file = lchan.selected_adf
 #print("\tSELECT AID %s" % adf)
 else:
-logger.warning('SELECT UNKNOWN AID %s' % aid)
+logger.warning('SELECT UNKNOWN AID %s', aid)
 pass
 else:
 raise ValueError('Select Mode %s not implemented' % mode)
@@ -490,7 +490,7 @@
 elif self.p2 & 0xdf == 0x40:
 c['mode'] = 'retransmit_previous_block'
 else:
-logger.warning('%s: invalid P2=%02x' % (self, self.p2))
+logger.warning('%s: invalid P2=%02x', self, self.p2)
 return c

 def _decode_cmd(self):
diff --git a/pySim/apdu_source/pyshark_rspro.py 
b/pySim/apdu_source/pyshark_rspro.py
index 8c614ff..0178bf2 100644
--- a/pySim/apdu_source/pyshark_rspro.py
+++ b/pySim/apdu_source/pyshark_rspro.py
@@ -89,7 +89,7 @@
 bsl = self.get_bank_slot(bank_slot)
 self._set_or_verify_bank_slot(bsl)
 data = modem2card.get_field('data').replace(':','')
-logger.debug("C(%u:%u) -> B(%u:%u): %s" % (csl[0], csl[1], bsl[0], 
bsl[1], data))
+logger.debug("C(%u:%u) -> B(%u:%u): %s", (csl[0], csl[1], bsl[0], 
bsl[1], data)
 # store the CMD portion until the RSP portion arrives later
 self.cmd_tpdu = h2b(data)
 elif msg_type == '13': # tpduCardToModem
@@ -101,7 +101,7 @@
 bsl = self.get_bank_slot(bank_slot)
 self._set_or_verify_bank_slot(bsl)
 data = card2modem.get_field('data').replace(':','')
-logger.debug("C(%u:%u) <- B(%u:%u): %s" % (csl[0], csl[1], bsl[0], 
bsl[1], data))
+logger.debug("C(%u:%u) <- B(%u:%u): %s", (csl[0], csl[1], bsl[0], 
bsl[1], data)
 rsp_tpdu = h2b(data)
 if self.cmd_tpdu:
 # combine this R-TPDU with the C-TPDU we saw earlier

--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35495?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: I39d26cdd5b85a61a06fd8c7a9d0a046e398819bd
Gerrit-Change-Number: 35495
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-MessageType: newchange


[S] Change in libosmo-abis[master]: DAHDI: Log hexdump of TX at level DEBUG, not ERROR

2024-01-07 Thread laforge
Attention is currently required from: keith.

laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmo-abis/+/35494?usp=email )

Change subject: DAHDI: Log hexdump of TX at level DEBUG, not ERROR
..


Patch Set 2: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/libosmo-abis/+/35494?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-Change-Id: I29aa82c8586d846a861e62d90d376ff9cfaa9654
Gerrit-Change-Number: 35494
Gerrit-PatchSet: 2
Gerrit-Owner: keith 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Attention: keith 
Gerrit-Comment-Date: Sun, 07 Jan 2024 08:55:00 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


[S] Change in libosmo-abis[master]: DAHDI: Log hexdump of TX at level DEBUG, not ERROR

2024-01-07 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmo-abis/+/35494?usp=email )

Change subject: DAHDI: Log hexdump of TX at level DEBUG, not ERROR
..

DAHDI: Log hexdump of TX at level DEBUG, not ERROR

This fixes Change-Id I447a2360757fed97ed50f9db1e2efbf2f90e46a0 where
log messages received more context.  However, by accident, one log
statement got elevated from DEBUG to ERROR level.  Let's revert that
accident.

Change-Id: I29aa82c8586d846a861e62d90d376ff9cfaa9654
---
M src/input/dahdi.c
1 file changed, 15 insertions(+), 1 deletion(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved




diff --git a/src/input/dahdi.c b/src/input/dahdi.c
index efed38d..b9a3fcf 100644
--- a/src/input/dahdi.c
+++ b/src/input/dahdi.c
@@ -259,7 +259,7 @@
return 0;
}

-   LOGPITS(e1i_ts, DLMI, LOGL_ERROR, "TX: %s\n", osmo_hexdump(msg->data, 
msg->len));
+   LOGPITS(e1i_ts, DLMI, LOGL_DEBUG, "TX: %s\n", osmo_hexdump(msg->data, 
msg->len));
lapd_transmit(e1i_ts->lapd, sign_link->tei,
sign_link->sapi, msg);


--
To view, visit https://gerrit.osmocom.org/c/libosmo-abis/+/35494?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-Change-Id: I29aa82c8586d846a861e62d90d376ff9cfaa9654
Gerrit-Change-Number: 35494
Gerrit-PatchSet: 2
Gerrit-Owner: keith 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-MessageType: merged


[S] Change in libosmo-abis[master]: DAHDI: Log hexdump of TX at level DEBUG, not ERROR

2024-01-07 Thread laforge
Attention is currently required from: laforge.

laforge has uploaded a new patch set (#2) to the change originally created by 
keith. ( https://gerrit.osmocom.org/c/libosmo-abis/+/35494?usp=email )


Change subject: DAHDI: Log hexdump of TX at level DEBUG, not ERROR
..

DAHDI: Log hexdump of TX at level DEBUG, not ERROR

This fixes Change-Id I447a2360757fed97ed50f9db1e2efbf2f90e46a0 where
log messages received more context.  However, by accident, one log
statement got elevated from DEBUG to ERROR level.  Let's revert that
accident.

Change-Id: I29aa82c8586d846a861e62d90d376ff9cfaa9654
---
M src/input/dahdi.c
1 file changed, 15 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/94/35494/2
--
To view, visit https://gerrit.osmocom.org/c/libosmo-abis/+/35494?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-Change-Id: I29aa82c8586d846a861e62d90d376ff9cfaa9654
Gerrit-Change-Number: 35494
Gerrit-PatchSet: 2
Gerrit-Owner: keith 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Attention: laforge 
Gerrit-MessageType: newpatchset