Cannot authenticate NTAG216 password protected block using winscard libarary

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nomibashir015
    New Member
    • May 2016
    • 1

    Cannot authenticate NTAG216 password protected block using winscard libarary

    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".

    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;
    }
    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?
    Last edited by Rabbit; May 10 '16, 05:08 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Please use code tags when posting code or formatted data.

    It would help if you told us what language this is so we can move it to the correct forum.

    Comment

    Working...