Attention is currently required from: laforge, neels.
Hoernchen has posted comments on this change by neels. ( https://gerrit.osmocom.org/c/pysim/+/40201?usp=email )
Change subject: personalization: make AlgorithmID a new EnumParam ......................................................................
Patch Set 5:
(1 comment)
Patchset:
PS5:
(Slight counter argument: This is not a map to the binary representation. […]
as far as I know the compiled asn1 representation loses the schema information/name, so you would need to access the schema instead. a somewhat concise way would be something like this, by getting the schema as well in compile_asn1_subdir and then working with the schema dict. this would basically leave the compiled asn1 alone and would not interfere with anything else:
def compile_asn1_subdir(subdir_name:str, codec='der'): """Helper function that compiles ASN.1 syntax from all files within given subdir""" import asn1tools asn_txt = '' __ver = sys.version_info if (__ver.major, __ver.minor) >= (3, 9): for i in resources.files('pySim.esim').joinpath('asn1').joinpath(subdir_name).iterdir(): asn_txt += i.read_text() asn_txt += "\n" #else: #print(resources.read_text(__name__, 'asn1/rsp.asn')) asn1_schema = asn1tools.parse_string(asn_txt, codec=codec) return asn1tools.compile_dict(asn1_schema, codec='ber'), asn1_schema
in saip/__init__.py
asn1, asn1_schema = compile_asn1_subdir('saip') # or asn, _ = compile_asn1_subdir(...) if schema not needed
somewhere else
from pySim.esim.saip import asn1_schema as saip_schema print(saip_schema['PEDefinitions']['types']['AlgoParameter']['members'][0]['named-numbers']) # {'milenage': 1, 'tuak': 2, 'usim-test-algorithm': 3}