示例#1
0
    def test_unmarshal(self):
        pdu = RAPDU.unmarshal([0x90, 0x00])
        self.assertIs(type(pdu), SuccessResponse)

        pdu = RAPDU.unmarshal([0x63, 0xC2])
        self.assertIs(type(pdu), WarningResponse)

        with self.assertRaises(ErrorResponse):
            RAPDU.unmarshal([0x6A, 0x81])
示例#2
0
def test_unmarshal():
    pdu = RAPDU.unmarshal([0x90, 0x00])
    assert type(pdu) is SuccessResponse

    pdu = RAPDU.unmarshal([0x63, 0xC2])
    assert type(pdu) is WarningResponse

    with pytest.raises(ErrorResponse):
        RAPDU.unmarshal([0x6A, 0x81])
示例#3
0
 def test_pinsentry_equivalence(self):
     # Real response from barclays-pinsentry.c, with its calculated response
     data = unformat_bytes(
         '80 12 80 09 5F 0F 9D 37 98 E9 3F 12 9A 06 0A 0A 03 A4 90 00 90 00'
     )
     res = RAPDU.unmarshal(data)
     self.assertEqual(get_cap_value(res), 46076570)
示例#4
0
def test_real_response_rmtf2():
    # Real response from a new (2018) Barclays card using RMTF2 response format.
    data = unformat_bytes(
        """77 1E 9F 27 01 80 9F 36 02 00 16 9F 26 08 29 9C C8 F1 0B 9B C8
                             30 9F 10 07 06 0B 0A 03 A4 90 00""")
    res = RAPDU.unmarshal(data)
    assert get_cap_value(res, ipb=BARCLAYS_IPB, psn=None) == 36554800
示例#5
0
def test_real_response_rmtf1():
    # Real response from barclays-pinsentry.c, with its calculated response.
    # This was an older card which used the RMTF1 response format
    data = unformat_bytes(
        "80 12 80 09 5F 0F 9D 37 98 E9 3F 12 9A 06 0A 0A 03 A4 90 00 90 00")
    res = RAPDU.unmarshal(data)
    assert get_cap_value(res, ipb=BARCLAYS_IPB, psn=None) == 46076570