-
Notifications
You must be signed in to change notification settings - Fork 609
Description
Iot.Device.Mfrc522.ListenToCardIso14443TypeA invokes PiccRequestA to perform a REQA, which returns the answer (ATQA) as a 2-byte array. ListenToCard14443TypeA converts this into a ushort. However, it treats the two bytes as a big-endian integer, whereas ISO 14443-3 specifies that the bits are sent from LSB to MSB. The MFRC522 reverses the bits within each byte but doesn't reverse the byte order. Therefore, the conversion should treat these two bytes as a little-endian integer.
Repro: listen for a Mifare Classic 1K card on an MFRC522. The expected ATQA is 0x0004 but the value 0x0400 is reported. As an example, Iot.Device.Card.Mifare.MifareCard.SetCapacity is unable to compute the card capacity when using an MFRC522, because the expected and reported ATQA values do not match.
Suggested fix: compute the ushort using
card.Atqa = BinaryPrimitives.ReadUInt16LittleEndian(atqa);