T=0 and case 3 Command (Incoming Data Only)

[ Follow Ups ] [ BasicCard User Forum ]

Posted by xavier ( on July 01, 2003 at 05:43:45:

We want to use the T=0 protocol and we want the following command to be of type "Incoming Data Only", which is considered as a Case 3.
The aim of this command is to show that the Terminal Program and the Card have the same key. The Terminal Program sends the 8 bytes string CHV$, which is compared to the key that the card holds in his file. If the comparison succeed, the two status bytes SW1SW2 are set to &H9000.

Thanks to a step to step execution, we can see that SW1SW2 is indeed set to &H9000. But when the command is finished, just after the "End Command" statement, SW1SW2 is set to &H6108. I guess it means that the card accepts the command and indicates that 8 bytes of outgoing data are available.
So the card considers this command as a case 4, ie Incoming and Outgoing Data.

If a "Disable Le" statement is added to the Command Definition and Declaration, then the card answers with a SW1SW2 set to &H6C08. The card seems to understand the APDU as one of a case 2 (Outgoing Data Only) with Le not accepted and La=8 indicated.

If "Le=0" is added to the APDU then the card answers with &H6108.

In the value &H9000 is changed with &H6900, for example, the card answers with &H6900.
Is it impossible to set SW1SW2 to &H9000?

Please, can you tell me where is my mistake?

Thanks for your attention.

Command Declaration:
Declare Command &HC0 &H20 VerifyCHV(P1=&H00, P2=&H01, Lc=&H08, CHV$ as string*8)

Command Definition:
Command &HC0 &H20 VerifyCHV(Lc=&H08, CHVa$ as string*8)

Dim CHVc$ as string*8
Dim chemin$ as string

'Get the Key in the file
FileNumber = FreeFile
Open chemin$ for Binary Access Read As #FileNumber
Get #filenumber,1,CHVc$,8
Close #FileNumber

'comparison of the 2 keys
If CHVc$ = CHVa$ then
End if

End Command

Follow Ups:

[ Follow Ups ] [ BasicCard User Forum ]