Ejemplo n.º 1
0
    def update(self, cardconnection, ccevent):

        if 'connect' == ccevent.type:
            print('connecting to ' + cardconnection.getReader())

        elif 'disconnect' == ccevent.type:
            print('disconnecting from ' + cardconnection.getReader())

        elif 'command' == ccevent.type:
            print('> ' + toHexString(ccevent.args[0]))

        elif 'response' == ccevent.type:
            if [] == ccevent.args[0]:
                print('<  [] %-2X %-2X' % tuple(ccevent.args[-2:]))
            else:
                print('< ' + toHexString(ccevent.args[0]) + " " +
                      "%-2X %-2X" % tuple(ccevent.args[-2:]))
Ejemplo n.º 2
0
    def update(self, cardconnection, ccevent):

        if 'connect' == ccevent.type:
            print('connecting to ' + cardconnection.getReader())

        elif 'disconnect' == ccevent.type:
            print('disconnecting from ' + cardconnection.getReader())

        elif 'command' == ccevent.type:
            print('> ' + toHexString(ccevent.args[0]))

        elif 'response' == ccevent.type:
            if [] == ccevent.args[0]:
                print('<  [] %-2X %-2X' % tuple(ccevent.args[-2:]))
            else:
                print('< ' +
                      toHexString(ccevent.args[0]) + " " +
                      "%-2X %-2X" % tuple(ccevent.args[-2:]))
Ejemplo n.º 3
0
 def __init__(self, atr, mask=None):
     """ATRCardType constructor.
     atr:    the ATR of the CardType
     mask:   an optional mask to be applied to the ATR for CardType matching
             default is None
     """
     self.atr = list(atr)
     self.mask = mask
     if None == mask:
         self.maskedatr = self.atr
     else:
         if len(self.atr) != len(self.mask):
             raise InvalidATRMaskLengthException(toHexString(mask))
         self.maskedatr = list(map(lambda x, y: x & y, self.atr, self.mask))
Ejemplo n.º 4
0
 def __str__(self):
     """Returns a string representation of the ATR as a strem of bytes."""
     return toHexString(self.bytes)
Ejemplo n.º 5
0
        print('\tguard time: ' + str(self.getGuardTime()))

        print('nb of interface bytes: %d' % self.getInterfaceBytesCount())
        print('nb of historical bytes: %d' % self.getHistoricalBytesCount())

    def __str__(self):
        """Returns a string representation of the ATR as a strem of bytes."""
        return toHexString(self.bytes)


if __name__ == '__main__':
    """Small sample illustrating the use of ATR."""

    atrs = [[0x3F, 0x65, 0x25, 0x00, 0x2C, 0x09, 0x69, 0x90, 0x00],
             [0x3F, 0x65, 0x25, 0x08, 0x93, 0x04, 0x6C, 0x90, 0x00],
             [0x3B, 0x16, 0x94, 0x7C, 0x03, 0x01, 0x00, 0x00, 0x0D],
             [0x3B, 0x65, 0x00, 0x00, 0x9C, 0x11, 0x01, 0x01, 0x03],
             [0x3B, 0xE3, 0x00, 0xFF, 0x81, 0x31, 0x52, 0x45, 0xA1,
                0xA2, 0xA3, 0x1B],
             [0x3B, 0xE5, 0x00, 0x00, 0x81, 0x21, 0x45, 0x9C, 0x10,
                0x01, 0x00, 0x80, 0x0D]]

    for atr in atrs:
        a = ATR(atr)
        print(80 * '-')
        print(a)
        a.dump()
        print(toHexString(a.getHistoricalBytes()))

Ejemplo n.º 6
0
 def __str__(self):
     """Returns a string representation of the ATR as a strem of bytes."""
     return toHexString(self.bytes)
Ejemplo n.º 7
0
        print('nb of interface bytes: %d' % self.getInterfaceBytesCount())
        print('nb of historical bytes: %d' % self.getHistoricalBytesCount())

    def __str__(self):
        """Returns a string representation of the ATR as a strem of bytes."""
        return toHexString(self.bytes)


if __name__ == '__main__':
    """Small sample illustrating the use of ATR."""

    atrs = [[0x3F, 0x65, 0x25, 0x00, 0x2C, 0x09, 0x69, 0x90, 0x00],
            [0x3F, 0x65, 0x25, 0x08, 0x93, 0x04, 0x6C, 0x90, 0x00],
            [0x3B, 0x16, 0x94, 0x7C, 0x03, 0x01, 0x00, 0x00, 0x0D],
            [0x3B, 0x65, 0x00, 0x00, 0x9C, 0x11, 0x01, 0x01, 0x03],
            [
                0x3B, 0xE3, 0x00, 0xFF, 0x81, 0x31, 0x52, 0x45, 0xA1, 0xA2,
                0xA3, 0x1B
            ],
            [
                0x3B, 0xE5, 0x00, 0x00, 0x81, 0x21, 0x45, 0x9C, 0x10, 0x01,
                0x00, 0x80, 0x0D
            ]]

    for atr in atrs:
        a = ATR(atr)
        print(80 * '-')
        print(a)
        a.dump()
        print(toHexString(a.getHistoricalBytes()))
Ejemplo n.º 8
0
 def __repr__(self):
     """Return a string representing the Card (atr and reader
     concatenation)."""
     return toHexString(self.atr) + ' / ' + str(self.reader)