laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/pysim/+/36025?usp=email )


Change subject: osmo-smdpp: Get rid of hard-coded ICCID
......................................................................

osmo-smdpp: Get rid of hard-coded ICCID

Read the ICCID from the header of the UPP when building the
ProfileMetdata.  This allows the download of profiles with arbitrary ICCID.

Change-Id: I1b9e17f757f9935436828e6dc1ab75ff17d1d1a4
---
M osmo-smdpp.py
1 file changed, 17 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/25/36025/1

diff --git a/osmo-smdpp.py b/osmo-smdpp.py
index 8cb0082..001a00e 100755
--- a/osmo-smdpp.py
+++ b/osmo-smdpp.py
@@ -35,6 +35,7 @@
 from pySim.utils import h2b, b2h, swap_nibbles

 import pySim.esim.rsp as rsp
+from pySim.esim import saip
 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
@@ -363,11 +364,14 @@
                 if not os.path.isfile(path) or not os.access(path, os.R_OK):
                     raise ApiError('8.2.6', '3.8', 'Refused')
                 ss.matchingId = matchingId
+                with open(path, 'rb') as f:
+                    pes = saip.ProfileElementSequence.from_der(f.read())
+                    iccid_str = 
b2h(pes.get_pe_for_type('header').decoded['iccid'])

         # FIXME: we actually want to perform the profile binding herr, and 
read the profile metadat from the profile

         # Put together profileMetadata + _bin
-        ss.profileMetadata = ProfileMetadata(iccid_bin= 
h2b(swap_nibbles('89000123456789012358')), spn="OsmocomSPN", 
profile_name="OsmocomProfile")
+        ss.profileMetadata = 
ProfileMetadata(iccid_bin=h2b(swap_nibbles(iccid_str))), spn="OsmocomSPN", 
profile_name=matchingId)
         profileMetadata_bin = ss.profileMetadata.gen_store_metadata_request()

         # Put together smdpSigned2 + _bin

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

Reply via email to