3

am working with NFC Android programming and I want to read Mifare Classic cards. Does anybody know how to read the sectors off such a card?

Authentication method returns true which means that authentication is done. After authentication, sector should be ready for any IO action but whenever i use readBlock() method or transceive() method, I get exception with IOException("transceive failed"). I can not find any example which uses the Mifare Classic, so i want to know if it is possible to read the Mifare Classic with this API or not.

My code like this boolean success = m1tag.authenticateSectorWithKeyB(0,MifareClassic。KEY_DEFAULT) int index = m1tag.sectorToBlock(0) byte[] content = m1tag.readBlock(index)

success is true,but when i read content from card,throw IOException("transceive failed")

user556615
  • 31
  • 1
  • 3

2 Answers2

1

You won't be able to readBlock() or writeBlock() after using authenticateSectorWithKeyB(). If it is a new tag with default access bits access to the tag will be blocked. If the access conditions have be changed then readBlock() and writeBlock() will throw an exception. You will have to perform reading of the tag using KeyA authentication.

0

You can not read the Block of a mifare card by authonticating with keyB. To read the block of Mifare card, you will have to aunthenticae with key A i.e. use authenticateSectorWithKeyA() instead of authenticateSectorWithKeyB().

biegleux
  • 13,179
  • 11
  • 45
  • 52
sam
  • 1
  • 4
  • That is not true. Depending on the access control configuration of the blocks in the sector trailer, key B can be used to read blocks. However, the default configuration from the manufacturer ("empty card") is such that key B cannot be used to read the blocks. – NFC guy Aug 30 '12 at 19:50
  • @NFCguy Can you please provide your valuable opinion on http://stackoverflow.com/questions/17220523/card-emulation-via-software-nfc – user720694 Jun 21 '13 at 06:10