Search code examples
c#smartcardsmartcard-reader

APDU Command Read Binary command incompatible with file structure


I am trying to read from a smart card the binary with the read binary apdu command. I am doing this in a c# program I've written. First I send the loadKey- and the authenticate-command. Booth return 90-00, so they should be working fine. But when I try to send the read binary command it returns 69-81, which stands for "command incopmatible with file structure". The strange thing is if I use the same command with the Omnikey 6321 USB Reader everything works perfectly, but with the TWN4 Legic USB Reader the problem above appears.

Can someone please help me to get this working? :)

Here is the code of the APDU commands I am sending to the smart card:

cmdReadBinary = new CmdApdu();
        cmdReadBinary.CLA = 0xFF;
        cmdReadBinary.INS = 0xB0;
        cmdReadBinary.P1 = 0x00;
        cmdReadBinary.P2 = 0x00;
        cmdReadBinary.Le = 0x10;

scard.Transmit(commands.CmdReadBinary.GetBytes(), commands.CmdReadBinary.GetBytes().Length, respApdu, ref respLength);

Solution

  • I solved the problem. I was using the wrong authentication command. After changing the INS of authentication to 0x86 everything works fine now