This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Alexander Chemeris gerrit-no-reply at lists.osmocom.orgAlexander Chemeris has submitted this change and it was merged. Change subject: cards: Implement card type autodetection based on ATR. ...................................................................... cards: Implement card type autodetection based on ATR. Change-Id: I1099a96626c0ce74243b47a8fdfa25b0d76a1ef3 --- M pySim/cards.py 1 file changed, 21 insertions(+), 2 deletions(-) Approvals: Vadim Yanitskiy: Looks good to me, but someone else must approve Alexander Chemeris: Verified Harald Welte: Looks good to me, approved diff --git a/pySim/cards.py b/pySim/cards.py index db63d2b..046766e 100644 --- a/pySim/cards.py +++ b/pySim/cards.py @@ -25,6 +25,7 @@ from pySim.ts_51_011 import EF, DF from pySim.utils import * +from smartcard.util import toBytes class Card(object): @@ -418,7 +419,12 @@ @classmethod def autodetect(kls, scc): - # TODO: look for ATR 3B 7D 94 00 00 55 55 53 0A 74 86 93 0B 24 7C 4D 54 68 + try: + # Look for ATR + if scc.get_atr() == toBytes("3B 7D 94 00 00 55 55 53 0A 74 86 93 0B 24 7C 4D 54 68"): + return kls(scc) + except: + return None return None def program(self, p): @@ -494,7 +500,12 @@ @classmethod def autodetect(kls, scc): - # TODO: look for ATR 3B 9F 96 80 1F C7 80 31 A0 73 BE 21 13 67 43 20 07 18 00 00 01 A5 + try: + # Look for ATR + if scc.get_atr() == toBytes("3B 9F 96 80 1F C7 80 31 A0 73 BE 21 13 67 43 20 07 18 00 00 01 A5"): + return kls(scc) + except: + return None return None def program(self, p): @@ -537,3 +548,11 @@ # In order for autodetection ... _cards_classes = [ FakeMagicSim, SuperSim, MagicSim, GrcardSim, SysmoSIMgr1, SysmoSIMgr2, SysmoUSIMgr1, SysmoUSIMSJS1 ] + +def card_autodetect(scc): + for kls in _cards_classes: + card = kls.autodetect(scc) + if card is not None: + card.reset() + return card + return None -- To view, visit https://gerrit.osmocom.org/5721 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I1099a96626c0ce74243b47a8fdfa25b0d76a1ef3 Gerrit-PatchSet: 2 Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Owner: Alexander Chemeris <Alexander.Chemeris at gmail.com> Gerrit-Reviewer: Alexander Chemeris <Alexander.Chemeris at gmail.com> Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org> Gerrit-Reviewer: Vadim Yanitskiy <axilirator at gmail.com>