-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:
oepen
2011-07-26 12:30:18 +00:00
parent 14fb0aefe9
commit 43df314a5e
4 changed files with 15 additions and 8 deletions

View File

@@ -15,7 +15,10 @@
#
# You should have received a copy of the GNU General Public License along with
# virtualsmartcard. If not, see <http://www.gnu.org/licenses/>.
#
MAX_SHORT_LE = 0xff
MAX_EXTENDED_LE = 0xffff
# Life cycle status byte {{{
LCB = {}
LCB["NOINFORMATION"] = 0x00

View File

@@ -45,8 +45,6 @@ TAG["OFFSET_DATA"] = 0x54
TAG["TAG_LIST"] = 0x5C
TAG["HEADER_LIST"] = 0x5D
TAG["EXTENDED_HEADER_LIST"] = 0x4D
MAX_EXTENDED_LE = 0xffff
MAX_SHORT_LE = 0xff
def tlv_unpack(data): # {{{
ber_class = (ord(data[0]) & 0xC0) >> 6

View File

@@ -61,7 +61,7 @@ class SmartcardOS(object): # {{{
# }}}
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.SAM = sam
@@ -107,10 +107,15 @@ class Iso7816OS(SmartcardOS): # {{{
else:
self.ins2handler = ins2handler
self.maxle = maxle
if extended_length:
self.maxle = MAX_EXTENDED_LE
else:
self.maxle = MAX_SHORT_LE
self.lastCommandOffcut = ""
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,
histChars = chr(0x80) + chr(0x70 + len(card_capabilities)) +
card_capabilities)

View File

@@ -17,6 +17,7 @@
# virtualsmartcard. If not, see <http://www.gnu.org/licenses/>.
#
import string, binascii
from ConstantDefinitions import MAX_SHORT_LE, MAX_EXTENDED_LE
def stringtoint(str): # {{{
#i = len(str) - 1
@@ -298,9 +299,9 @@ class C_APDU(APDU):
def effective_Le(self):
if hasattr(self, "_Le") and (self.Le == 0):
if self.__extended_length:
return 0xffff
return MAX_EXTENDED_LE
else:
return 0xff
return MAX_SHORT_LE
else:
return self.Le