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

July 2024

  • 1 participants
  • 1379 discussions
[S] Change in pysim[master]: pySim.ts_31_102: Fix name of EF.VBSCA
by laforge 19 Jul '24

19 Jul '24
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/37529?usp=email ) Change subject: pySim.ts_31_102: Fix name of EF.VBSCA ...................................................................... pySim.ts_31_102: Fix name of EF.VBSCA It's VGCS but VBS. There's no VBCS. Change-Id: I3c4a7ec9cd6a56fe7b85832afc68685f8dccbfd1 --- M pySim/ts_31_102.py 1 file changed, 12 insertions(+), 1 deletion(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved diff --git a/pySim/ts_31_102.py b/pySim/ts_31_102.py index 497044f..5c010ad 100644 --- a/pySim/ts_31_102.py +++ b/pySim/ts_31_102.py @@ -1639,7 +1639,7 @@ EF_VGCS('6fb3', None, 'EF.VBS', desc='Voice Broadcast Service', service=58), EF_VGCSS('6fb4', None, 'EF.VBSS', desc='Voice Broadcast Service Status', service=58), EF_VGCSCA(service=64), - EF_VGCSCA('6fd5', None, 'EF.VBCSCA', desc='Voice Broadcast Service Ciphering Algorithm', service=65), + EF_VGCSCA('6fd5', None, 'EF.VBSCA', desc='Voice Broadcast Service Ciphering Algorithm', service=65), EF_GBABP(service=68), EF_MSK(service=69), EF_MUK(service=69), -- To view, visit https://gerrit.osmocom.org/c/pysim/+/37529?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: I3c4a7ec9cd6a56fe7b85832afc68685f8dccbfd1 Gerrit-Change-Number: 37529 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]: contrib/es9p_client: Add support for reporting notifications to SM-DP+
by laforge 19 Jul '24

19 Jul '24
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/37499?usp=email ) Change subject: contrib/es9p_client: Add support for reporting notifications to SM-DP+ ...................................................................... contrib/es9p_client: Add support for reporting notifications to SM-DP+ The ES9+ interface is not only used for downloading eSIM profiles, but it is also used to report back the installation result as well as profile management operations like enable/disable/delete. Change-Id: Iefba7fa0471b34eae30700ed43531a515af0eb93 --- M contrib/es9p_client.py M pySim/esim/__init__.py 2 files changed, 132 insertions(+), 3 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved diff --git a/contrib/es9p_client.py b/contrib/es9p_client.py index 5e72e7b..0434eb8 100755 --- a/contrib/es9p_client.py +++ b/contrib/es9p_client.py @@ -29,8 +29,9 @@ from cryptography.hazmat.primitives.asymmetric import ec import pySim.esim.rsp as rsp -from pySim.esim import es9p -from pySim.utils import h2b, b2h, swap_nibbles, bertlv_parse_one_rawtag, bertlv_return_one_rawtlv +from pySim.esim import es9p, PMO +from pySim.utils import h2b, b2h, swap_nibbles, is_hexstr +from pySim.utils import bertlv_parse_one_rawtag, bertlv_return_one_rawtlv from pySim.esim.x509_cert import CertAndPrivkey from pySim.esim.es8p import BoundProfilePackage @@ -63,6 +64,29 @@ parser_dl.add_argument('--confirmation-code', help="Confirmation Code for the eSIM download") +# notification +parser_ntf = subparsers.add_parser('notification', help='ES9+ (other) notification') +parser_ntf.add_argument('operation', choices=['enable','disable','delete'], + help='Profile Management Opreation whoise occurrence shall be notififed') +parser_ntf.add_argument('--sequence-nr', type=int, required=True, + help='eUICC global notification sequence number') +parser_ntf.add_argument('--notification-address', help='notificationAddress, if different from URL') +parser_ntf.add_argument('--iccid', type=is_hexstr, help='ICCID to which the notification relates') + +# notification-install +parser_ntfi = subparsers.add_parser('notification-install', help='ES9+ installation notification') +parser_ntfi.add_argument('--sequence-nr', type=int, required=True, + help='eUICC global notification sequence number') +parser_ntfi.add_argument('--transaction-id', required=True, + help='transactionId of previous ES9+ download') +parser_ntfi.add_argument('--notification-address', help='notificationAddress, if different from URL') +parser_ntfi.add_argument('--iccid', type=is_hexstr, help='ICCID to which the notification relates') +parser_ntfi.add_argument('--smdpp-oid', required=True, help='SM-DP+ OID (as in CERT.DPpb.ECDSA)') +parser_ntfi.add_argument('--isdp-aid', type=is_hexstr, required=True, + help='AID of the ISD-P of the installed profile') +parser_ntfi.add_argument('--sima-response', type=is_hexstr, required=True, + help='hex digits of BER-encoded SAIP EUICCResponse') + class Es9pClient: def __init__(self, opts): self.opts = opts @@ -91,6 +115,49 @@ self.peer = es9p.Es9pApiClient(opts.url, server_cert_verify=opts.server_ca_cert) + def do_notification(self): + + ntf_metadata = { + 'seqNumber': self.opts.sequence_nr, + 'profileManagementOperation': PMO(self.opts.operation).to_bitstring(), + 'notificationAddress': self.opts.notification_address or urlparse(self.opts.url).netloc, + } + if opts.iccid: + ntf_metadata['iccid'] = h2b(swap_nibbles(opts.iccid)) + + if self.opts.operation == 'download': + pird = { + 'transactionId': self.opts.transaction_id, + 'notificationMetadata': ntf_metadata, + 'smdpOid': self.opts.smdpp_oid, + 'finalResult': ('successResult', { + 'aid': self.opts.isdp_aid, + 'simaResponse': self.opts.sima_response, + }), + } + pird_bin = rsp.asn1.encode('ProfileInstallationResultData', pird) + signature = self.cert_and_key.ecdsa_sign(pird_bin) + pn_dict = ('profileInstallationResult', { + 'profileInstallationResultData': pird, + 'euiccSignPIR': signature, + }) + else: + ntf_bin = rsp.asn1.encode('NotificationMetadata', ntf_metadata) + signature = self.cert_and_key.ecdsa_sign(ntf_bin) + pn_dict = ('otherSignedNotification', { + 'tbsOtherNotification': ntf_metadata, + 'euiccNotificationSignature': signature, + 'euiccCertificate': rsp.asn1.decode('Certificate', self.cert_and_key.get_cert_as_der()), + 'eumCertificate': rsp.asn1.decode('Certificate', self.eum_cert.public_bytes(Encoding.DER)), + }) + + data = { + 'pendingNotification': pn_dict, + } + #print(data) + res = self.peer.call_handleNotification(data) + + def do_download(self): print("Step 1: InitiateAuthentication...") @@ -243,3 +310,8 @@ if opts.command == 'download': c.do_download() + elif opts.command == 'notification': + c.do_notification() + elif opts.command == 'notification-install': + opts.operation = 'install' + c.do_notification() diff --git a/pySim/esim/__init__.py b/pySim/esim/__init__.py index fbb90b9..29e2bf4 100644 --- a/pySim/esim/__init__.py +++ b/pySim/esim/__init__.py @@ -1,7 +1,51 @@ import sys -from typing import Optional +from typing import Optional, Tuple from importlib import resources +class PMO: + """Convenience conversion class for ProfileManagementOperation as used in ES9+ notifications.""" + pmo4operation = { + 'install': 0x80, + 'enable': 0x40, + 'disable': 0x20, + 'delete': 0x10, + } + + def __init__(self, op: str): + if not op in self.pmo4operation: + raise ValueError('Unknown operation "%s"' % op) + self.op = op + + def to_int(self): + return self.pmo4operation[self.op] + + @staticmethod + def _num_bits(data: int)-> int: + for i in range(0, 8): + if data & (1 << i): + return 8-i + return 0 + + def to_bitstring(self) -> Tuple[bytes, int]: + """return value in a format as used by asn1tools for BITSTRING.""" + val = self.to_int() + return (bytes([val]), self._num_bits(val)) + + @classmethod + def from_int(cls, i: int) -> 'PMO': + """Parse an integer representation.""" + for k, v in cls.pmo4operation.items(): + if v == i: + return cls(k) + raise ValueError('Unknown PMO 0x%02x' % i) + + @classmethod + def from_bitstring(cls, bstr: Tuple[bytes, int]) -> 'PMO': + """Parse a asn1tools BITSTRING representation.""" + return cls.from_int(bstr[0][0]) + + def __str__(self): + return self.op def compile_asn1_subdir(subdir_name:str, codec='der'): """Helper function that compiles ASN.1 syntax from all files within given subdir""" -- To view, visit https://gerrit.osmocom.org/c/pysim/+/37499?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: Iefba7fa0471b34eae30700ed43531a515af0eb93 Gerrit-Change-Number: 37499 Gerrit-PatchSet: 6 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
[S] Change in pysim[master]: osmo-smdpp: Implement 'other' notification signature validation
by laforge 19 Jul '24

19 Jul '24
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/37508?usp=email ) Change subject: osmo-smdpp: Implement 'other' notification signature validation ...................................................................... osmo-smdpp: Implement 'other' notification signature validation "other" notifications (enable, disable, delete) contain ECDSA signatures that also need verification. Change-Id: If610058b7af6f9fc7822576c93f9970e2ce9aba9 --- M osmo-smdpp.py 1 file changed, 36 insertions(+), 4 deletions(-) Approvals: laforge: Looks good to me, approved fixeria: Looks good to me, but someone else must approve Jenkins Builder: Verified diff --git a/osmo-smdpp.py b/osmo-smdpp.py index 390db18..cc4b121 100755 --- a/osmo-smdpp.py +++ b/osmo-smdpp.py @@ -35,7 +35,7 @@ from pySim.utils import h2b, b2h, swap_nibbles import pySim.esim.rsp as rsp -from pySim.esim import saip +from pySim.esim import saip, PMO from pySim.esim.es8p import * from pySim.esim.x509_cert import oid, cert_policy_has_oid, cert_get_auth_key_id from pySim.esim.x509_cert import CertAndPrivkey, CertificateSet, cert_get_subject_key_id, VerifyError @@ -494,13 +494,33 @@ pird_bin = rsp.asn1.encode('ProfileInstallationResultData', pird) # verify eUICC signature if not self._ecdsa_verify(ss.euicc_cert, profileInstallRes['euiccSignPIR'], pird_bin): - print("Unable to verify eUICC signature") + raise Exception('ECDSA signature verification failed on notification') print("Profile Installation Final Result: ", pird['finalResult']) # remove session state del self.rss[transactionId] elif pendingNotification[0] == 'otherSignedNotification': - # TODO - pass + otherSignedNotif = pendingNotification[1] + # TODO: use some kind of partially-parsed original data, don't re-encode? + euiccCertificate_bin = rsp.asn1.encode('Certificate', otherSignedNotif['euiccCertificate']) + eumCertificate_bin = rsp.asn1.encode('Certificate', otherSignedNotif['eumCertificate']) + euicc_cert = x509.load_der_x509_certificate(euiccCertificate_bin) + eum_cert = x509.load_der_x509_certificate(eumCertificate_bin) + ci_cert_id = cert_get_auth_key_id(eum_cert) + # Verify the validity of the eUICC certificate chain + cs = CertificateSet(self.ci_get_cert_for_pkid(ci_cert_id)) + cs.add_intermediate_cert(eum_cert) + # TODO v3: otherCertsInChain + cs.verify_cert_chain(euicc_cert) + tbs_bin = rsp.asn1.encode('NotificationMetadata', otherSignedNotif['tbsOtherNotification']) + if not self._ecdsa_verify(euicc_cert, otherSignedNotif['euiccNotificationSignature'], tbs_bin): + raise Exception('ECDSA signature verification failed on notification') + other_notif = otherSignedNotif['tbsOtherNotification'] + pmo = PMO.from_bitstring(other_notif['profileManagementOperation']) + eid = euicc_cert.subject.get_attributes_for_oid(x509.oid.NameOID.SERIAL_NUMBER)[0].value + iccid = other_notif.get('iccid', None) + if iccid: + iccid = swap_nibbles(b2h(iccid)) + print("handleNotification: EID %s: %s of %s" % (eid, pmo, iccid)) else: raise ValueError(pendingNotification) -- To view, visit https://gerrit.osmocom.org/c/pysim/+/37508?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: If610058b7af6f9fc7822576c93f9970e2ce9aba9 Gerrit-Change-Number: 37508 Gerrit-PatchSet: 4 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-MessageType: merged
1 0
0 0
[S] Change in pysim[master]: osmo-smdpp: Request enable/disable/delete notifications in metadata
by laforge 19 Jul '24

19 Jul '24
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/37509?usp=email ) ( 3 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: osmo-smdpp: Request enable/disable/delete notifications in metadata ...................................................................... osmo-smdpp: Request enable/disable/delete notifications in metadata this way, the eUICC will send us notifications whenever our profiles are enabled/disabled/deleted. Change-Id: I2861290864522b691b30b079c7c2e1466904df2d --- M osmo-smdpp.py M pySim/esim/es8p.py 2 files changed, 27 insertions(+), 0 deletions(-) Approvals: fixeria: Looks good to me, but someone else must approve laforge: Looks good to me, approved Jenkins Builder: Verified dexter: Looks good to me, but someone else must approve diff --git a/osmo-smdpp.py b/osmo-smdpp.py index cc4b121..e9638aa 100755 --- a/osmo-smdpp.py +++ b/osmo-smdpp.py @@ -376,6 +376,9 @@ # Put together profileMetadata + _bin ss.profileMetadata = ProfileMetadata(iccid_bin=h2b(swap_nibbles(iccid_str)), spn="OsmocomSPN", profile_name=matchingId) + # enable notifications for all operations + for event in ['enable', 'disable', 'delete']: + ss.profileMetadata.add_notification(event, self.server_hostname) profileMetadata_bin = ss.profileMetadata.gen_store_metadata_request() # Put together smdpSigned2 + _bin diff --git a/pySim/esim/es8p.py b/pySim/esim/es8p.py index ff266ce..a5c88f0 100644 --- a/pySim/esim/es8p.py +++ b/pySim/esim/es8p.py @@ -25,6 +25,7 @@ import pySim.esim.rsp as rsp from pySim.esim.bsp import BspInstance +from pySim.esim import PMO # Given that GSMA RSP uses ASN.1 in a very weird way, we actually cannot encode the full data type before # signing, but we have to build parts of it separately first, then sign that, so we can put the signature @@ -78,6 +79,11 @@ self.iccid_bin = iccid_bin self.spn = spn self.profile_name = profile_name + self.notifications = [] + + def add_notification(self, event: str, address: str): + """Add an 'other' notification to the notification configuration of the metadata""" + self.notifications.append((event, address)) def gen_store_metadata_request(self) -> bytes: """Generate encoded (but unsigned) StoreMetadataReqest DO (SGP.22 5.5.3)""" @@ -86,6 +92,12 @@ 'serviceProviderName': self.spn, 'profileName': self.profile_name, } + nci = [] + for n in self.notifications: + pmo = PMO(n[0]) + nci.append({'profileManagementOperation': pmo.to_bitstring(), 'notificationAddress': n[1]}) + if len(nci): + smr['notificationConfigurationInfo'] = nci return rsp.asn1.encode('StoreMetadataRequest', smr) -- To view, visit https://gerrit.osmocom.org/c/pysim/+/37509?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: I2861290864522b691b30b079c7c2e1466904df2d Gerrit-Change-Number: 37509 Gerrit-PatchSet: 4 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-MessageType: merged
1 0
0 0
[S] Change in pysim[master]: pySim.esim.es8p: Add support for encoding icon in ProfileMetadata
by laforge 19 Jul '24

19 Jul '24
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/37510?usp=email ) Change subject: pySim.esim.es8p: Add support for encoding icon in ProfileMetadata ...................................................................... pySim.esim.es8p: Add support for encoding icon in ProfileMetadata Change-Id: I8c6a0c628f07c2a9608174457d20b8955114731a --- M pySim/esim/es8p.py 1 file changed, 24 insertions(+), 0 deletions(-) Approvals: fixeria: Looks good to me, but someone else must approve Jenkins Builder: Verified laforge: Looks good to me, approved diff --git a/pySim/esim/es8p.py b/pySim/esim/es8p.py index a5c88f0..ba824d6 100644 --- a/pySim/esim/es8p.py +++ b/pySim/esim/es8p.py @@ -79,8 +79,20 @@ self.iccid_bin = iccid_bin self.spn = spn self.profile_name = profile_name + self.icon = None + self.icon_type = None self.notifications = [] + def set_icon(self, is_png: bool, icon_data: bytes): + """Set the icon that is part of the metadata.""" + if len(icon_data) > 1024: + raise ValueError('Icon data must not exceed 1024 bytes') + self.icon = icon_data + if is_png: + self.icon_type = 1 + else: + self.icon_type = 0 + def add_notification(self, event: str, address: str): """Add an 'other' notification to the notification configuration of the metadata""" self.notifications.append((event, address)) @@ -92,6 +104,9 @@ 'serviceProviderName': self.spn, 'profileName': self.profile_name, } + if self.icon: + smr['icon'] = self.icon + smr['iconType'] = self.icon_type nci = [] for n in self.notifications: pmo = PMO(n[0]) -- To view, visit https://gerrit.osmocom.org/c/pysim/+/37510?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: I8c6a0c628f07c2a9608174457d20b8955114731a Gerrit-Change-Number: 37510 Gerrit-PatchSet: 4 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-MessageType: merged
1 0
0 0
[S] Change in pysim[master]: osmo-smdpp + es9p_client: HTTP status 204 is used for handleNotification
by laforge 19 Jul '24

19 Jul '24
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/37511?usp=email ) Change subject: osmo-smdpp + es9p_client: HTTP status 204 is used for handleNotification ...................................................................... osmo-smdpp + es9p_client: HTTP status 204 is used for handleNotification As SGP.22 states, the handleNotification endpoint uses HTTP status 204, not 200 (due to its empty body). Change-Id: I890bdbd3e1c4578d2d5f0367958fdce26e338cac --- M osmo-smdpp.py M pySim/esim/es9p.py 2 files changed, 16 insertions(+), 0 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved diff --git a/osmo-smdpp.py b/osmo-smdpp.py index e9638aa..a044b9b 100755 --- a/osmo-smdpp.py +++ b/osmo-smdpp.py @@ -481,6 +481,9 @@ @rsp_api_wrapper def handleNotification(self, request: IRequest, content: dict) -> dict: """See ES9+ HandleNotification in SGP.22 Section 5.6.4""" + # SGP.22 Section 6.3: "A normal notification function execution status (MEP Notification) + # SHALL be indicated by the HTTP status code '204' (No Content) with an empty HTTP response body" + request.setResponseCode(204) pendingNotification_bin = b64decode(content['pendingNotification']) pendingNotification = rsp.asn1.decode('PendingNotification', pendingNotification_bin) print("Rx %s: %s" % pendingNotification) diff --git a/pySim/esim/es9p.py b/pySim/esim/es9p.py index 41f2eeb..2c4b10f 100644 --- a/pySim/esim/es9p.py +++ b/pySim/esim/es9p.py @@ -136,6 +136,7 @@ 'pendingNotification': param.PendingNotification, } input_mandatory = ['pendingNotification'] + expected_http_status = 204 # ES9+ CancelSession function (SGP.22 section 6.5.2.10) class CancelSession(Es9PlusApiFunction): -- To view, visit https://gerrit.osmocom.org/c/pysim/+/37511?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: I890bdbd3e1c4578d2d5f0367958fdce26e338cac Gerrit-Change-Number: 37511 Gerrit-PatchSet: 5 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-MessageType: merged
1 0
0 0
[M] Change in pysim[master]: pySim.globalplatform: Add 'http' submodule for GP Amd B RAM over HTTPS
by laforge 19 Jul '24

19 Jul '24
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/37486?usp=email ) Change subject: pySim.globalplatform: Add 'http' submodule for GP Amd B RAM over HTTPS ...................................................................... pySim.globalplatform: Add 'http' submodule for GP Amd B RAM over HTTPS This implements the first parts of the "GlobalPlatform Remote Application Management over HTTP Card Specification v2.3 - Amendment B, Versoin 1.2". Specifically, this patch covers the TLV definitions for the OTA message used for HTTPS session triggering. This also adds some more unit test coverage to pySim.cat, based on real-world data that was captured nested inside the HTTPS Administration session triggering parameters. Change-Id: Ia7d7bd6df41bdf1249011bad9a9a38b7669edc54 --- M pySim/cat.py A pySim/global_platform/http.py M tests/test_tlvs.py 3 files changed, 127 insertions(+), 0 deletions(-) Approvals: fixeria: Looks good to me, but someone else must approve Jenkins Builder: Verified laforge: Looks good to me, approved diff --git a/pySim/cat.py b/pySim/cat.py index d2a3a66..73f0a76 100644 --- a/pySim/cat.py +++ b/pySim/cat.py @@ -267,6 +267,9 @@ # TS 102 223 Section 8.15 class TextString(COMPR_TLV_IE, tag=0x8D): + _test_de_encode = [ + ( '8d090470617373776f7264', {'dcs': 4, 'text_string': '70617373776f7264'} ), + ] _construct = Struct('dcs'/Int8ub, # TS 03.38 'text_string'/HexAdapter(GreedyBytes)) @@ -444,6 +447,9 @@ # TS 102 223 Section 8.52 class BearerDescription(COMPR_TLV_IE, tag=0xB5): + _test_de_encode = [ + ( 'b50103', {'bearer_parameters': '', 'bearer_type': 'default'} ), + ] # TS 31.111 Section 8.52.1 BearerParsCs = Struct('data_rate'/Int8ub, 'bearer_service'/Int8ub, @@ -507,11 +513,17 @@ # TS 102 223 Section 8.58 class OtherAddress(COMPR_TLV_IE, tag = 0xBE): + _test_de_encode = [ + ( 'be052101020304', {'address': '01020304', 'type_of_address': 'ipv4'} ), + ] _construct = Struct('type_of_address'/Enum(Int8ub, ipv4=0x21, ipv6=0x57), 'address'/HexAdapter(GreedyBytes)) # TS 102 223 Section 8.59 class UiccTransportLevel(COMPR_TLV_IE, tag = 0xBC): + _test_de_encode = [ + ( 'bc03028000', {'port_number': 32768, 'protocol_type': 'tcp_uicc_client_remote'} ), + ] _construct = Struct('protocol_type'/Enum(Int8ub, udp_uicc_client_remote=1, tcp_uicc_client_remote=2, tcp_uicc_server=3, udp_uicc_client_local=4, tcp_uicc_client_local=5, direct_channel=6), @@ -558,6 +570,9 @@ # TS 102 223 Section 8.70 class NetworkAccessName(COMPR_TLV_IE, tag=0xC7): + _test_de_encode = [ + ( 'c704036e6161', '036e6161' ), + ] _construct = HexAdapter(GreedyBytes) # TS 102 223 Section 8.72 diff --git a/pySim/global_platform/http.py b/pySim/global_platform/http.py new file mode 100644 index 0000000..f0e98aa --- /dev/null +++ b/pySim/global_platform/http.py @@ -0,0 +1,93 @@ +"""GlobalPlatform Remote Application Management over HTTP Card Specification v2.3 - Amendment B. +Also known as SCP81 for SIM/USIM/UICC/eUICC/eSIM OTA. +""" + +# (C) 2024 by Harald Welte <laforge(a)osmocom.org> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# 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 <http://www.gnu.org/licenses/>. + +from construct import Struct, Int8ub, Int16ub, Bytes, GreedyBytes, GreedyString, BytesInteger +from construct import this, len_, Rebuild, Const +from construct import Optional as COptional + +from pySim.tlv import BER_TLV_IE +from pySim import cat + + +# Table 3-3 + Section 3.8.1 +class RasConnectionParams(BER_TLV_IE, tag=0x84, nested=cat.OpenChannel.nested_collection_cls.possible_nested): + pass + +# Table 3-3 + Section 3.8.2 +class SecurityParams(BER_TLV_IE, tag=0x85): + _test_de_encode = [ + ( '850804deadbeef020040', {'kid': 64,'kvn': 0, 'psk_id': b'\xde\xad\xbe\xef', 'sha_type': None} ) + ] + _construct = Struct('_psk_id_len'/Rebuild(Int8ub, len_(this.psk_id)), 'psk_id'/Bytes(this._psk_id_len), + '_kid_kvn_len'/Const(2, Int8ub), 'kvn'/Int8ub, 'kid'/Int8ub, + 'sha_type'/COptional(Int8ub)) + +# Table 3-3 + ? +class ExtendedSecurityParams(BER_TLV_IE, tag=0xA5): + _construct = GreedyBytes + +# Table 3-3 + Section 3.8.3 +class SessionRetryPolicyParams(BER_TLV_IE, tag=0x86): + _construct = Struct('retry_counter'/Int16ub, + 'retry_waiting_delay'/BytesInteger(5), + 'retry_report_failure'/COptional(GreedyBytes)) + +# Table 3-3 + Section 3.8.4 +class AdminHostParam(BER_TLV_IE, tag=0x8A): + _test_de_encode = [ + ( '8a0a61646d696e2e686f7374', 'admin.host' ), + ] + _construct = GreedyString('utf-8') + +# Table 3-3 + Section 3.8.5 +class AgentIdParam(BER_TLV_IE, tag=0x8B): + _construct = GreedyString('utf-8') + +# Table 3-3 + Section 3.8.6 +class AdminUriParam(BER_TLV_IE, tag=0x8C): + _test_de_encode = [ + ( '8c1668747470733a2f2f61646d696e2e686f73742f757269', 'https://admin.host/uri' ), + ] + _construct = GreedyString('utf-8') + +# Table 3-3 +class HttpPostParams(BER_TLV_IE, tag=0x89, nested=[AdminHostParam, AgentIdParam, AdminUriParam]): + pass + +# Table 3-3 +class AdmSessionParams(BER_TLV_IE, tag=0x83, nested=[RasConnectionParams, SecurityParams, + ExtendedSecurityParams, SessionRetryPolicyParams, + HttpPostParams]): + pass + +# Table 3-3 + Section 3.11.4 +class RasFqdn(BER_TLV_IE, tag=0xD6): + _construct = GreedyBytes # FIXME: DNS String + +# Table 3-3 + Section 3.11.7 +class DnsConnectionParams(BER_TLV_IE, tag=0xFA, nested=cat.OpenChannel.nested_collection_cls.possible_nested): + pass + +# Table 3-3 +class DnsResolutionParams(BER_TLV_IE, tag=0xB3, nested=[RasFqdn, DnsConnectionParams]): + pass + +# Table 3-3 +class AdmSessTriggerParams(BER_TLV_IE, tag=0x81, nested=[AdmSessionParams, DnsResolutionParams]): + pass diff --git a/tests/test_tlvs.py b/tests/test_tlvs.py index a0dd107..429b966 100755 --- a/tests/test_tlvs.py +++ b/tests/test_tlvs.py @@ -31,6 +31,7 @@ import pySim.gsm_r import pySim.cdma_ruim import pySim.global_platform +import pySim.global_platform.http if 'unittest.util' in __import__('sys').modules: # Show full diff in self.assertEqual. -- To view, visit https://gerrit.osmocom.org/c/pysim/+/37486?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: Ia7d7bd6df41bdf1249011bad9a9a38b7669edc54 Gerrit-Change-Number: 37486 Gerrit-PatchSet: 6 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-MessageType: merged
1 0
0 0
[S] Change in pysim[master]: pySim.ts_31_103: update to spec v18.1.0 Release 18
by laforge 19 Jul '24

19 Jul '24
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/37523?usp=email ) Change subject: pySim.ts_31_103: update to spec v18.1.0 Release 18 ...................................................................... pySim.ts_31_103: update to spec v18.1.0 Release 18 This adds two new EFs and one new IST service. Change-Id: Iced1700046b459399a3e8305e1387ec65eeb3536 --- M pySim/ts_31_103.py M pysim-testdata/pySim-trace_test_gsmtap.pcapng.ok 2 files changed, 40 insertions(+), 3 deletions(-) Approvals: laforge: Looks good to me, approved fixeria: Looks good to me, but someone else must approve Jenkins Builder: Verified diff --git a/pySim/ts_31_103.py b/pySim/ts_31_103.py index 81de13c..2a71449 100644 --- a/pySim/ts_31_103.py +++ b/pySim/ts_31_103.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- """ -Various constants from 3GPP TS 31.103 V16.1.0 +Various constants from 3GPP TS 31.103 V18.1.0 """ # # Copyright (C) 2020 Supreeth Herle <herlesupreeth(a)gmail.com> -# Copyright (C) 2021 Harald Welte <laforge(a)osmocom.org> +# Copyright (C) 2021-2024 Harald Welte <laforge(a)osmocom.org> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -56,6 +56,7 @@ 19: 'XCAP Configuration Data', 20: 'WebRTC URI', 21: 'MuD and MiD configuration data', + 22: 'IMS Data Channel indication', } # TS 31.103 Section 4.2.2 @@ -279,6 +280,29 @@ super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, **kwargs) self._tlv = EF_MuDMiDConfigData.MudMidConfigDataCollection +# TS 31.103 Section 4.2.22 +class EF_AC_GBAUAPI(LinFixedEF): + """The use of this EF is eescribed in 3GPP TS 31.130""" + class AppletNafAccessControl(BER_TLV_IE, tag=0x80): + # the use of Int8ub as length field in Prefixed is strictly speaking incorrect, as it is a BER-TLV + # length field whihc will consume two bytes from length > 127 bytes. However, AIDs and NAF IDs can + # safely be assumed shorter than that + _construct = Struct('aid'/Prefixed(Int8ub, GreedyBytes), + 'naf_id'/Prefixed(Int8ub, GreedyBytes)) + def __init__(self, fid='6f0a', sfid=None, name='EF.GBAUAPI', + desc='Access Control to GBA_U_API', **kwargs): + super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, **kwargs) + self._tlv = EF_AC_GBAUAPI.AppletNafAccessControl + +# TS 31.103 Section 4.2.23 +class EF_IMSDCI(TransparentEF): + """See Management object as defined in 3GPP TS 24.275.""" + def __init__(self, fid='6f0b', sfid=None, name='EF.IMSDCI', desc='IMS Data Channel Indication', **kwargs): + super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, **kwargs) + self._construct = Enum(Byte, ims_dc_not_allowed=0x00, + ims_dc_allowed_after_ims_session=0x01, + ims_dc_allowed_simultaneous_ims_session=0x02) + class ADF_ISIM(CardADF): def __init__(self, aid='a0000000871004', has_fs=True, name='ADF.ISIM', fid=None, sfid=None, @@ -306,6 +330,8 @@ EF_XCAPConfigData(service=19), EF_WebRTCURI(service=20), EF_MuDMiDConfigData(service=21), + EF_AC_GBAUAPI(service=2), + EF_IMSDCI(service=22), ] self.add_files(files) # add those commands to the general commands of a TransparentEF diff --git a/pysim-testdata/pySim-trace_test_gsmtap.pcapng.ok b/pysim-testdata/pySim-trace_test_gsmtap.pcapng.ok index b947983..9c17b69 100644 --- a/pysim-testdata/pySim-trace_test_gsmtap.pcapng.ok +++ b/pysim-testdata/pySim-trace_test_gsmtap.pcapng.ok @@ -347,7 +347,7 @@ =============================== 01 READ RECORD MF/ADF.ISIM/EF.P-CSCF 01 9000 {'pcscf_address': None} =============================== -01 READ BINARY MF/ADF.ISIM/EF.IST - 9000 {1: {'activated': True, 'description': 'P-CSCF address'}, 2: {'activated': False, 'description': 'Generic Bootstrapping Architecture (GBA)'}, 3: {'activated': False, 'description': 'HTTP Digest'}, 4: {'activated': True, 'description': 'GBA-based Local Key Establishment Mechanism'}, 5: {'activated': True, 'description': 'Support of P-CSCF discovery for IMS Local Break Out'}, 6: {'activated': False, 'description': 'Short Message Storage (SMS)'}, 7: {'activated': False, 'description': 'Short Message Status Reports (SMSR)'}, 8: {'activated': False, 'description': 'Support for SM-over-IP including data download via SMS-PP as defined in TS 31.111 [31]'}, 9: {'activated': False, 'description': 'Communication Control for IMS by ISIM'}, 10: {'activated': True, 'description': 'Support of UICC access to IMS'}, 11: {'activated': False, 'description': 'URI support by UICC'}, 12: {'activated': False, 'description': 'Media Type support'}, 13: {'activated': False, 'description': 'IMS call disconnection cause'}, 14: {'activated': False, 'description': 'URI support for MO SHORT MESSAGE CONTROL'}, 15: {'activated': False, 'description': 'MCPTT'}, 16: {'activated': False, 'description': 'URI support for SMS-PP DOWNLOAD as defined in 3GPP TS 31.111 [31]'}, 17: {'activated': False, 'description': 'From Preferred'}, 18: {'activated': False, 'description': 'IMS configuration data'}, 19: {'activated': False, 'description': 'XCAP Configuration Data'}, 20: {'activated': False, 'description': 'WebRTC URI'}, 21: {'activated': False, 'description': 'MuD and MiD configuration data'}, 22: {'activated': False}, 23: {'activated': False}, 24: {'activated': False}} +01 READ BINARY MF/ADF.ISIM/EF.IST - 9000 {1: {'activated': True, 'description': 'P-CSCF address'}, 2: {'activated': False, 'description': 'Generic Bootstrapping Architecture (GBA)'}, 3: {'activated': False, 'description': 'HTTP Digest'}, 4: {'activated': True, 'description': 'GBA-based Local Key Establishment Mechanism'}, 5: {'activated': True, 'description': 'Support of P-CSCF discovery for IMS Local Break Out'}, 6: {'activated': False, 'description': 'Short Message Storage (SMS)'}, 7: {'activated': False, 'description': 'Short Message Status Reports (SMSR)'}, 8: {'activated': False, 'description': 'Support for SM-over-IP including data download via SMS-PP as defined in TS 31.111 [31]'}, 9: {'activated': False, 'description': 'Communication Control for IMS by ISIM'}, 10: {'activated': True, 'description': 'Support of UICC access to IMS'}, 11: {'activated': False, 'description': 'URI support by UICC'}, 12: {'activated': False, 'description': 'Media Type support'}, 13: {'activated': False, 'description': 'IMS call disconnection cause'}, 14: {'activated': False, 'description': 'URI support for MO SHORT MESSAGE CONTROL'}, 15: {'activated': False, 'description': 'MCPTT'}, 16: {'activated': False, 'description': 'URI support for SMS-PP DOWNLOAD as defined in 3GPP TS 31.111 [31]'}, 17: {'activated': False, 'description': 'From Preferred'}, 18: {'activated': False, 'description': 'IMS configuration data'}, 19: {'activated': False, 'description': 'XCAP Configuration Data'}, 20: {'activated': False, 'description': 'WebRTC URI'}, 21: {'activated': False, 'description': 'MuD and MiD configuration data'}, 22: {'activated': False, 'description': 'IMS Data Channel indication'}, 23: {'activated': False}, 24: {'activated': False}} =============================== 01 READ BINARY MF/ADF.ISIM/EF.GBABP - 9000 None =============================== -- To view, visit https://gerrit.osmocom.org/c/pysim/+/37523?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: Iced1700046b459399a3e8305e1387ec65eeb3536 Gerrit-Change-Number: 37523 Gerrit-PatchSet: 3 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-MessageType: merged
1 0
0 0
[S] Change in pysim[master]: pySim.ts_31_102: Fix name of EF.VBSCA
by laforge 19 Jul '24

19 Jul '24
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/37529?usp=email ) Change subject: pySim.ts_31_102: Fix name of EF.VBSCA ...................................................................... Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/pysim/+/37529?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: I3c4a7ec9cd6a56fe7b85832afc68685f8dccbfd1 Gerrit-Change-Number: 37529 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Comment-Date: Fri, 19 Jul 2024 12:10:08 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[M] Change in pysim[master]: ts_31_102: Make use of ts_31_103_shared and add Rel 18 files
by laforge 19 Jul '24

19 Jul '24
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/37526?usp=email ) Change subject: ts_31_102: Make use of ts_31_103_shared and add Rel 18 files ...................................................................... Patch Set 3: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/pysim/+/37526?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: I68ca15084f9654468bd37526c02a66322085b25b Gerrit-Change-Number: 37526 Gerrit-PatchSet: 3 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Comment-Date: Fri, 19 Jul 2024 12:10:04 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • ...
  • 138
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.