예제 #1
0
 def __init__(self):
     self.session = None
     if len(smartcard.listReaders()) == 0:
         print("No reader found")
     else:
         self.session = smartcard.Session()
         print("Reader selected")
예제 #2
0
    def __init__(self, reader=0):
        self.connection = None

        readers_list = smartcard.listReaders()
        if not readers_list:
            raise Exception('No smartcard readers were found')
        try:
            readers = smartcard.System.readers()
            if isinstance(reader, int):
                self.reader = readers[reader]
            elif isinstance(reader, str):
                self.reader = readers[readers_list.index(reader)]
            else:
                raise Exception('Wrong reader parameter: "%s"' % reader)
            self.connection = self.reader.createConnection()
        except KeyError:
            raise Exception('Specified smartcard reader was not found')
예제 #3
0
 def testcase_legacyreaders(self):
     foundreaders = {}
     for reader in listReaders():
         foundreaders[reader] = 1
     for reader in expectedReaders:
         self.assertTrue(reader in foundreaders)
예제 #4
0
 def testcase_legacyreaders(self):
     foundreaders = {}
     for reader in listReaders():
         foundreaders[reader] = 1
     for reader in expectedReaders:
         self.assert_(reader in foundreaders)
예제 #5
0
 def getCardReaderList(self):
     return smartcard.listReaders()
예제 #6
0
import smartcard
from smartcard.util import *
from compiler.pycodegen import EXCEPT


def printAsHex(data):
    l = len(data)
    hexList = []
    n = 0
    while n < len(data):
        hexList.append(hex(data[n]))
        n += 1
    return (hexList)


readers = smartcard.listReaders()
if len(readers) > 0:
    print "Available readers: ", readers
    print("using reader ", readers[0])

try:
    session = smartcard.Session(readers[0])
except smartcard.Exceptions.NoCardException:
    print('Unable to connect to card or no card in reader')
    exit("Exit on error")

print "\n### START SELECT EF.dir"

SELECT = [0x00, 0xA4, 0x02, 0x0C, 0x02]
EFDIR = [0x2F, 0x00]
예제 #7
0
 def testcase_legacyreaders(self):
     foundreaders = {}
     for reader in listReaders():
         foundreaders[reader] = 1
     for reader in expectedReaders:
         self.assert_(foundreaders.has_key(reader))