First off, I'm still relatively new working with smart cards and I don't know exactly how is data stored and which data is protected on a smart card.
I'm trying to read my student identification smart card which is PIN protected. I've been programming in C++ with default windows smart card library (winscard.lib).
I've successfully read ATR header but as far as I know, ATR header contains information on how to communicate with reader, not user information.
I've tried reading binary from the card and but APDU always returns 6E 00 which indicates "Class not supported" or "Wrong instruction". Here is the code:
switch(dwProtocol)
{
case SCARD_PROTOCOL_T0:
{
pioSendPci = *SCARD_PCI_T0;
break;
}
case SCARD_PROTOCOL_T1:
{
pioSendPci = *SCARD_PCI_T1;
break;
}
default:
{
printf("Detecting protocol failed!");
printf("Press <ENTER> key to terminate!\n");
nResponse = getchar();
lRet = SCardReleaseContext(hContext);
return -1;
}
}
lRet = SCardTransmit(hCard,
&pioSendPci,
(LPCBYTE)&cmdRead,
sizeof(cmdRead),
NULL,
(LPBYTE)&recvbuffer,
&atrLen);
printf("APDU return code:\n");
printf("=================\n");
for(i=0; i<2; i++)
{
printf("%02X ", recvbuffer[i]);
}
printf("\n");
if(lRet!=SCARD_S_SUCCESS)
{
printf("Transmission failed! ErrorCode = 0x%08X\n",lRet);
printf("Press <ENTER> key to terminate!\n");
nResponse = getchar();
lRet = SCardReleaseContext(hContext);
return -1;
}
Where cmdRead is as following:
BYTE cmdRead[] = { 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0xFF };
What could be wrong? Do I need to verify the card first in order to read binary? Is read binary right function to read basic data like student id?