/[openpgpmdrv]/trunk/OpenPGPminidriver/ContextManagement.c
ViewVC logotype

Diff of /trunk/OpenPGPminidriver/ContextManagement.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 11 by vletoux, Thu Mar 18 16:03:39 2010 UTC revision 12 by vletoux, Wed Mar 31 08:58:46 2010 UTC
# Line 81  DWORD CheckContextEx(__in PCARD_DATA pCa Line 81  DWORD CheckContextEx(__in PCARD_DATA pCa
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 )
# Line 95  DWORD CheckContextEx(__in PCARD_DATA pCa Line 96  DWORD CheckContextEx(__in PCARD_DATA pCa
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)
# Line 160  DWORD CheckContextEx(__in PCARD_DATA pCa Line 171  DWORD CheckContextEx(__in PCARD_DATA pCa
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;
# Line 342  DWORD CreateContext(__in PCARD_DATA pCar Line 335  DWORD CreateContext(__in PCARD_DATA pCar
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];

Legend:
Removed from v.11  
changed lines
  Added in v.12

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26