card: re-add capability to find USIM cards by ATR
de31d9f88b
removes the ability to select
USIM cards by specifiying their ATR. This feature is needed to
properly distinguish symo-usim-sjs1 and sysmo-isim-sja2 from other
cards.
This commit is contained in:
parent
fd95de36de
commit
a767cec4d0
|
@ -35,6 +35,7 @@ import re
|
||||||
|
|
||||||
# smartcard python modules from pyscard
|
# smartcard python modules from pyscard
|
||||||
from smartcard.CardType import AnyCardType
|
from smartcard.CardType import AnyCardType
|
||||||
|
from smartcard.CardType import ATRCardType
|
||||||
from smartcard.CardRequest import CardRequest
|
from smartcard.CardRequest import CardRequest
|
||||||
from smartcard.CardConnection import CardConnection
|
from smartcard.CardConnection import CardConnection
|
||||||
from smartcard.ATR import ATR
|
from smartcard.ATR import ATR
|
||||||
|
@ -141,7 +142,7 @@ class ISO7816(object):
|
||||||
0xAB : 'Security Attribute expanded',
|
0xAB : 'Security Attribute expanded',
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, CLA=0x00):
|
def __init__(self, atr=None, CLA=0x00):
|
||||||
"""
|
"""
|
||||||
connect smartcard and defines class CLA code for communication
|
connect smartcard and defines class CLA code for communication
|
||||||
uses "pyscard" library services
|
uses "pyscard" library services
|
||||||
|
@ -149,7 +150,10 @@ class ISO7816(object):
|
||||||
creates self.CLA attribute with CLA code
|
creates self.CLA attribute with CLA code
|
||||||
and self.coms attribute with associated "apdu_stack" instance
|
and self.coms attribute with associated "apdu_stack" instance
|
||||||
"""
|
"""
|
||||||
cardtype = AnyCardType()
|
if (atr):
|
||||||
|
cardtype = ATRCardType(atr)
|
||||||
|
else:
|
||||||
|
cardtype = AnyCardType()
|
||||||
cardrequest = CardRequest(timeout=1, cardType=cardtype)
|
cardrequest = CardRequest(timeout=1, cardType=cardtype)
|
||||||
self.cardservice = cardrequest.waitforcard()
|
self.cardservice = cardrequest.waitforcard()
|
||||||
self.cardservice.connection.connect()
|
self.cardservice.connection.connect()
|
||||||
|
|
|
@ -100,12 +100,12 @@ class SIM(ISO7816):
|
||||||
use self.dbg = 1 or more to print live debugging information
|
use self.dbg = 1 or more to print live debugging information
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, atr = None):
|
||||||
"""
|
"""
|
||||||
initialize like an ISO7816-4 card with CLA=0xA0
|
initialize like an ISO7816-4 card with CLA=0xA0
|
||||||
can also be used for USIM working in SIM mode,
|
can also be used for USIM working in SIM mode,
|
||||||
"""
|
"""
|
||||||
ISO7816.__init__(self, CLA=0xA0)
|
ISO7816.__init__(self, atr, CLA=0xA0)
|
||||||
|
|
||||||
if self.dbg >= 2:
|
if self.dbg >= 2:
|
||||||
log(3, '(SIM.__init__) type definition: %s' % type(self))
|
log(3, '(SIM.__init__) type definition: %s' % type(self))
|
||||||
|
|
|
@ -177,7 +177,7 @@ class USIM(UICC):
|
||||||
use self.dbg = 1 or more to print live debugging information
|
use self.dbg = 1 or more to print live debugging information
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, atr = None):
|
||||||
"""
|
"""
|
||||||
initializes like an ISO7816-4 card with CLA=0x00
|
initializes like an ISO7816-4 card with CLA=0x00
|
||||||
and checks available AID (Application ID) read from EF_DIR
|
and checks available AID (Application ID) read from EF_DIR
|
||||||
|
@ -185,7 +185,7 @@ class USIM(UICC):
|
||||||
initializes on the MF
|
initializes on the MF
|
||||||
"""
|
"""
|
||||||
# initialize like a UICC
|
# initialize like a UICC
|
||||||
ISO7816.__init__(self, CLA=0x00)
|
ISO7816.__init__(self, atr, CLA=0x00)
|
||||||
self.AID = []
|
self.AID = []
|
||||||
|
|
||||||
if self.dbg >= 2:
|
if self.dbg >= 2:
|
||||||
|
|
|
@ -85,7 +85,7 @@ class Simcard():
|
||||||
# Constructor: Create a new simcard object
|
# Constructor: Create a new simcard object
|
||||||
def __init__(self, cardtype = GSM_USIM, atr = None):
|
def __init__(self, cardtype = GSM_USIM, atr = None):
|
||||||
if cardtype == GSM_USIM:
|
if cardtype == GSM_USIM:
|
||||||
self.card = USIM()
|
self.card = USIM(atr)
|
||||||
self.usim = True
|
self.usim = True
|
||||||
|
|
||||||
# Detect ISIM / USIM applications
|
# Detect ISIM / USIM applications
|
||||||
|
|
Loading…
Reference in New Issue