aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2024-02-20 23:50:28 +0100
committerHarald Welte <laforge@osmocom.org>2024-02-20 23:55:37 +0100
commit8449b14d08b3a607a702c0906e875ed5eb6e0188 (patch)
treed5dd1de4f441031d72d6da681c2a57daf3394407
parent922b8a279c1e3bc3fe5137704585f6eb27ed3c7c (diff)
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
-rwxr-xr-xosmo-smdpp.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/osmo-smdpp.py b/osmo-smdpp.py
index 8cb0082..582b222 100755
--- a/osmo-smdpp.py
+++ b/osmo-smdpp.py
@@ -35,6 +35,7 @@ import asn1tools
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 @@ class SmDppHttpServer:
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