aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2023-05-24 10:28:34 +0200
committerHarald Welte <laforge@osmocom.org>2023-05-25 22:23:07 +0200
commit0489ae67cfb62f15d70ea12ccd6fc93603fa7793 (patch)
tree3be6d52a2de50c2914eee52610442fb2316d76a8
parent2bee70cbac8c2fbff4c8809e125dc4833884e4a3 (diff)
cards.py: support ATR-based detection of sysmoISIM-SJA5
The cards are 99% software-compatible to the SJA2, so let's just derive the SJA5 class from the SJA2 Change-Id: I706631baaf447c49904277886bc9a3f6ba3f5532
-rw-r--r--pySim/cards.py29
-rw-r--r--pySim/sysmocom_sja2.py35
2 files changed, 61 insertions, 3 deletions
diff --git a/pySim/cards.py b/pySim/cards.py
index b48a80c..d5cd676 100644
--- a/pySim/cards.py
+++ b/pySim/cards.py
@@ -1656,11 +1656,38 @@ class SysmoISIMSJA2(UsimCard, IsimCard):
return
+class SysmoISIMSJA5(SysmoISIMSJA2):
+ """
+ sysmocom sysmoISIM-SJA5
+ """
+
+ name = 'sysmoISIM-SJA5'
+
+ @classmethod
+ def autodetect(kls, scc):
+ try:
+ # Try card model #1 (9FJ)
+ atr = "3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 51 CC"
+ if scc.get_atr() == toBytes(atr):
+ return kls(scc)
+ # Try card model #2 (SLM17)
+ atr = "3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 65 F8"
+ if scc.get_atr() == toBytes(atr):
+ return kls(scc)
+ # Try card model #3 (9FV)
+ atr = "3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4"
+ if scc.get_atr() == toBytes(atr):
+ return kls(scc)
+ except:
+ return None
+ return None
+
# In order for autodetection ...
_cards_classes = [FakeMagicSim, SuperSim, MagicSim, GrcardSim,
SysmoSIMgr1, SysmoSIMgr2, SysmoUSIMgr1, SysmoUSIMSJS1,
- FairwavesSIM, OpenCellsSim, WavemobileSim, SysmoISIMSJA2]
+ FairwavesSIM, OpenCellsSim, WavemobileSim, SysmoISIMSJA2,
+ SysmoISIMSJA5]
def card_detect(ctype, scc):
diff --git a/pySim/sysmocom_sja2.py b/pySim/sysmocom_sja2.py
index 4967701..e32943f 100644
--- a/pySim/sysmocom_sja2.py
+++ b/pySim/sysmocom_sja2.py
@@ -1,7 +1,7 @@
# coding=utf-8
-"""Utilities / Functions related to sysmocom SJA2 cards
+"""Utilities / Functions related to sysmocom SJA2/SJA5 cards
-(C) 2021 by Harald Welte <laforge@osmocom.org>
+(C) 2021-2023 by Harald Welte <laforge@osmocom.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -258,3 +258,34 @@ class SysmocomSJA2(CardModel):
EF_USIM_SQN(name='EF.ISIM_SQN'),
]
isim_adf.add_files(files_adf_isim)
+
+class SysmocomSJA5(CardModel):
+ _atrs = ["3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 51 CC",
+ "3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 65 F8",
+ "3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4"]
+
+ @classmethod
+ def add_files(cls, rs: RuntimeState):
+ """Add sysmocom SJA2 specific files to given RuntimeState."""
+ rs.mf.add_file(DF_SYSTEM())
+ # optional USIM application
+ if 'a0000000871002' in rs.mf.applications:
+ usim_adf = rs.mf.applications['a0000000871002']
+ files_adf_usim = [
+ EF_USIM_AUTH_KEY(),
+ EF_USIM_AUTH_KEY_2G(),
+ EF_GBA_SK(),
+ EF_GBA_REC_LIST(),
+ EF_GBA_INT_KEY(),
+ EF_USIM_SQN(),
+ ]
+ usim_adf.add_files(files_adf_usim)
+ # optional ISIM application
+ if 'a0000000871004' in rs.mf.applications:
+ isim_adf = rs.mf.applications['a0000000871004']
+ files_adf_isim = [
+ EF_USIM_AUTH_KEY(name='EF.ISIM_AUTH_KEY'),
+ EF_USIM_AUTH_KEY_2G(name='EF.ISIM_AUTH_KEY_2G'),
+ EF_USIM_SQN(name='EF.ISIM_SQN'),
+ ]
+ isim_adf.add_files(files_adf_isim)