Exemplo n.º 1
0
 def __init__(self, name, config):
     self.token = Token.get(name, config[name])
     self.protocol = config[name].get('protocol', 2)
     self.cards = {}
     self.lockedby = 0
     # reentrant to authorize nested transactions
     self.transaction = CardRLock()
Exemplo n.º 2
0
    def testLoader(self):
        tkn = Token.get("pycsc", self._testConfig())

        # Finally, check that our applet is registered !
        self.assertEquals(1, len(tkn.applets))
        aid = tkn.applets.keys()[0]
        self.assert_(aid.equals([0xA0, 0, 0, 0, 0], 0, 5))
Exemplo n.º 3
0
    def testSelect(self):
        tkn = Token.get("pycsc", self._testConfig())

        self.assertEquals(None, tkn.selected)

        tkn._cmselect([0, 0, 0, 0, 5, 0xA0, 0, 0, 0, 0])
        self.assertEquals(tkn.applets[tkn.applets.keys()[0]], tkn.selected)

        try:
            tkn._cmselect([0, 0, 0, 0, 5, 0xA0, 0, 9, 0, 0])
            self.fail()
        except ISOException, ie:
            self.assertEquals(ISO7816.SW_FILE_NOT_FOUND, ie.getReason())
Exemplo n.º 4
0
    def testSelectViaTransmit(self):
        tkn = Token.get("pycsc", self._testConfig())
        self.assertEquals(None, tkn.selected)

        hresult, response = tkn.transmit([0, 0xA4, 0, 0, 5, 0xA0, 0, 0, 0, 0])
        self.assertEquals(0, hresult)
        self.assertEquals([0x90, 0x00], response)
        self.assertEquals(tkn.applets[tkn.applets.keys()[0]], tkn.selected)

        hresult, response = tkn.transmit([0, 0xA4, 0, 0, 5, 0xA0, 0, 0, 9, 0])
        self.assertEquals(0, hresult)
        self.assertEquals([0x6A, 0x82], response)  # No such File

        self.assertEquals(tkn.applets[tkn.applets.keys()[0]], tkn.selected)
Exemplo n.º 5
0
 def testLoad(self):
     tkn = Token.get("pycsc", self._testConfig())