def test_serialise_long_data(self): dol = DOL.unmarshal(self.dol_data) # First tag is too long for the DOL source = { Tag(0x9A): [0x01, 0x01, 0x01, 0x02], Tag(0x95): [0x80, 0x00, 0x00, 0x00, 0x00] } with self.assertRaises(Exception): dol.serialise(source)
def test_serialise_long_data(): dol = DOL.unmarshal(dol_data) # First tag is too long for the DOL source = { Tag(0x9A): [0x01, 0x01, 0x01, 0x02], Tag(0x95): [0x80, 0x00, 0x00, 0x00, 0x00], } with pytest.raises(Exception): dol.serialise(source)
def test_serialise(self): dol = DOL.unmarshal(self.dol_data) # Parameters to GENERATE APPLICATION CRYPTOGRAM from barclays-pinsentry.c: data = unformat_bytes( '''00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 00 00 00 00 00 00 01 01 01 00 00 00 00 00''') tlv = dol.unserialise(data) self.assertEqual(tlv[0x9A], [1, 1, 1]) # Re-serialise by round trip self.assertEqual(dol.serialise(tlv), data) # Serialise with partial data source = { Tag(0x9A): [0x01, 0x01, 0x01], Tag(0x95): [0x80, 0x00, 0x00, 0x00, 0x00] } serialised = dol.serialise(source) self.assertEqual(serialised, data)
def test_serialise(): dol = DOL.unmarshal(dol_data) # Parameters to GENERATE APPLICATION CRYPTOGRAM from barclays-pinsentry.c: data = unformat_bytes( """00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 00 00 00 00 00 00 01 01 01 00 00 00 00 00""" ) tlv = dol.unserialise(data) assert tlv[0x9A] == [1, 1, 1] # Re-serialise by round trip assert dol.serialise(tlv) == data # Serialise with partial data source = { Tag(0x9A): [0x01, 0x01, 0x01], Tag(0x95): [0x80, 0x00, 0x00, 0x00, 0x00], } serialised = dol.serialise(source) assert serialised == data