So I am using this library: https://github.com/ekapujiw2002/... with an Atmega328P reading and writing to the Mifare 1k classic NFC tag using the RC522 chip. The tag's datasheet can be found here: https://www.nxp.com/docs/en/data...
However... No where in the datasheet I've found how to password-protect it (so that nobody can write to it unless a password is provided).
At the library, this is the authentication method used:
/* * Function Name : MFRC522_Auth * Description : Verify card password * Input parameters : authMode - Password Authentication Mode 0x60 = A key authentication 0x61 = B key authentication BlockAddr - block address Sectorkey - Sector password serNum - card serial number, 4-byte * Return value: the successful return CARD_FOUND */ uint8_t mfrc522_auth(uint8_t authMode, uint8_t BlockAddr, uint8_t *Sectorkey, uint8_t *serNum) { uint8_t status; uint32_t recvBits; uint8_t i; uint8_t buff[12]; // Validate instruction block address + sector + password + card serial number buff[0] = authMode; buff[1] = BlockAddr; for (i = 0; i<6; i++) { buff[i + 2] = *(Sectorkey + i); } for (i = 0; i<4; i++) { buff[i + 8] = *(serNum + i); } status = mfrc522_to_card(PCD_AUTHENT, buff, 12, buff, &recvBits); i = mfrc522_read(Status2Reg); if ((status != CARD_FOUND) || (!(i & 0x08))) { status = ERROR; } return status; }
The only things I see there that must be provided is the block address, the serial number and the sector key. How should I:
1) Set a password to the NFC tag
2) Once set, use that password (provide it in the mfrc522_auth function.
Have anyone used Mifare classic before? Any ideas?