decode_cla: label standard ETSI class bytes precisely

CLA 0x80 is the ETSI/3GPP-defined UICC/USIM class (TS 102 221 Table 10.3),
not ISO 7816-4 'proprietary'. Relabel 0x80 -> ETSI-defined (UICC/USIM),
0xA0 -> ETSI-defined (SIM/GSM), 0x00 -> inter-industry (ISO 7816-4);
drop the now-redundant note field.
This commit is contained in:
catarrh committed 2026-08-13 09:14:41 +03:00
1 parent 4e67948dce
commit 6b2bcefbac
1 file changed
+7 -7
+7 -7
View File
@@ -103,12 +103,14 @@ def decode_sw(raw_sw):
def decode_cla(cla): def decode_cla(cla):
chain_bits = (cla >> 4) & 0x03 chain_bits = (cla >> 4) & 0x03
chain_names = {0: 'last or only', 1: 'first in chain', 2: 'not last in chain', 3: 'not last'} chain_names = {0: 'last or only', 1: 'first in chain', 2: 'not last in chain', 3: 'not last'}
interclass = 'inter-industry' if (cla & 0x80) == 0 else 'proprietary' if cla == 0x80:
note = None interclass = 'ETSI-defined (UICC/USIM)'
if cla in (0xa0, 0x80): elif cla == 0xa0:
note = 'standard UICC CLA' interclass = 'ETSI-defined (SIM/GSM)'
elif cla == 0x00: elif cla == 0x00:
note = 'standard inter-industry CLA' interclass = 'inter-industry (ISO 7816-4)'
else:
interclass = 'inter-industry' if (cla & 0x80) == 0 else 'proprietary'
result = { result = {
'hex': f'{cla:02x}', 'hex': f'{cla:02x}',
'interclass': interclass, 'interclass': interclass,
@@ -116,8 +118,6 @@ def decode_cla(cla):
'secure_messaging': 'none' if (cla & 0x0c) == 0 else 'SM present', 'secure_messaging': 'none' if (cla & 0x0c) == 0 else 'SM present',
'chain': chain_names.get(chain_bits, f'unknown ({chain_bits})'), 'chain': chain_names.get(chain_bits, f'unknown ({chain_bits})'),
} }
if note:
result['note'] = note
return result return result