-Moved MAX_LE defines to ConstantDefinitions
-Added a parameter to control whether or not an ISO card supports extended length APDUs -Correctly indicating extended length support in the ATR git-svn-id: https://vsmartcard.svn.sourceforge.net/svnroot/vsmartcard@439 96b47cad-a561-4643-ad3b-153ac7d7599c
This commit is contained in:
@@ -15,7 +15,10 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License along with
|
# You should have received a copy of the GNU General Public License along with
|
||||||
# virtualsmartcard. If not, see <http://www.gnu.org/licenses/>.
|
# virtualsmartcard. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
|
||||||
|
MAX_SHORT_LE = 0xff
|
||||||
|
MAX_EXTENDED_LE = 0xffff
|
||||||
|
|
||||||
# Life cycle status byte {{{
|
# Life cycle status byte {{{
|
||||||
LCB = {}
|
LCB = {}
|
||||||
LCB["NOINFORMATION"] = 0x00
|
LCB["NOINFORMATION"] = 0x00
|
||||||
|
|||||||
@@ -45,8 +45,6 @@ TAG["OFFSET_DATA"] = 0x54
|
|||||||
TAG["TAG_LIST"] = 0x5C
|
TAG["TAG_LIST"] = 0x5C
|
||||||
TAG["HEADER_LIST"] = 0x5D
|
TAG["HEADER_LIST"] = 0x5D
|
||||||
TAG["EXTENDED_HEADER_LIST"] = 0x4D
|
TAG["EXTENDED_HEADER_LIST"] = 0x4D
|
||||||
MAX_EXTENDED_LE = 0xffff
|
|
||||||
MAX_SHORT_LE = 0xff
|
|
||||||
|
|
||||||
def tlv_unpack(data): # {{{
|
def tlv_unpack(data): # {{{
|
||||||
ber_class = (ord(data[0]) & 0xC0) >> 6
|
ber_class = (ord(data[0]) & 0xC0) >> 6
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ class SmartcardOS(object): # {{{
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
class Iso7816OS(SmartcardOS): # {{{
|
class Iso7816OS(SmartcardOS): # {{{
|
||||||
def __init__(self, mf, sam, ins2handler=None, maxle=MAX_SHORT_LE):
|
def __init__(self, mf, sam, ins2handler=None, extended_length=False):
|
||||||
self.mf = mf
|
self.mf = mf
|
||||||
self.SAM = sam
|
self.SAM = sam
|
||||||
|
|
||||||
@@ -107,10 +107,15 @@ class Iso7816OS(SmartcardOS): # {{{
|
|||||||
else:
|
else:
|
||||||
self.ins2handler = ins2handler
|
self.ins2handler = ins2handler
|
||||||
|
|
||||||
self.maxle = maxle
|
if extended_length:
|
||||||
|
self.maxle = MAX_EXTENDED_LE
|
||||||
|
else:
|
||||||
|
self.maxle = MAX_SHORT_LE
|
||||||
|
|
||||||
self.lastCommandOffcut = ""
|
self.lastCommandOffcut = ""
|
||||||
self.lastCommandSW = SW["NORMAL"]
|
self.lastCommandSW = SW["NORMAL"]
|
||||||
card_capabilities = self.mf.firstSFT + self.mf.secondSFT + Iso7816OS.makeThirdSoftwareFunctionTable()
|
card_capabilities = self.mf.firstSFT + self.mf.secondSFT + \
|
||||||
|
Iso7816OS.makeThirdSoftwareFunctionTable(extendedLe = extended_length)
|
||||||
self.atr = Iso7816OS.makeATR(T=1, directConvention = True, TA1=0x13,
|
self.atr = Iso7816OS.makeATR(T=1, directConvention = True, TA1=0x13,
|
||||||
histChars = chr(0x80) + chr(0x70 + len(card_capabilities)) +
|
histChars = chr(0x80) + chr(0x70 + len(card_capabilities)) +
|
||||||
card_capabilities)
|
card_capabilities)
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
# virtualsmartcard. If not, see <http://www.gnu.org/licenses/>.
|
# virtualsmartcard. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
import string, binascii
|
import string, binascii
|
||||||
|
from ConstantDefinitions import MAX_SHORT_LE, MAX_EXTENDED_LE
|
||||||
|
|
||||||
def stringtoint(str): # {{{
|
def stringtoint(str): # {{{
|
||||||
#i = len(str) - 1
|
#i = len(str) - 1
|
||||||
@@ -298,9 +299,9 @@ class C_APDU(APDU):
|
|||||||
def effective_Le(self):
|
def effective_Le(self):
|
||||||
if hasattr(self, "_Le") and (self.Le == 0):
|
if hasattr(self, "_Le") and (self.Le == 0):
|
||||||
if self.__extended_length:
|
if self.__extended_length:
|
||||||
return 0xffff
|
return MAX_EXTENDED_LE
|
||||||
else:
|
else:
|
||||||
return 0xff
|
return MAX_SHORT_LE
|
||||||
else:
|
else:
|
||||||
return self.Le
|
return self.Le
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user