I am using an ACR122U NFC reader to password protect an NTAG216 NFC block. I think I have managed to set the password correctly, but I cannot authenticate and change the block afterward. My code for authenticating looks like this:
I set password "1234" and Pack "OK".
This should send the PWD_AUTH command to the NTAG216 with the Pwd. I expected to receive an error if the password is wrong or two bytes with the PACK if the password is correct. But SCard_Status is SCARD_S_SUCCESS and outBytes is 0 afterwards. And if I try to write to the block I get an error.
I am having trouble finding any examples showing how to do this. Can anyone see what I am doing wrong?
I set password "1234" and Pack "OK".
Code:
public int Authentication(string Password){ if(connectCard()){ ModWinsCard.SCARD_IO_REQUEST Request; Request.dwProtocol = Protocol; Request.cbPciLength = System.Runtime.InteropServices.Marshal.SizeOf(typeof(ModWinsCard.SCARD_IO_REQUEST)); ClearBuffers(); SendBuff[0] = 0x1B; //PWD_AUTH (See data sheet) SendBuff[1] = (byte)Password[0]; SendBuff[2] = (byte)Password[1]; SendBuff[3] = (byte)Password[2]; SendBuff[4] = (byte)Password[3]; byte[] receivedUID = new byte[256]; int outBytes = receivedUID.Length; int status = ModWinsCard.SCardTransmit(hCard, ref Request, ref SendBuff[0], SendBuff.Length, ref Request, ref receivedUID[0], ref outBytes); } return status; }
I am having trouble finding any examples showing how to do this. Can anyone see what I am doing wrong?
Comment