81 |
DWORD dwI, dwJ; |
DWORD dwI, dwJ; |
82 |
BOOL fFound = FALSE; |
BOOL fFound = FALSE; |
83 |
BOOL fRightATRLenFound = FALSE; |
BOOL fRightATRLenFound = FALSE; |
84 |
|
DWORD dwMinSupportedVersion; |
85 |
__try |
__try |
86 |
{ |
{ |
87 |
if ( pCardData == NULL ) |
if ( pCardData == NULL ) |
96 |
dwReturn = SCARD_E_INVALID_PARAMETER; |
dwReturn = SCARD_E_INVALID_PARAMETER; |
97 |
__leave; |
__leave; |
98 |
} |
} |
99 |
|
if (fRunOnVistaAndLater) |
100 |
if (pCardData->dwVersion < CARD_DATA_VERSION_SIX) |
{ |
101 |
|
dwMinSupportedVersion = CARD_DATA_VERSION_SIX; |
102 |
|
} |
103 |
|
else |
104 |
|
{ |
105 |
|
// only a subset of functions is supported |
106 |
|
// so the project don't pass the ms test |
107 |
|
// we do this so the driver can operate under XP |
108 |
|
dwMinSupportedVersion = CARD_DATA_VERSION_FIVE; |
109 |
|
} |
110 |
|
if (pCardData->dwVersion < dwMinSupportedVersion) |
111 |
{ |
{ |
112 |
Trace(WINEVENT_LEVEL_ERROR, L"pCardData->dwVersion(%d) < CARD_DATA_VERSION_SIX", pCardData->dwVersion); |
Trace(WINEVENT_LEVEL_ERROR, L"pCardData->dwVersion(%d) < dwMinSupportedVersion(%d)", pCardData->dwVersion, dwMinSupportedVersion); |
113 |
dwReturn = ERROR_REVISION_MISMATCH; |
dwReturn = ERROR_REVISION_MISMATCH; |
114 |
__leave; |
__leave; |
115 |
} |
} |
116 |
pCardData->dwVersion = min(pCardData->dwVersion, CARD_DATA_VERSION_SIX); |
pCardData->dwVersion = min(pCardData->dwVersion, CARD_DATA_VERSION_SEVEN); |
117 |
for (dwI = 0; dwI < dwSupportedATRCount; dwI++) |
for (dwI = 0; dwI < dwSupportedATRCount; dwI++) |
118 |
{ |
{ |
119 |
if (SupportedATR[dwI].cbAtr == pCardData->cbAtr) |
if (SupportedATR[dwI].cbAtr == pCardData->cbAtr) |
171 |
dwReturn = SCARD_E_UNEXPECTED; |
dwReturn = SCARD_E_UNEXPECTED; |
172 |
__leave; |
__leave; |
173 |
} |
} |
|
if (pCardData->hSCardCtx == 0) |
|
|
{ |
|
|
Trace(WINEVENT_LEVEL_ERROR, L"pCardData->hSCardCtx == NULL"); |
|
|
dwReturn = SCARD_E_INVALID_PARAMETER; |
|
|
__leave; |
|
|
} |
|
|
if (pCardData->hScard == 0) |
|
|
{ |
|
|
Trace(WINEVENT_LEVEL_ERROR, L"pCardData->hScard == NULL"); |
|
|
dwReturn = SCARD_E_INVALID_PARAMETER; |
|
|
__leave; |
|
|
} |
|
174 |
} |
} |
175 |
else |
else |
176 |
{ |
{ |
|
/*if (pCardData->pvVendorSpecific) |
|
|
{ |
|
|
Trace(WINEVENT_LEVEL_ERROR, L"pContext != NULL"); |
|
|
dwReturn = SCARD_E_UNEXPECTED; |
|
|
__leave; |
|
|
}*/ |
|
177 |
pCardData->pvVendorSpecific = NULL; |
pCardData->pvVendorSpecific = NULL; |
178 |
} |
} |
179 |
dwReturn = 0; |
dwReturn = 0; |
335 |
} |
} |
336 |
pContext->fExtentedLeLcFields = ((pbCardCapabilities[2] & 0x40)?TRUE:FALSE); |
pContext->fExtentedLeLcFields = ((pbCardCapabilities[2] & 0x40)?TRUE:FALSE); |
337 |
pContext->fSupportCommandChaining = ((pbCardCapabilities[2] & 0x80)?TRUE:FALSE); |
pContext->fSupportCommandChaining = ((pbCardCapabilities[2] & 0x80)?TRUE:FALSE); |
338 |
pContext->bSecureMessagingAlgorithm = pbExtendedCapabilities[1]; |
if (pbExtendedCapabilities[0] & 0x80) |
339 |
|
{ |
340 |
|
switch(pbExtendedCapabilities[1]) |
341 |
|
{ |
342 |
|
case 0: |
343 |
|
pContext->aiSecureMessagingAlg = CALG_3DES; |
344 |
|
break; |
345 |
|
case 1: |
346 |
|
pContext->aiSecureMessagingAlg = CALG_AES_128; |
347 |
|
break; |
348 |
|
} |
349 |
|
Trace(WINEVENT_LEVEL_VERBOSE, L"secure messaging supported with aiAlg = %d", pContext->aiSecureMessagingAlg); |
350 |
|
} |
351 |
pContext->dwMaxChallengeLength = pbExtendedCapabilities[2] * 0x100 + pbExtendedCapabilities[3]; |
pContext->dwMaxChallengeLength = pbExtendedCapabilities[2] * 0x100 + pbExtendedCapabilities[3]; |
352 |
pContext->dwMaxCertificateLength = pbExtendedCapabilities[4] * 0x100 + pbExtendedCapabilities[5]; |
pContext->dwMaxCertificateLength = pbExtendedCapabilities[4] * 0x100 + pbExtendedCapabilities[5]; |
353 |
pContext->dwMaxCommandDataLength = pbExtendedCapabilities[6] * 0x100 + pbExtendedCapabilities[7]; |
pContext->dwMaxCommandDataLength = pbExtendedCapabilities[6] * 0x100 + pbExtendedCapabilities[7]; |