From 4f888a0414101dee4f20aa12579491fcc71707b3 Mon Sep 17 00:00:00 2001 From: Philipp Maier Date: Fri, 2 Dec 2022 12:30:12 +0100 Subject: [PATCH] sysmocom_sja2: simplify and fix op/opc decoder/encoder The decoder/encoder of that decodes the EF.xSIM_AUTH_KEY files has an overcomplicated handling for op/and opc. There is a condition that checks if milenage is configured and another one that checks if the string is recognized as OP or OPc. Both is not correct and seems not to work (op and opc is always displayed as "null") The encoder/decoder should focus on the physical file layout and regardless of any other conriguration the OP/OPc field is physically present and should be displayd and presented for editing. Change-Id: I6fa3a07e5e473273498d3f13d4cfa33743b787e1 --- pySim/sysmocom_sja2.py | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/pySim/sysmocom_sja2.py b/pySim/sysmocom_sja2.py index 53e6585c..a78318ed 100644 --- a/pySim/sysmocom_sja2.py +++ b/pySim/sysmocom_sja2.py @@ -143,12 +143,7 @@ class EF_SIM_AUTH_KEY(TransparentEF): 'algorithm'/Enum(Nibble, milenage=4, comp128v1=1, comp128v2=2, comp128v3=3)) self._construct = Struct('cfg'/CfgByte, 'key'/HexAdapter(Bytes(16)), - 'op'/ If(this.cfg.algorithm == 'milenage' and not this.cfg.use_opc_instead_of_op, - HexAdapter(Bytes(16))), - 'opc' / - If(this.cfg.algorithm == 'milenage' and this.cfg.use_opc_instead_of_op, - HexAdapter(Bytes(16))) - ) + 'op_opc' /HexAdapter(Bytes(16))) class DF_SYSTEM(CardDF): @@ -198,13 +193,7 @@ class EF_USIM_AUTH_KEY(TransparentEF): 'algorithm'/Enum(Nibble, milenage=4, sha1_aka=5, xor=15)) self._construct = Struct('cfg'/CfgByte, 'key'/HexAdapter(Bytes(16)), - 'op' / - If(this.cfg.algorithm == 'milenage' and not this.cfg.use_opc_instead_of_op, - HexAdapter(Bytes(16))), - 'opc' / - If(this.cfg.algorithm == 'milenage' and this.cfg.use_opc_instead_of_op, - HexAdapter(Bytes(16))) - ) + 'op_opc' /HexAdapter(Bytes(16))) class EF_USIM_AUTH_KEY_2G(TransparentEF): @@ -216,13 +205,7 @@ class EF_USIM_AUTH_KEY_2G(TransparentEF): 'algorithm'/Enum(Nibble, milenage=4, comp128v1=1, comp128v2=2, comp128v3=3)) self._construct = Struct('cfg'/CfgByte, 'key'/HexAdapter(Bytes(16)), - 'op' / - If(this.cfg.algorithm == 'milenage' and not this.cfg.use_opc_instead_of_op, - HexAdapter(Bytes(16))), - 'opc' / - If(this.cfg.algorithm == 'milenage' and this.cfg.use_opc_instead_of_op, - HexAdapter(Bytes(16))) - ) + 'op_opc' /HexAdapter(Bytes(16))) class EF_GBA_SK(TransparentEF):