miguelbalboa / rfid

Arduino RFID Library for MFRC522
The Unlicense
2.79k stars 1.45k forks source link

fail to authenticate with keyB #490

Closed Rita858 closed 4 years ago

Rita858 commented 5 years ago

Step 1: Describe your environment

Step 2: Describe the problem

First of all,thanks to your library. Here is the problem:

Affected file(s) or example(s):

Steps to reproduce:

  1. access bit:g[0] = 000 g[1] = 110 g[2] = 000 g[3] = 001 mfrc522.MIFARE_SetAccessBits(&trailerBuffer[6], 0, 6, 0, 1);
  2. keyA and keyB = FF FF FF FF FF FF
  3. wirte 100 into a value block: mfrc522.MIFARE_SetValue(valueBlock, 100)

Relevant Code:

status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_B, (sector * 4 + 3), &key, &(mfrc522.uid));
  if (status != MFRC522::STATUS_OK) {
    Serial.print(F("PCD_Authenticate() failed: "));
    Serial.println(mfrc522.GetStatusCodeName(status));
    return;
  }

  status = mfrc522.MIFARE_SetValue(valueBlock, 100);
  if (status != MFRC522::STATUS_OK) {
    Serial.print(F("mifare_SetValue() failed: "));
    Serial.println(mfrc522.GetStatusCodeName(status));
    return;
  }

Observed Results:

Rotzbua commented 4 years ago

@Rita-GE Any update? Otherwise I close this.