miguelbalboa / rfid

Arduino RFID Library for MFRC522
The Unlicense
2.75k stars 1.43k forks source link

changed authentication key, I don't know how to access the block now #489

Closed dorindabassey closed 5 years ago

dorindabassey commented 5 years ago

hi, am a newbie but I've been read about rfid tags for sometime now, my issue is-

i used the changekey example code to change the authentication keys of my rfid cards now i can't access the block where i changed authentication key, so i tried to run the dumpinfo example code and it shows problemcom port

dorindabassey commented 5 years ago

uhh, I actually changed authentication key from sector 2 to sector 15

dorindabassey commented 5 years ago

so how can I gain access to my cards with my new authentication key

thanks in advance

nedoskiv commented 5 years ago

you need to authenticate to block with new key, if you do not know what is the new key you write, throw chip away and start with new one :)

dorindabassey commented 5 years ago

okay, so I know the new key, please how do I authenticate the block with the new key thanks

nedoskiv commented 5 years ago

here is how I define my key

  MFRC522::MIFARE_Key key;
//  for (byte i = 0; i < 5; i++) key.keyByte[i] = 0xFF;
  key.keyByte[0] = 0xFF;
  key.keyByte[1] = 0xFF;
  key.keyByte[2] = 0xFF;
  key.keyByte[3] = 0xFF;
  key.keyByte[4] = 0xFF;
  key.keyByte[5] = 0x77;

if you cannot understand that part, should move your question to arduino forums for complete solution

dorindabassey commented 5 years ago

okay thanks, well, I made some changes like this

void loop() {

// Prepare key - all keys are set to FFFFFFFFFFFFh at chip delivery from the factory. MFRC522::MIFARE_Key key; for (byte i = 0; i < 6; i++) key.keyByte[i] = 0xCC;//my new authentication key

//some variables we need byte block; byte len; MFRC522::StatusCode status;

//-------------------------------------------

and when I tried to execute the readpersonaldatafromtag example I edited, it still showed authentication failed

dorindabassey commented 5 years ago

*my new authentication keys were set to 0xCC

nedoskiv commented 5 years ago

changing auth key is a bit tricky, when you write new key there is some access bits that need to be set in proper way, if you do not do that correctly, sector got bricked. So I suggest you start read something about mifare 1k documentation before start playing with authentication keys

dorindabassey commented 5 years ago

😢 thanks, but am not satisfied, I don't think the sector is broken😕, I'll read some more though

nedoskiv commented 5 years ago

what code you use to set new authentication key?

dorindabassey commented 5 years ago

https://github.com/miguelbalboa/rfid/wiki/How-to-change-keys%3F

nedoskiv commented 5 years ago

Well I never used that function, I was writed my own, but on different platform to change keys. I'm not sure if that function set properly access bits. You can play with another sector/block and experiment before throw chip on garbage, you have 14 more sectors to brick :)

meanwhile I was starting to looking for alternative library since this one cannot hangle some readers.

dorindabassey commented 5 years ago

HI, thanks so much, for (byte i = 0; i < 6; i++) key.keyByte[i] = 0xCC;//my new authentication key

this did the trick, the problem was my code, I was busy trying to read block1 that had a different authentication key, but now I've changed all my sectors from 1 to 15 authentication key to 0xCC and am good to go. thanks😃.

nedoskiv commented 5 years ago

good, now close that issue please

dorindabassey commented 5 years ago

oww. I thought I did thanks