예제 #1
0
 def open_connection(self, connection_type):
     if issubclass(ScardSmartCardConnection, connection_type):
         return self._open_smartcard_connection()
     elif issubclass(CtapPcscDevice, connection_type):
         if self.transport == TRANSPORT.NFC:
             return CtapPcscDevice(self.reader.createConnection(), self.reader.name)
     return super(ScardYubiKeyDevice, self).open_connection(connection_type)
예제 #2
0
    def test_pcsc_call_version_1(self):
        connection = mock.Mock()
        connection.transmit.side_effect = [(b"U2F_V2", 0x90, 0x00),
                                           (b"", 0x63, 0x85)]

        dev = CtapPcscDevice(connection, "Mock")

        self.assertEqual(dev.version, 1)
예제 #3
0
    def test_pcsc_call_cbor(self):
        connection = mock.Mock()
        connection.transmit.side_effect = [(b"U2F_V2", 0x90, 0x00),
                                           (b"", 0x90, 0x00)]

        CtapPcscDevice(connection, "Mock")

        connection.transmit.assert_called_with(
            [0x80, 0x10, 0x80, 0x00, 0x01, 0x04, 0x00], None)
예제 #4
0
    def test_pcsc_call_version_2(self):
        connection = mock.Mock()
        connection.transmit.side_effect = [
            (b'U2F_V2', 0x90, 0x00),
            (b'', 0x90, 0x00),
        ]

        dev = CtapPcscDevice(connection, 'Mock')

        self.assertEqual(dev.version, 2)
예제 #5
0
    def test_pcsc_call_u2f(self):
        connection = mock.Mock()
        connection.transmit.side_effect = [(b'U2F_V2', 0x90, 0x00),
                                           (b'', 0x90, 0x00),
                                           (b'u2f_resp', 0x90, 0x00)]

        dev = CtapPcscDevice(connection, 'Mock')
        res = dev.call(CTAPHID.MSG,
                       b'\x00\x01\x00\x00\x05' + b'\x01' * 5 + b'\x00')

        connection.transmit.assert_called_with(
            [0x00, 0x01, 0x00, 0x00, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00],
            None)
        self.assertEqual(res, b'u2f_resp\x90\x00')
예제 #6
0
    def test_pcsc_call_u2f(self):
        connection = mock.Mock()
        connection.transmit.side_effect = [
            (b"U2F_V2", 0x90, 0x00),
            (b"", 0x90, 0x00),
            (b"u2f_resp", 0x90, 0x00),
        ]

        dev = CtapPcscDevice(connection, "Mock")
        res = dev.call(CTAPHID.MSG,
                       b"\x00\x01\x00\x00\x05" + b"\x01" * 5 + b"\x00")

        connection.transmit.assert_called_with(
            [0x00, 0x01, 0x00, 0x00, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00],
            None)
        self.assertEqual(res, b"u2f_resp\x90\x00")