[EMAIL PROTECTED] wrote:

> Hi,
> I'm trying to write to a Siemens SLE4442 card, using the CT-API in Linux and a 
>Towitoko reader, but I can't find out how to verify the PIN.
>
>

I'm using to, and may be able to help you.
The default PIN is 0xFFFF, it is only two bytes long.

You have to send the verify command, i did it by using pcsc-lite :

This is my function which i call to write the code :
DEFAULT_PROTO = 0 in our case.
kPart1 = 0xFF
kPart2 = 0xFF
kPart3 = 0x00.

LONG SCVerifyPin(SCARDHANDLE hCard, BYTE kPart1, BYTE kPart2, BYTE kPart3)
{
  LONG rv; //The response status
  DWORD dwLength = 2;

  BYTE bufToRecv[2] = {0}; //unsigned char * bufToRecv
  BYTE verifyPin[8] = { 0x00, 0x20, 0x00, 0x00, 0x03, kPart1, kPart2, kPart3 };
  SCARD_IO_REQUEST sRecvPci;
  SCARD_IO_REQUEST sSendPci;
  sRecvPci.dwProtocol = DEFAULT_PROTO;
  sSendPci.dwProtocol = DEFAULT_PROTO;

  rv = SCardTransmit(hCard, &sSendPci, verifyPin, 8, &sRecvPci,
       bufToRecv, &dwLength);

  if (rv == SCARD_S_SUCCESS)
    {
      int i;
      printf("PCSC OK: %s\n", pcsc_stringify_error(rv));
      for(i = 0; i < dwLength; i++)
      {
          printf("Result APDU : %x\n", bufToRecv[i]);
      }
       return rv;
    }else
      {
 printf("PCSC ERROR: %s\n", pcsc_stringify_error(rv));
 return rv;
      }
}




> I succesfully managed to write to the other cards I have, all I had to do was to 
>verify the pin as discussed in a previous discussion.
>
> So, what APDU command shall I send before trying to write to the card? Sending the 
>same command as I did to the other cards results in an verification error end my 
>tries are decreased by one.
> I read something about the PIN being BCD-encoded, how should the PIN-data that I 
>send look like?
>

Maybe somebody use your card and set the writable bit in order to disable further 
write or the PIN has been changed.

In my case i only use 0xFF 0xFF, but it does not help to get the right order. ;-)


>
> I'm using a program that came with the Towitoko reader, SmartCard Explorer. It says 
>that my PIN is 000000.
> How can I read the PIN from the card, is that even possible? And how do I get the 
>number of tries that are left?
>

As far as i know it is not possible to read the PIN from the card.
The number left is given by the Verify command 0x63 0xXX with XX = the number of try 
left.
If you get 0x69 0x83 that 's mean you cannot verify PIN anymore and the write is 
definitely blocked.

Once you manage to input the correct PIN, the count number is reseted to 8.

>
> Is it possible to unblock a card when I run out of tries, does that require some 
>kind of "super user PIN"?
>
> In the SC Explorer app, write protected bytes are in blue color, how do I find out 
>which that are write protected?

take a look at infineon for datasheets.

here you will find general info
http://www.infineon.com/cmc_upload/0/000/013/103/DS_sle4418_0494.pdf

additional infos about extended coding scheme
http://www.infineon.com/cmc_upload/0/000/013/105/Add_SLE4418_0299.pdf

Here you will find which byte are write protected.

>
>
> Thanks, Henrik Sandberg
>
> ***************************************************************
> Linux Smart Card Developers - M.U.S.C.L.E.
> (Movement for the Use of Smart Cards in a Linux Environment)
> http://www.linuxnet.com/smartcard/index.html
> ***************************************************************

If you cannot make your card work, throw it away and buy a new one.
I did it and it works pretty well know ;-)


--
Christian Jean
+-------------------------------+-----------------------------+
|R&D Engineer                   |Tel : (65) 844 1301          |
|celestix Networks Pte Ltd      |Fax : (65) 844 1125          |
|18 Tannery Lane #05-03         |mail: [EMAIL PROTECTED] |
|Lian Tong Building             |web : http://www.celestix.com|
|Singapore 347780               |                             |
+-------------------------------+-----------------------------+



***************************************************************
Linux Smart Card Developers - M.U.S.C.L.E.
(Movement for the Use of Smart Cards in a Linux Environment)
http://www.linuxnet.com/smartcard/index.html
***************************************************************

Reply via email to