static UINT32 smartcard_State_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPERATION* operation, State_Call* call)
{
	LONG status;
	State_Return ret;
	IRP* irp = operation->irp;

	ret.cbAtrLen = SCARD_ATR_LENGTH;

	status = ret.ReturnCode = SCardState(operation->hCard, &ret.dwState, &ret.dwProtocol, (BYTE*) &ret.rgAtr, &ret.cbAtrLen);

	status = smartcard_pack_state_return(smartcard, irp->output, &ret);

	if (status != SCARD_S_SUCCESS)
		return status;

	return ret.ReturnCode;
}
Beispiel #2
0
static int testSCardState(SCARDCONTEXT hCard)
{
	int           errCount = 0;
    DWORD         dwState = 0;
    DWORD         dwProt = 0;
    BYTE          tucAtr[32];
    DWORD         dwAtrLen = (DWORD) sizeof(tucAtr);

    int ret = SCardState(hCard, &dwState, &dwProt, tucAtr, &dwAtrLen);
	CHECK_PCSC_RET("SCardState()", ret);

    if (dwState == 0)
	{
        printf("ERR: SCardState(): dwState not filled in\n");
		errCount++;
	}

    if (dwProt != SCARD_PROTOCOL_T0)
	{
        printf("ERR: SCardState(): dwProtocol should be SCARD_PROTOCOL_T0 (as least for a BE eID test)\n");
		errCount++;
	}

    if (dwAtrLen < 8)
	{
        printf("ERR: SCardState(): ATR length looks too small (%d) for a BE eID card\n", dwAtrLen);
		errCount++;
	}
    else if (tucAtr[0] != 0x3B)
	{
        printf("ERR: SCardState(): ATR should start with 0x3B (instead of 0x%0x) for a BE eID card\n", tucAtr[0]);
		errCount++;
	}

    return errCount;
}