From 84077f239f381ef871aba75fceffb72ed974b956 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Tue, 16 Jul 2024 16:40:23 +0200 Subject: [PATCH] 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 --- osmo-smdpp.py | 3 +++ pySim/esim/es8p.py | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/osmo-smdpp.py b/osmo-smdpp.py index cc4b1213..e9638aac 100755 --- a/osmo-smdpp.py +++ b/osmo-smdpp.py @@ -376,6 +376,9 @@ class SmDppHttpServer: # 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 ff266ceb..a5c88f02 100644 --- a/pySim/esim/es8p.py +++ b/pySim/esim/es8p.py @@ -25,6 +25,7 @@ from pySim.utils import bertlv_return_one_rawtlv 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 @@ class ProfileMetadata: 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 @@ class ProfileMetadata: '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)