mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-07-05 17:48:07 +03:00
saip.PES.rebuild_mandatory_services(): set 5G get-identity, profile-a-x25519, profile-b-p256
Related: SYS#8096 SYS#8037 Change-Id: Ibc29c6437c5c92e2b14938b733156536863465c1
This commit is contained in:
@@ -34,7 +34,7 @@ from pySim import ts_102_222
|
|||||||
from pySim.utils import dec_imsi
|
from pySim.utils import dec_imsi
|
||||||
from pySim.ts_102_221 import FileDescriptor
|
from pySim.ts_102_221 import FileDescriptor
|
||||||
from pySim.filesystem import CardADF, Path
|
from pySim.filesystem import CardADF, Path
|
||||||
from pySim.ts_31_102 import ADF_USIM
|
from pySim.ts_31_102 import ADF_USIM, EF_UST, EF_SUCI_Calc_Info
|
||||||
from pySim.ts_31_103 import ADF_ISIM
|
from pySim.ts_31_103 import ADF_ISIM
|
||||||
from pySim.esim import compile_asn1_subdir
|
from pySim.esim import compile_asn1_subdir
|
||||||
from pySim.esim.saip import templates
|
from pySim.esim.saip import templates
|
||||||
@@ -1726,7 +1726,52 @@ class ProfileElementSequence:
|
|||||||
if 'BT' in ftype_list:
|
if 'BT' in ftype_list:
|
||||||
svc_set.add('ber-tlv')
|
svc_set.add('ber-tlv')
|
||||||
# FIXME:dfLinked files (scan all files, check for non-empty Fcp.linkPath presence of DFs)
|
# FIXME:dfLinked files (scan all files, check for non-empty Fcp.linkPath presence of DFs)
|
||||||
# TODO: 5G related bits (derive from EF.UST or file presence?)
|
|
||||||
|
# 5G:
|
||||||
|
# - When SUCI is:
|
||||||
|
# - enabled (EF.UST 124 = true)
|
||||||
|
# AND
|
||||||
|
# - calculated in the USIM (EF.UST 125 = true),
|
||||||
|
# then eUICC-Mandatory-services needs 'get-identity'.
|
||||||
|
# - 'get-identity' implies that the eUICC must support ONE OF profile-A OR profile-B.
|
||||||
|
# (One might assume from this that, when SUCI-CalcInfo for USIM in DF.SAIP contains both key types, then no
|
||||||
|
# profile-A or B services need to be requested explicitly. However, the correct logic is:)
|
||||||
|
# - Iff the SUCI-CalcInfo for USIM (DF.SAIP) contains a key of profile-A ("identifier": 1),
|
||||||
|
# then eUICC-Mandatory-services needs 'profile-a-x25519'.
|
||||||
|
# - Same: profile-B ("identifier": 2) needs 'profile-b-p256'.
|
||||||
|
# - (When SUCI is calculated in the UE, then the eUICC does not need to provide any of these services.)
|
||||||
|
suci_in_usim_enabled = False
|
||||||
|
try:
|
||||||
|
f_ust = self.get_pe_for_type("usim").files["ef-ust"]
|
||||||
|
ust = EF_UST().decode_bin(f_ust.body)
|
||||||
|
suci_in_usim_enabled = ust[124]['activated'] and ust[125]['activated']
|
||||||
|
except (KeyError, AttributeError):
|
||||||
|
pass
|
||||||
|
if suci_in_usim_enabled:
|
||||||
|
svc_set.add('get-identity')
|
||||||
|
# now check for profile-a and profile-b presence
|
||||||
|
suci_calcinfo_has_profile_a = False
|
||||||
|
suci_calcinfo_has_profile_b = False
|
||||||
|
try:
|
||||||
|
f_sucici = self.get_pe_for_type("df-saip").files["ef-suci-calc-info-usim"]
|
||||||
|
sucici = EF_SUCI_Calc_Info().decode_bin(f_sucici.body) or {}
|
||||||
|
for prot_scheme in sucici['prot_scheme_id_list']:
|
||||||
|
if not isinstance(prot_scheme, dict):
|
||||||
|
continue
|
||||||
|
ps_id = prot_scheme["identifier"]
|
||||||
|
if ps_id == 1:
|
||||||
|
suci_calcinfo_has_profile_a = True
|
||||||
|
elif ps_id == 2:
|
||||||
|
suci_calcinfo_has_profile_b = True
|
||||||
|
except (KeyError, AttributeError):
|
||||||
|
pass
|
||||||
|
if suci_calcinfo_has_profile_a:
|
||||||
|
# The profile has a profile-A key, so require that
|
||||||
|
svc_set.add('profile-a-x25519')
|
||||||
|
if suci_calcinfo_has_profile_b:
|
||||||
|
# The profile has a profile-B key, so require that
|
||||||
|
svc_set.add('profile-b-p256')
|
||||||
|
|
||||||
hdr_pe = self.get_pe_for_type('header')
|
hdr_pe = self.get_pe_for_type('header')
|
||||||
# patch in the 'manual' services from the existing list:
|
# patch in the 'manual' services from the existing list:
|
||||||
for old_svc in hdr_pe.decoded['eUICC-Mandatory-services'].keys():
|
for old_svc in hdr_pe.decoded['eUICC-Mandatory-services'].keys():
|
||||||
|
|||||||
Reference in New Issue
Block a user