mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-03-25 06:48:33 +03:00
wip
Change-Id: I0f44d0e90b26b152bcf414ec4497afb8182dd72d
This commit is contained in:
@@ -22,9 +22,11 @@ import re
|
||||
import pprint
|
||||
from typing import List, Tuple, Generator, Optional
|
||||
|
||||
from construct.core import StreamError
|
||||
from osmocom.tlv import camel_to_snake
|
||||
from osmocom.utils import hexstr
|
||||
from pySim.utils import enc_iccid, dec_iccid, enc_imsi, dec_imsi, h2b, b2h, rpad, sanitize_iccid
|
||||
from pySim.ts_31_102 import EF_AD
|
||||
from pySim.ts_51_011 import EF_SMSP
|
||||
from pySim.esim.saip import param_source
|
||||
from pySim.esim.saip import ProfileElement, ProfileElementSD, ProfileElementSequence
|
||||
@@ -646,7 +648,7 @@ class SmspTpScAddr(ConfigurableParameter):
|
||||
yield { cls.name: cls.tuple_to_str((international, digits)) }
|
||||
|
||||
|
||||
class AdMncLen(ConfigurableParameter):
|
||||
class MncLen(ConfigurableParameter):
|
||||
"""MNC length. Must be either 2 or 3. Sets only the MNC length field in EF-AD (Administrative Data)."""
|
||||
name = 'MNC-LEN'
|
||||
allow_chars = '23'
|
||||
@@ -670,10 +672,20 @@ class AdMncLen(ConfigurableParameter):
|
||||
"""val must be an int: either 2 or 3"""
|
||||
for naa in ('usim', 'isim', 'csim'):
|
||||
for pe in pes.get_pes_for_type(naa):
|
||||
if not hasattr(pe, 'files'):
|
||||
continue
|
||||
# decode existing values
|
||||
f_ad = pe.files['ef-ad']
|
||||
ef_ad = EF_AD()
|
||||
ef_ad_dec = ef_ad.decode_bin(f_ad.body)
|
||||
print(f"XXXX {f_ad.body}")
|
||||
if not f_ad.body:
|
||||
continue
|
||||
try:
|
||||
ef_ad = EF_AD()
|
||||
ef_ad_dec = ef_ad.decode_bin(f_ad.body)
|
||||
except StreamError:
|
||||
continue
|
||||
if 'mnc_len' not in ef_ad_dec:
|
||||
continue
|
||||
# change mnc_len
|
||||
ef_ad_dec['mnc_len'] = val
|
||||
# re-encode into the File body
|
||||
@@ -682,23 +694,26 @@ class AdMncLen(ConfigurableParameter):
|
||||
|
||||
@classmethod
|
||||
def get_values_from_pes(cls, pes: ProfileElementSequence):
|
||||
for naa in ('usim', 'isim', 'csim'):
|
||||
for naa in ('isim',):# 'isim', 'csim'):
|
||||
for pe in pes.get_pes_for_type(naa):
|
||||
if not hasattr(pe, 'files'):
|
||||
continue
|
||||
f_ad = pe.files.get('ef-ad', None)
|
||||
if f_ad is None:
|
||||
continue
|
||||
print(f"XXXX {f_ad.body}")
|
||||
|
||||
try:
|
||||
ef_ad = EF_AD()
|
||||
ef_ad_dec = ef_ad.decode_bin(f_ad.body)
|
||||
except IndexError:
|
||||
except StreamError:
|
||||
continue
|
||||
|
||||
mnc_len = ef_ad_dec.get('mnc_len', None)
|
||||
if mnc_len is None:
|
||||
continue
|
||||
|
||||
yield { cls.name: mnc_len }
|
||||
yield { cls.name: str(mnc_len) }
|
||||
|
||||
|
||||
class SdKey(BinaryParam):
|
||||
@@ -1135,7 +1150,7 @@ class MilenageRotationConstants(BinaryParam, AlgoConfig):
|
||||
class MilenageXoringConstants(BinaryParam, AlgoConfig):
|
||||
"""XOR-ing constants c1,c2,c3,c4,c5 of Milenage, 128bit each. See 3GPP TS 35.206 Sections 2.3 + 5.3.
|
||||
Provided as octet-string concatenation of all 5 constants. The default value by 3GPP is the concetenation
|
||||
of::
|
||||
of:
|
||||
|
||||
00000000000000000000000000000000
|
||||
00000000000000000000000000000001
|
||||
|
||||
Reference in New Issue
Block a user