Question

I am trying to sign a document via CryptoTech SCR3310 using A Smart Card Framework for .NET. I use demo from second article (SmartcardFmwk). While sending APDUCommand I will get errors like:

  • for verifing (new APDUCommand(0x00, 0x20, 0, 1, null, 0)) SW1= 69 SW2=83 (Authentication method blocked) ErrorNr1
  • for selecting file (new APDUCommand(0x00, 0xA4, 0, 0, null, 0)) [SW=61 SW2=2E][4] ErrorNr2
  • for getting response (new APDUCommand(0x00, 0xC0, 0, 0, null, 0)) SW=68 00 ErrorNr3

CODE:

APDUCommand apduVerifyCHV = new APDUCommand(0x00, 0x20, 0, 1, null, 0)
APDUCommand apduSelectFile = new APDUCommand(0x00, 0xA4, 0, 0, null, 0)
APDUResponse apduResp;

CardNative iCard = new CardNative();
iCard.Connect(readers[0], SHARE.Shared, PROTOCOL.T0orT1); //connected
Console.WriteLine("Connects card on reader: " + readers[0]);

// Verify the PIN  (PIN = 12341234)
byte[] pin = new byte[] { 0x31, 0x32, 0x33, 0x34, 0x31, 0x32, 0x33, 0x34 }; 

APDUParam apduParam = new APDUParam();
apduParam.Data = pin;
apduVerifyCHV.Update(apduParam);
apduResp = iCard.Transmit(apduVerifyCHV); //ErrorNr1

// Select the MF (3F00)
apduParam.Data = new byte[] { 0x3F, 0x00 };
apduSelectFile = new APDUCommand(0x00, 0xA4, 0, 0, apduParam.Data, 0);

apduSelectFile.Update(apduParam);
apduResp = iCard.Transmit(apduSelectFile); //ErrorNr2
apduGetResponse.Update(apduParam);
apduResp = iCard.Transmit(apduGetResponse); //ErrorNr3

What shall I do to get rid of those errors?? I tested the card with another programs and there are no errors.

May be the APDUCommand parameters are wrong. How do you think?

Was it helpful?

Solution

If this card works correctly with other programs, than the key is to set the appropriate parameters for the APDU command. I've never done this, but my friend had some university project related to the student cards. He provided me with the following link with the list of known APDU commands. Don't know, maybe it will help You find the correct combination.

APDU table

OTHER TIPS

  • The smart card reader in questions is not relevant, it is jut a gateway device to card. Your errors are not from the reader but from the card
  • You really need to have a manual for your card or you could try commands from ISO 7816-4
  • Calling GET RESPONSE would usually mean using T=0 protocol, you connect with either T=0 or T=1 which defaults to T=1 for modern cards that support it.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top