Changeset 44cf3d0 in OpenSC


Ignore:
Timestamp:
04/12/11 07:40:12 (14 months ago)
Author:
martin <martin@…>
Branches:
master, staging
Children:
7c17247
Parents:
577ccdbf
git-author:
martin <martin@…> (04/12/11 07:40:12)
git-committer:
martin <martin@…> (04/12/11 07:40:12)
Message:

MiniDriver: rename cardmod to minidriver in source.
Also change some grammar, whitespace (reported by git) and wording (Opensc->OpenSC) issues.
Add some comments here and there.

See  http://www.opensc-project.org/pipermail/opensc-devel/2011-April/016261.html

git-svn-id:  https://www.opensc-project.org/svnp/opensc/trunk@5329 c6295689-39f2-0310-b995-f0e70906c6a9

Files:
1 added
1 deleted
9 edited
5 moved

Legend:

Unmodified
Added
Removed
  • configure.ac

    rdb3ebb1 r44cf3d0  
    129129 
    130130AC_ARG_ENABLE( 
    131         [cardmod], 
    132         [AS_HELP_STRING([--enable-cardmod],[enable cardmod module on Windows @<:@disabled@:>@])], 
    133         , 
    134         [enable_cardmod="no"] 
     131        [minidriver], 
     132        [AS_HELP_STRING([--enable-minidriver],[enable minidriver on Windows @<:@disabled@:>@])], 
     133        , 
     134        [enable_minidriver="no"] 
    135135) 
    136136 
     
    294294fi 
    295295 
    296 if test "${enable_cardmod}" = "yes"; then 
     296if test "${enable_minidriver}" = "yes"; then 
    297297        dnl win32 special test for minidriver 
    298298        AC_CHECK_HEADER( 
    299299                [cardmod.h], 
    300300                , 
    301                 [AC_MSG_ERROR([cardmod.h is not found and required for cardmod])] 
     301                [AC_MSG_ERROR([cardmod.h is not found and required for minidriver])] 
    302302        ) 
    303         AC_DEFINE([ENABLE_CARDMOD], [1], [Enable cardmod support]) 
     303        AC_DEFINE([ENABLE_MINIDRIVER], [1], [Enable minidriver support]) 
    304304fi 
    305305 
     
    523523if test "${enable_ctapi}" = "yes"; then 
    524524        OPENSC_FEATURES="${OPENSC_FEATURES} ctapi" 
    525 fi 
    526 if test "${enable_cardmod}" = "yes"; then 
    527         OPENSC_FEATURES="${OPENSC_FEATURES} cardmod" 
    528525fi 
    529526 
     
    565562AM_CONDITIONAL([WIN32], [test "${WIN32}" = "yes"]) 
    566563AM_CONDITIONAL([CYGWIN], [test "${CYGWIN}" = "yes"]) 
    567 AM_CONDITIONAL([ENABLE_CARDMOD], [test "${enable_cardmod}" = "yes"]) 
     564AM_CONDITIONAL([ENABLE_MINIDRIVER], [test "${enable_minidriver}" = "yes"]) 
    568565 
    569566if test "${enable_pedantic}" = "yes"; then 
     
    593590        src/tests/regression/Makefile 
    594591        src/tools/Makefile 
    595         src/cardmod/Makefile 
    596         src/cardmod/cardmod.inf 
     592        src/minidriver/Makefile 
     593        src/minidriver/opensc-minidriver.inf 
    597594        win32/Makefile 
    598595        win32/versioninfo.rc 
     
    621618OpenCT support:          ${enable_openct} 
    622619CT-API support:          ${enable_ctapi} 
    623 cardmod support:         ${enable_cardmod} 
     620minidriver support:      ${enable_minidriver} 
    624621 
    625622PC/SC default provider:  ${DEFAULT_PCSC_PROVIDER} 
  • etc/opensc.conf.in

    r69c846f r44cf3d0  
    448448} 
    449449 
     450# XXX: remove cardmod pseudodriver 
    450451app cardmod { 
    451452        # cardmod app name use special pcsc reader subset  
     
    458459        } 
    459460} 
    460  
  • src/Makefile.am

    rd22a248 r44cf3d0  
    44# Order IS important 
    55SUBDIRS = common scconf pkcs15init libopensc pkcs11 \ 
    6         tools tests cardmod 
     6        tools tests minidriver 
  • src/Makefile.mak

    rc5b2b02 r44cf3d0  
    55SUBDIRS = common scconf pkcs15init libopensc pkcs11 tools tests 
    66 
    7 !IF "$(MINIDRIVER_DEF)" == "/DENABLE_CARDMOD" 
    8 SUBDIRS = $(SUBDIRS) cardmod 
    9 !ENDIF 
    10  
    11 !IF "$(WIX_MSI_DEF)" == "/DBUILD_MSI" 
    12 SUBDIRS = $(SUBDIRS) "$(TOPDIR)\etc" 
    13 SUBDIRS = $(SUBDIRS) "$(TOPDIR)\win32\opensc-msi" 
     7!IF "$(MINIDRIVER_DEF)" == "/DENABLE_MINIDRIVER" 
     8SUBDIRS = $(SUBDIRS) minidriver 
    149!ENDIF 
    1510 
  • src/libopensc/ctx.c

    r383d6e8 r44cf3d0  
    655655#ifdef ENABLE_PCSC 
    656656        ctx->reader_driver = sc_get_pcsc_driver(); 
    657         #ifdef ENABLE_CARDMOD 
     657/* XXX: remove cardmod pseudoreader driver */ 
     658#ifdef ENABLE_MINIDRIVER 
    658659        if(strcmp(ctx->app_name, "cardmod") == 0) { 
    659660                ctx->reader_driver = sc_get_cardmod_driver(); 
    660661        } 
    661         #endif 
     662#endif 
    662663#elif ENABLE_CTAPI 
    663664        ctx->reader_driver = sc_get_ctapi_driver(); 
     
    682683} 
    683684 
    684 /* use by cardmod to pass in provided handles to reader-pcsc */ 
    685 int sc_ctx_use_reader(sc_context_t *ctx, void * pcsc_context_handle, void * pcsc_card_handle) 
     685/* Used by minidriver to pass in provided handles to reader-pcsc */ 
     686int sc_ctx_use_reader(sc_context_t *ctx, void *pcsc_context_handle, void *pcsc_card_handle) 
    686687{ 
    687688        SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL); 
  • src/libopensc/opensc.h

    r69c846f r44cf3d0  
    389389        /* Reset a reader */ 
    390390        int (*reset)(struct sc_reader *, int); 
    391         /* used to pass in reader handles in cardmod mode */ 
    392         int (*use_reader)(struct sc_context *ctx, void * pcsc_context_handle, void * pcsc_card_handle); 
     391        /* Used to pass in PC/SC handles to minidriver */ 
     392        int (*use_reader)(struct sc_context *ctx, void *pcsc_context_handle, void *pcsc_card_handle); 
    393393}; 
    394394 
  • src/libopensc/reader-pcsc.c

    rcd3012f r44cf3d0  
    15521552} 
    15531553 
    1554 #ifdef ENABLE_CARDMOD 
     1554#ifdef ENABLE_MINIDRIVER 
    15551555 
    15561556#define SCARD_CLASS_SYSTEM     0x7fff  
  • src/minidriver/Makefile.mak

    rc5b2b02 r44cf3d0  
    11TOPDIR = ..\.. 
    22 
    3 TARGET = opensc-cardmod.dll 
    4 OBJECTS = cardmod.obj  
     3TARGET = opensc-minidriver.dll 
     4OBJECTS = opensc-minidriver.obj 
    55 
    66!INCLUDE $(TOPDIR)\win32\Make.rules.mak 
     
    1111        echo LIBRARY $* > $*.def 
    1212        echo EXPORTS >> $*.def 
    13         type cardmod.exports >> $*.def 
     13        type minidriver.exports >> $*.def 
    1414        link /dll $(LINKFLAGS) /def:$*.def /out:$(TARGET) $(OBJECTS) ..\libopensc\opensc_a.lib $(ZLIB_LIB) $(OPENSSL_LIB) ..\common\libscdl.lib ws2_32.lib gdi32.lib advapi32.lib winscard.lib Crypt32.lib User32.lib 
    1515        if EXIST $(TARGET).manifest mt -manifest $(TARGET).manifest -outputresource:$(TARGET);2 
  • src/minidriver/minidriver-westcos.reg

    r0e03c6d r44cf3d0  
    1 Windows Registry Editor Version 5.00 
     1Windows Registry Editor Version 5.00 
    22 
    33[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography\Calais\SmartCards\CEV WESTCOS] 
    4 "80000001"="opensc-cardmod.dll" 
     4"80000001"="opensc-minidriver.dll" 
    55"ATR"=hex:3f,69,00,00,00,64,01,00,00,00,80,90,00 
    66"ATRMask"=hex:ff,ff,ff,ff,ff,ff,ff,00,00,00,f0,ff,ff 
    77"Crypto Provider"="Microsoft Base Smart Card Crypto Provider" 
    8  
  • src/minidriver/minidriver.c

    r6c1862e r44cf3d0  
    11/* 
    2  * cardmod.c: card module support for opensc 
     2 * minidriver.c: OpenSC minidriver 
    33 * 
    4  * Copyright (C) 2009,2010 francois.leblanc@cev-sa.com  
     4 * Copyright (C) 2009,2010 francois.leblanc@cev-sa.com 
    55 * 
    66 * This library is free software; you can redistribute it and/or 
     
    2020 
    2121/* 
    22  * This module require "cardmod.h" from CNG SDK or plattform SDK to 
    23  * be build.  
     22 * This module requires "cardmod.h" from CNG SDK or platform SDK to build. 
    2423 */ 
     24 
     25#include "config.h" 
     26#ifdef ENABLE_MINIDRIVER 
    2527 
    2628#ifdef _MANAGED 
    2729#pragma managed(push, off) 
    2830#endif 
    29  
    30 #include "config.h" 
    3131 
    3232#include <stdio.h> 
     
    6464{ 
    6565        char *pin; 
    66          
     66 
    6767        sc_pkcs15_object_t *cert_objs[32]; 
    6868        int cert_count; 
     
    7171        sc_pkcs15_object_t *pin_objs[8]; 
    7272        int pin_count; 
    73          
     73 
    7474        sc_context_t *ctx; 
    7575        sc_reader_t *reader; 
     
    8686        SCARDCONTEXT hSCardCtx; 
    8787        SCARDHANDLE hScard; 
    88          
     88 
    8989}VENDOR_SPECIFIC; 
    9090 
     
    9898/* #define CARDMOD_LOW_LEVEL_DEBUG 1 */ 
    9999#ifdef CARDMOD_LOW_LEVEL_DEBUG 
    100 /* Use a simplied log to get all messages including messages  
     100/* Use a simplied log to get all messages including messages 
    101101 * before opensc is loaded. The file must be modifiable by all 
    102  * users as we maybe called under lsa or user. Note data from  
     102 * users as we maybe called under lsa or user. Note data from 
    103103 * multiple process and threads may get intermingled. 
    104104 * flush to get last message before ann crash 
     
    119119        return; 
    120120        } 
    121 #endif    
     121#endif 
    122122 
    123123        va_start(arg, format); 
     
    140140        } 
    141141        va_end(arg); 
    142 }  
     142} 
    143143 
    144144static void loghex(PCARD_DATA pCardData, int level, PBYTE data, int len) 
     
    148148        int i, a; 
    149149        unsigned char * p; 
    150          
     150 
    151151        logprintf(pCardData, level, "--- %p:%d\n", data, len); 
    152152 
     
    176176        if (i%32 != 0) 
    177177                logprintf(pCardData, level, " %04X  %s\n", a, line); 
    178  
     178} 
     179 
    179180static void print_werror(PCARD_DATA pCardData, char *str) 
    180181{ 
     
    191192 
    192193/* 
    193  * check if the card has been removed, or the  
     194 * check if the card has been removed, or the 
    194195 * caller has changed the handles. 
    195196 * if so, then free up all previous card info 
     
    205206        if(!pCardData) 
    206207                return SCARD_E_INVALID_PARAMETER; 
    207          
     208 
    208209        vs = (VENDOR_SPECIFIC*)(pCardData->pvVendorSpecific); 
    209210        if(!vs) 
     
    212213        logprintf(pCardData, 7, "pCardData->hSCardCtx:0x%08X hScard:0x%08X\n", 
    213214                        pCardData->hSCardCtx, pCardData->hScard); 
    214                          
    215          
    216         if (pCardData->hSCardCtx != vs->hSCardCtx  
     215 
     216        if (pCardData->hSCardCtx != vs->hSCardCtx 
    217217                                || pCardData->hScard != vs->hScard) { 
    218                         logprintf (pCardData, 1, "HANDLES CHANGED from 0x%08X 0x%08X\n", vs->hSCardCtx, vs->hScard);   
     218                        logprintf (pCardData, 1, "HANDLES CHANGED from 0x%08X 0x%08X\n", vs->hSCardCtx, vs->hScard); 
    219219 
    220220                         r = disassociate_card(pCardData); 
     
    222222                         r = associate_card(pCardData); /* need to check return codes */ 
    223223                         logprintf(pCardData, 1, "associate_card r = 0x%08X\n"); 
    224                  
    225224        } else 
    226225 
     
    229228                r = sc_detect_card_presence(vs->reader); 
    230229                logprintf(pCardData, 2, "check_reader_status r=%d flags 0x%08X\n", 
    231                         r, vs->reader->flags);  
     230                        r, vs->reader->flags); 
    232231        } 
    233232        return SCARD_S_SUCCESS; 
     
    256255        int i; 
    257256 
    258         if (!pCardData)  
     257        if (!pCardData) 
    259258                return SCARD_E_INVALID_PARAMETER; 
    260259 
     
    328327                loghex(pCardData, 5, prkey_info->subject.value, prkey_info->subject.len); 
    329328        } 
    330                  
     329 
    331330        for(i = 0; i < vs->cert_count; i++) 
    332331        { 
     
    337336                sc_pkcs15_free_certificate(cert); 
    338337        } 
    339                  
     338 
    340339        for(i = 0; i < vs->pin_count; i++) 
    341340        { 
    342                 const char *pin_flags[] =  
     341                const char *pin_flags[] = 
    343342                { 
    344343                        "case-sensitive", "local", "change-disabled", 
     
    349348                }; 
    350349                const char *pin_types[] = {"bcd", "ascii-numeric", "UTF-8", 
    351                         "halfnibble bcd", "iso 9664-1"};  
     350                        "halfnibble bcd", "iso 9664-1"}; 
    352351                const struct sc_pkcs15_object *obj = vs->pin_objs[i]; 
    353352                const struct sc_pkcs15_pin_info *pin = (const struct sc_pkcs15_pin_info *) (obj->data); 
     
    391390 
    392391        vs = (VENDOR_SPECIFIC*)(pCardData->pvVendorSpecific); 
    393          
     392 
    394393        if(!vs) 
    395394                return SCARD_E_INVALID_PARAMETER; 
    396395 
    397396        disassociate_card(pCardData); 
    398          
     397 
    399398        if(vs->ctx) 
    400399        { 
     
    413412} 
    414413 
    415 DWORD WINAPI CardQueryCapabilities(__in PCARD_DATA pCardData,  
     414DWORD WINAPI CardQueryCapabilities(__in PCARD_DATA pCardData, 
    416415        __in PCARD_CAPABILITIES  pCardCapabilities) 
    417416{ 
     
    426425                && pCardCapabilities->dwVersion != 0) 
    427426                        return ERROR_REVISION_MISMATCH; 
    428          
     427 
    429428        pCardCapabilities->dwVersion = CARD_CAPABILITIES_CURRENT_VERSION; 
    430429        pCardCapabilities->fCertificateCompression = TRUE; 
     
    470469        sc_pkcs15_cert_t *cert = NULL; 
    471470        VENDOR_SPECIFIC *vs = NULL; 
    472          
     471 
    473472        PUBKEYSTRUCT_BASE *oh = NULL; 
    474473        PUBKEYSTRUCT_BASE *oh2 = NULL; 
     
    479478        DWORD ret; 
    480479        sc_pkcs15_pubkey_t *pubkey = NULL; 
    481          
     480 
    482481        logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData); 
    483482        logprintf(pCardData, 1, "CardGetContainerInfo bContainerIndex=%u, dwFlags=0x%08X, " \ 
     
    489488        if (!pContainerInfo) SCARD_E_INVALID_PARAMETER; 
    490489        if (dwFlags) return SCARD_E_INVALID_PARAMETER; 
    491         if (pContainerInfo->dwVersion < 0  
    492                 || pContainerInfo->dwVersion >  CONTAINER_INFO_CURRENT_VERSION)  
     490        if (pContainerInfo->dwVersion < 0 
     491                || pContainerInfo->dwVersion >  CONTAINER_INFO_CURRENT_VERSION) 
    493492                        return ERROR_REVISION_MISMATCH; 
    494493 
    495494        vs = (VENDOR_SPECIFIC*)(pCardData->pvVendorSpecific); 
    496          
     495 
    497496        check_reader_status(pCardData); 
    498497 
    499498        if(bContainerIndex>=vs->cert_count) 
    500499                return SCARD_E_INVALID_PARAMETER; 
    501          
     500 
    502501        r = sc_pkcs15_read_certificate(vs->p15card, \ 
    503502                (struct sc_pkcs15_cert_info *)(vs->cert_objs[bContainerIndex]->data), \ 
     
    514513        { 
    515514                int modulus = compute_keybits(&(pubkey->u.rsa.modulus)); 
    516                  
     515 
    517516                PCCERT_CONTEXT cer = CertCreateCertificateContext(X509_ASN_ENCODING \ 
    518517                        | PKCS_7_ASN_ENCODING, cert->data, cert->data_len); 
     
    524523                RSA_CSP_PUBLICKEYBLOB, pinf->PublicKey.pbData, \ 
    525524                pinf->PublicKey.cbData , 0, oh, &sz); 
    526                 sz2 = sz;  
     525                sz2 = sz; 
    527526 
    528527                oh = (PUBKEYSTRUCT_BASE*)pCardData->pfnCspAlloc(sz); 
     
    533532                                RSA_CSP_PUBLICKEYBLOB, pinf->PublicKey.pbData, \ 
    534533                                pinf->PublicKey.cbData , 0, oh, &sz); 
    535                  
     534 
    536535                        oh->publickeystruc.aiKeyAlg = CALG_RSA_SIGN; 
    537536                        pContainerInfo->cbSigPublicKey = sz; 
     
    577576 
    578577        if(!pCardData) return SCARD_E_INVALID_PARAMETER; 
    579          
     578 
    580579        vs = (VENDOR_SPECIFIC*)(pCardData->pvVendorSpecific); 
    581580 
     
    594593        if (cbPin < 4 || cbPin > 12) return SCARD_W_WRONG_CHV; 
    595594 
    596         if (wcscmp(wszCARD_USER_ADMIN,pwszUserId) == 0)  
     595        if (wcscmp(wszCARD_USER_ADMIN,pwszUserId) == 0) 
    597596        { 
    598597                return SCARD_W_WRONG_CHV; 
    599598        } 
    600          
     599 
    601600        wcstombs(type, pwszUserId, 100); 
    602601        type[10] = 0; 
    603          
     602 
    604603        logprintf(pCardData, 1, "CardAuthenticatePin %.20s, %d, %d\n", NULLSTR(type), \ 
    605604                cbPin, (pcAttemptsRemaining==NULL?-2:*pcAttemptsRemaining)); 
    606          
     605 
    607606        pin_obj = vs->pin_objs[0]; 
    608607        r = sc_pkcs15_verify_pin(vs->p15card, pin_obj, (const u8 *) pbPin, cbPin); 
    609         if (r)  
     608        if (r) 
    610609        { 
    611610                logprintf(pCardData, 1, "PIN code verification failed: %s\n", sc_strerror(r)); 
    612                  
    613                 if(pcAttemptsRemaining)  
     611 
     612                if(pcAttemptsRemaining) 
    614613                { 
    615614                        (*pcAttemptsRemaining) = -1; 
     
    617616                return SCARD_W_WRONG_CHV; 
    618617        } 
    619          
     618 
    620619        logprintf(pCardData, 3, "Pin code correct.\n"); 
    621          
     620 
    622621        SET_PIN(vs->cardFiles.file_cardcf.bPinsFreshness, ROLE_USER); 
    623622        logprintf(pCardData, 3, "PinsFreshness = %d\n", 
    624623                vs->cardFiles.file_cardcf.bPinsFreshness); 
    625          
    626         return SCARD_S_SUCCESS;  
     624 
     625        return SCARD_S_SUCCESS; 
    627626} 
    628627 
     
    684683        logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData); 
    685684        logprintf(pCardData, 1, "CardDeauthenticate%S %d\n", NULLWSTR(pwszUserId), 
    686                         dwFlags);  
     685                        dwFlags); 
    687686 
    688687        if(!pCardData) return SCARD_E_INVALID_PARAMETER; 
     
    763762        if(pszDirectoryName == NULL) 
    764763        { 
    765                 if(strcmp(pszFileName, "cardid") == 0)  
     764                if(strcmp(pszFileName, "cardid") == 0) 
    766765                { 
    767766                        *pcbData = strlen(vs->p15card->tokeninfo->serial_number) + 10; 
     
    771770                                return SCARD_E_NO_MEMORY; 
    772771                        } 
    773                          
     772 
    774773                        strcpy(*ppbData, vs->p15card->tokeninfo->serial_number); 
    775                          
     774 
    776775                        logprintf(pCardData, 7, "return cardid "); 
    777776                        loghex(pCardData, 7, *ppbData, *pcbData); 
     
    780779                } 
    781780 
    782                 if(strcmp(pszFileName, "cardcf") == 0)  
     781                if(strcmp(pszFileName, "cardcf") == 0) 
    783782                { 
    784783                        *pcbData = sizeof(vs->cardFiles.file_cardcf); 
     
    788787                                return SCARD_E_NO_MEMORY; 
    789788                        } 
    790                          
     789 
    791790                        memcpy(*ppbData, &(vs->cardFiles.file_cardcf), *pcbData); 
    792791 
     
    798797 
    799798        } 
    800          
     799 
    801800        if(pszDirectoryName != NULL && strcmp(pszDirectoryName, "mscp") == 0) 
    802801        { 
     
    804803                sc_pkcs15_cert_t *cert = NULL; 
    805804 
    806                 if(strcmp(pszFileName, "cmapfile") == 0)  
     805                if(strcmp(pszFileName, "cmapfile") == 0) 
    807806                { 
    808807                        PCONTAINER_MAP_RECORD p; 
    809808                        sc_pkcs15_pubkey_t *pubkey = NULL; 
    810                          
     809 
    811810                        *pcbData = 32*sizeof(CONTAINER_MAP_RECORD); 
    812811                        *ppbData = pCardData->pfnCspAlloc(*pcbData); 
     
    815814                                return SCARD_E_NO_MEMORY; 
    816815                        } 
    817                          
     816 
    818817                        memset(*ppbData, 0, *pcbData); 
    819                          
     818 
    820819                        for(i = 0, p = (PCONTAINER_MAP_RECORD)*ppbData; \ 
    821820                                i < vs->cert_count; i++,p++) 
     
    823822                                struct sc_pkcs15_cert_info *cert_info = (sc_pkcs15_cert_info_t *)vs->cert_objs[i]->data; 
    824823                                sc_pkcs15_cert_t *cert = NULL; 
    825                                  
     824 
    826825                                r = sc_pkcs15_read_certificate(vs->p15card, cert_info, &cert); 
    827826                                logprintf(pCardData, 2, "sc_pkcs15_read_certificate return %d\n", r); 
     
    835834                                        struct sc_card *card = vs->p15card->card; 
    836835                                        char guid[MAX_CONTAINER_NAME_LEN + 1]; 
    837          
     836 
    838837                                        r = sc_pkcs15_get_guid(vs->p15card, vs->cert_objs[i], guid, sizeof(guid)); 
    839838                                        if (r) 
     
    841840 
    842841                                        logprintf(pCardData, 7, "Guid=%s\n", guid); 
    843                                          
     842 
    844843                                        mbstowcs(p->wszGuid, guid, MAX_CONTAINER_NAME_LEN + 1); 
    845                                          
     844 
    846845                                        p->bFlags += CONTAINER_MAP_VALID_CONTAINER; 
    847846                                        if(i == 0) 
     
    865864                        return SCARD_S_SUCCESS; 
    866865                } 
    867                  
     866 
    868867                if(sscanf(pszFileName, "ksc%d", &n) <= 0) 
    869868                { 
     
    873872                        } 
    874873                } 
    875                  
     874 
    876875                logprintf(pCardData, 7, "n = %d\n", n); 
    877                  
     876 
    878877                if(n>=0 && n<vs->cert_count) 
    879878                { 
    880879                        sc_pkcs15_cert_t *cert = NULL; 
    881                          
     880 
    882881                        r = sc_pkcs15_read_certificate(vs->p15card, \ 
    883882                                (struct sc_pkcs15_cert_info *)(vs->cert_objs[n]->data), \ 
     
    888887                                return SCARD_E_FILE_NOT_FOUND; 
    889888                        } 
    890                          
     889 
    891890                        *pcbData = cert->data_len; 
    892891                        *ppbData = pCardData->pfnCspAlloc(*pcbData); 
    893                          
     892 
    894893                        if(*ppbData == NULL) 
    895894                        { 
     
    897896                                return SCARD_E_NO_MEMORY; 
    898897                        } 
    899                          
     898 
    900899                        CopyMemory(*ppbData, cert->data, *pcbData); 
    901900 
     
    907906 
    908907                        sc_pkcs15_free_certificate(cert); 
    909                          
     908 
    910909                        return SCARD_S_SUCCESS; 
    911910                } 
    912911        } 
    913          
     912 
    914913        logprintf(pCardData, 5, "File not found\n"); 
    915914        return SCARD_E_FILE_NOT_FOUND; 
     
    928927        if(!pCardData) 
    929928                return SCARD_E_INVALID_PARAMETER; 
    930                  
     929 
    931930        if(pszDirectoryName == NULL) 
    932931        { 
    933                 if(strcmp(pszFileName, "cardcf") == 0)  
     932                if(strcmp(pszFileName, "cardcf") == 0) 
    934933                { 
    935934                        logprintf(pCardData, 2, "write cardcf ok.\n"); 
     
    938937                } 
    939938        } 
    940          
     939 
    941940        return SCARD_E_FILE_NOT_FOUND; 
    942941} 
     
    960959        const char root_files[] = "cardapps\0cardcf\0cardid\0\0"; 
    961960        const char mscp_files[] = "kxc00\0kxc01\0cmapfile\0\0"; 
    962          
     961 
    963962        logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData); 
    964963        logprintf(pCardData, 1, "CardEnumFiles\n"); 
    965          
     964 
    966965        if (!pCardData) return SCARD_E_INVALID_PARAMETER; 
    967966        if (!pmszFileNames) return SCARD_E_INVALID_PARAMETER; 
     
    969968        if (dwFlags) return SCARD_E_INVALID_PARAMETER; 
    970969 
    971         if (!pszDirectoryName || !strlen(pszDirectoryName))  
     970        if (!pszDirectoryName || !strlen(pszDirectoryName)) 
    972971        { 
    973972                DWORD sz = sizeof(root_files) - 1; 
     
    979978                return SCARD_S_SUCCESS; 
    980979        } 
    981         if (strcmpi(pszDirectoryName,"mscp") == 0)  
     980        if (strcmpi(pszDirectoryName,"mscp") == 0) 
    982981        { 
    983982                DWORD sz = sizeof(mscp_files) - 1; 
     
    989988                return SCARD_S_SUCCESS; 
    990989        } 
    991          
     990 
    992991        return SCARD_E_FILE_NOT_FOUND; 
    993992} 
     
    10081007{ 
    10091008        VENDOR_SPECIFIC *vs; 
    1010          
     1009 
    10111010        logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData); 
    10121011        logprintf(pCardData, 1, "CardQueryFreeSpace %X, dwFlags=%X, version=%X\n", \ 
     
    10221021        pCardFreeSpaceInfo->dwBytesAvailable = -1; 
    10231022        pCardFreeSpaceInfo->dwMaxKeyContainers = vs->cert_count; 
    1024   
     1023 
    10251024        pCardFreeSpaceInfo->dwKeyContainersAvailable = vs->cert_count; /*TODO should this be 0 */ 
    10261025 
     
    10401039        if (!pCardData) return SCARD_E_INVALID_PARAMETER; 
    10411040        if (!pKeySizes) return SCARD_E_INVALID_PARAMETER; 
    1042          
     1041 
    10431042        pKeySizes->dwVersion = CARD_KEY_SIZES_CURRENT_VERSION; 
    10441043        pKeySizes->dwMinimumBitlen = 512; 
     
    10841083 
    10851084        if (!(pInfo->bContainerIndex < vs->cert_count)) 
    1086     {     
     1085    { 
    10871086        return SCARD_E_INVALID_PARAMETER; 
    10881087    } 
     
    10911090        cert_info = (struct sc_pkcs15_cert_info *) \ 
    10921091        (vs->cert_objs[pInfo->bContainerIndex]->data); 
    1093      
     1092 
    10941093    for(i = 0; i < vs->prkey_count; i++) 
    1095     {     
     1094    { 
    10961095        sc_pkcs15_object_t *obj = (sc_pkcs15_object_t *)vs->prkey_objs[i]; 
    10971096        if(sc_pkcs15_compare_id(&((struct sc_pkcs15_prkey_info *) obj->data)->id, &(cert_info->id))) 
     
    11071106        return SCARD_E_INVALID_PARAMETER; 
    11081107    } 
    1109     
     1108 
    11101109    prkey_info = (sc_pkcs15_prkey_info_t*)(vs->pkey->data); 
    11111110 
    1112          
     1111 
    11131112        /* input and output buffers are always the same size */ 
    11141113        pbuf = pCardData->pfnCspAlloc(pInfo->cbData); 
     
    11251124        for(ui = 0; ui < pInfo->cbData; ui++) pbuf[ui] = pInfo->pbData[pInfo->cbData-ui-1]; 
    11261125 
    1127         r = sc_pkcs15_decipher(vs->p15card, vs->pkey,  
     1126        r = sc_pkcs15_decipher(vs->p15card, vs->pkey, 
    11281127                opt_crypt_flags, pbuf, pInfo->cbData, pbuf2, pInfo->cbData); 
    11291128        logprintf(pCardData, 2, "sc_pkcs15_decipher return %d\n", r); 
     
    11321131                        sc_strerror(r)); 
    11331132        } 
    1134          
     1133 
    11351134        /*inversion donnees */ 
    11361135        for(ui = 0; ui < pInfo->cbData; ui++) pInfo->pbData[ui] = pbuf2[pInfo->cbData-ui-1]; 
     
    11521151        int r, opt_crypt_flags = 0, opt_hash_flags = 0; 
    11531152        size_t dataToSignLen = sizeof(dataToSign); 
    1154          
     1153 
    11551154        logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData); 
    11561155        logprintf(pCardData, 1, "CardSignData\n"); 
     
    11631162                pInfo->dwVersion,pInfo->bContainerIndex ,pInfo->dwKeySpec, \ 
    11641163                pInfo->dwSigningFlags, pInfo->aiHashAlg); 
    1165                  
     1164 
    11661165        logprintf(pCardData, 7, "pInfo->pbData(%i) ", pInfo->cbData); 
    11671166        loghex(pCardData, 7, pInfo->pbData, pInfo->cbData); 
     
    11741173 
    11751174        vs->pkey = NULL; 
    1176          
     1175 
    11771176        logprintf(pCardData, 2, "pInfo->dwVersion = %d\n", pInfo->dwVersion); 
    11781177 
     
    11811180        dataToSignLen = pInfo->cbData; 
    11821181 
    1183         if (CARD_PADDING_INFO_PRESENT & pInfo->dwSigningFlags)  
     1182        if (CARD_PADDING_INFO_PRESENT & pInfo->dwSigningFlags) 
    11841183        { 
    11851184                BCRYPT_PKCS1_PADDING_INFO *pinf = (BCRYPT_PKCS1_PADDING_INFO *)pInfo->pPaddingInfo; 
    1186                 if (CARD_PADDING_PKCS1 != pInfo->dwPaddingType)  
     1185                if (CARD_PADDING_PKCS1 != pInfo->dwPaddingType) 
    11871186                { 
    11881187                        logprintf(pCardData, 0, "unsupported paddingtype\n"); 
    11891188                        return SCARD_E_UNSUPPORTED_FEATURE; 
    11901189                } 
    1191                 if (!pinf->pszAlgId)  
     1190                if (!pinf->pszAlgId) 
    11921191                { 
    11931192                        /* hashAlg = CALG_SSL3_SHAMD5; */ 
     
    11951194                        opt_hash_flags = SC_ALGORITHM_RSA_HASH_MD5_SHA1; 
    11961195                } 
    1197                 else  
    1198                 { 
    1199                          
     1196                else 
     1197                { 
     1198 
    12001199                        if (wcscmp(pinf->pszAlgId, L"MD5") == 0)  opt_hash_flags = SC_ALGORITHM_RSA_HASH_MD5; 
    12011200                        else if (wcscmp(pinf->pszAlgId, L"SHA1") == 0)  opt_hash_flags = SC_ALGORITHM_RSA_HASH_SHA1; 
    12021201                        else if (wcscmp(pinf->pszAlgId, L"SHAMD5") == 0) opt_hash_flags = SC_ALGORITHM_RSA_HASH_MD5_SHA1; 
    1203                         else  
     1202                        else 
    12041203                                logprintf(pCardData, 0,"unknown AlgId %S\n",NULLWSTR(pinf->pszAlgId)); 
    12051204                } 
     
    12081207        { 
    12091208                logprintf(pCardData, 3, "CARD_PADDING_INFO_PRESENT not set\n"); 
    1210                  
    1211                 if (GET_ALG_CLASS(hashAlg) != ALG_CLASS_HASH)  
     1209 
     1210                if (GET_ALG_CLASS(hashAlg) != ALG_CLASS_HASH) 
    12121211                { 
    12131212                        logprintf(pCardData, 0, "bogus aiHashAlg\n"); 
     
    12151214                } 
    12161215 
    1217                 if (hashAlg == CALG_MD5)  
     1216                if (hashAlg == CALG_MD5) 
    12181217                        opt_hash_flags = SC_ALGORITHM_RSA_HASH_MD5; 
    1219                 else if (hashAlg == CALG_SHA1)  
     1218                else if (hashAlg == CALG_SHA1) 
    12201219                        opt_hash_flags = SC_ALGORITHM_RSA_HASH_SHA1; 
    12211220                else if (hashAlg == CALG_SSL3_SHAMD5) 
     
    12261225 
    12271226        /* From sc-minidriver_specs_v7.docx pp.76: 
    1228          * 'The Base CSP/KSP performs the hashing operation on the data before passing it  
     1227         * 'The Base CSP/KSP performs the hashing operation on the data before passing it 
    12291228         *      to CardSignData for signature.' 
    1230          * So, the SC_ALGORITHM_RSA_HASH_* flags should not be passed to pkcs15 library  
     1229         * So, the SC_ALGORITHM_RSA_HASH_* flags should not be passed to pkcs15 library 
    12311230         *      when calculating the signature . 
    12321231         * 
    12331232         * From sc-minidriver_specs_v7.docx pp.76: 
    1234          * 'If the aiHashAlg member is nonzero, it specifies the hash algorithm’s object identifier (OID)  
     1233         * 'If the aiHashAlg member is nonzero, it specifies the hash algorithm’s object identifier (OID) 
    12351234         *  that is encoded in the PKCS padding.' 
    12361235         * So, the digest info has be included into the data to be signed. 
     
    12471246        } 
    12481247        opt_crypt_flags = SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_HASH_NONE; 
    1249          
     1248 
    12501249        if(!(pInfo->bContainerIndex < vs->cert_count)) 
    12511250        { 
    12521251                return SCARD_E_INVALID_PARAMETER; 
    12531252        } 
    1254                  
     1253 
    12551254        cert_info = (struct sc_pkcs15_cert_info *) \ 
    12561255                (vs->cert_objs[pInfo->bContainerIndex]->data); 
     
    12641263        pInfo->cbSignedData = prkey_info->modulus_length / 8; 
    12651264        logprintf(pCardData, 3, "pInfo->cbSignedData = %d\n", pInfo->cbSignedData); 
    1266          
     1265 
    12671266        if(!(pInfo->dwSigningFlags&CARD_BUFFER_SIZE_ONLY)) 
    12681267        { 
     
    12701269                BYTE *pbuf = NULL; 
    12711270                DWORD lg; 
    1272                  
     1271 
    12731272                lg = pInfo->cbSignedData; 
    12741273                logprintf(pCardData, 3, "lg = %d\n", lg); 
    12751274                pbuf = pCardData->pfnCspAlloc(lg); 
    1276                 if (!pbuf)  
     1275                if (!pbuf) 
    12771276                { 
    12781277                        return SCARD_E_NO_MEMORY; 
    12791278                } 
    1280                  
     1279 
    12811280                logprintf(pCardData, 7, "Data to sign: "); 
    12821281                loghex(pCardData, 7, dataToSign, dataToSignLen); 
    12831282 
    12841283                pInfo->pbSignedData = pCardData->pfnCspAlloc(pInfo->cbSignedData); 
    1285                 if (!pInfo->pbSignedData)  
     1284                if (!pInfo->pbSignedData) 
    12861285                { 
    12871286                        pCardData->pfnCspFree(pbuf); 
    12881287                        return SCARD_E_NO_MEMORY; 
    12891288                } 
    1290                  
     1289 
    12911290                r = sc_pkcs15_compute_signature(vs->p15card, vs->pkey, \ 
    12921291                        opt_crypt_flags, dataToSign, dataToSignLen, pbuf, lg); 
     
    12991298 
    13001299                pInfo->cbSignedData = r; 
    1301                  
     1300 
    13021301                /*inversion donnees*/ 
    13031302                for(i = 0; i < r; i++) pInfo->pbSignedData[i] = pbuf[r-i-1]; 
     
    13101309                logprintf(pCardData, 7, "pInfo->pbSignedData "); 
    13111310                loghex(pCardData, 7, pInfo->pbSignedData, pInfo->cbSignedData); 
    1312                  
    1313         } 
    1314          
     1311 
     1312        } 
     1313 
    13151314        logprintf(pCardData, 3, "CardSignData, dwVersion=%u, name=%S, hScard=0x%08X," \ 
    13161315                "hSCardCtx=0x%08X\n", pCardData->dwVersion, \ 
     
    13821381        logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData); 
    13831382        logprintf(pCardData, 1, "CardAuthenticateEx\n"); 
    1384          
     1383 
    13851384        if (!pCardData) return SCARD_E_INVALID_PARAMETER; 
    1386          
     1385 
    13871386        logprintf(pCardData, 2, "CardAuthenticateEx: PinId=%u, dwFlags=0x%08X, cbPinData=%u, Attempts %s\n", 
    13881387                PinId,dwFlags,cbPinData,pcAttemptsRemaining ? "YES" : "NO"); 
     
    13951394                dwFlags == CARD_AUTHENTICATE_SESSION_PIN) 
    13961395                        return SCARD_E_UNSUPPORTED_FEATURE; 
    1397         if (dwFlags && dwFlags != CARD_PIN_SILENT_CONTEXT)  
     1396        if (dwFlags && dwFlags != CARD_PIN_SILENT_CONTEXT) 
    13981397                return SCARD_E_INVALID_PARAMETER; 
    13991398 
    14001399        if (NULL == pbPinData) return SCARD_E_INVALID_PARAMETER; 
    1401          
     1400 
    14021401        if (PinId != ROLE_USER) return SCARD_E_INVALID_PARAMETER; 
    1403          
     1402 
    14041403        r = get_pin_by_role(pCardData, ROLE_USER, &pin_obj); 
    14051404        if (r != SCARD_S_SUCCESS) 
     
    14101409 
    14111410        r = sc_pkcs15_verify_pin(vs->p15card, pin_obj, (const u8 *) pbPinData, cbPinData); 
    1412         if (r)  
     1411        if (r) 
    14131412        { 
    14141413                logprintf(pCardData, 2, "PIN code verification failed: %s\n", sc_strerror(r)); 
    1415                  
    1416                 if(pcAttemptsRemaining)  
     1414 
     1415                if(pcAttemptsRemaining) 
    14171416                { 
    14181417                        (*pcAttemptsRemaining) = -1; 
     
    14201419                return SCARD_W_WRONG_CHV; 
    14211420        } 
    1422          
     1421 
    14231422        logprintf(pCardData, 2, "Pin code correct.\n"); 
    1424          
     1423 
    14251424        SET_PIN(vs->cardFiles.file_cardcf.bPinsFreshness, ROLE_USER); 
    14261425        logprintf(pCardData, 7, "PinsFreshness = %d\n", 
     
    14541453        logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData); 
    14551454        logprintf(pCardData, 1, "CardDeauthenticateEx PinId=%d dwFlags=0x%08X\n",PinId, dwFlags); 
    1456          
     1455 
    14571456        if (!pCardData) return SCARD_E_INVALID_PARAMETER; 
    1458          
     1457 
    14591458        vs = (VENDOR_SPECIFIC*)(pCardData->pvVendorSpecific); 
    14601459 
     
    14811480 
    14821481        check_reader_status(pCardData); 
    1483          
     1482 
    14841483        if (!pCardData) return SCARD_E_INVALID_PARAMETER; 
    14851484        logprintf(pCardData, 2, "CardGetContainerProperty bContainerIndex=%u, wszProperty=%S," \ 
     
    14951494                if (pdwDataLen) *pdwDataLen = sizeof(*p); 
    14961495                if (cbData >= sizeof(DWORD)) 
    1497                         if (p->dwVersion != CONTAINER_INFO_CURRENT_VERSION &&  
     1496                        if (p->dwVersion != CONTAINER_INFO_CURRENT_VERSION && 
    14981497                                p->dwVersion != 0 ) return ERROR_REVISION_MISMATCH; 
    14991498                if (cbData < sizeof(*p)) return ERROR_INSUFFICIENT_BUFFER; 
    15001499                return CardGetContainerInfo(pCardData,bContainerIndex,0,p); 
    15011500        } 
    1502          
    1503         if (wcscmp(CCP_PIN_IDENTIFIER,wszProperty) == 0)  
     1501 
     1502        if (wcscmp(CCP_PIN_IDENTIFIER,wszProperty) == 0) 
    15041503        { 
    15051504                PPIN_ID p = (PPIN_ID) pbData; 
     
    15101509                return SCARD_S_SUCCESS; 
    15111510        } 
    1512          
     1511 
    15131512        return SCARD_E_INVALID_PARAMETER; 
    15141513} 
     
    15431542        if (!pbData) return SCARD_E_INVALID_PARAMETER; 
    15441543        if (!pdwDataLen) return SCARD_E_INVALID_PARAMETER; 
    1545          
     1544 
    15461545        vs = (VENDOR_SPECIFIC*)(pCardData->pvVendorSpecific); 
    15471546 
     
    15531552                if (pdwDataLen) *pdwDataLen = sizeof(*pCardFreeSpaceInfo); 
    15541553                if (cbData < sizeof(*pCardFreeSpaceInfo)) return SCARD_E_NO_MEMORY; 
    1555                 if (pCardFreeSpaceInfo->dwVersion > CARD_FREE_SPACE_INFO_CURRENT_VERSION )  
     1554                if (pCardFreeSpaceInfo->dwVersion > CARD_FREE_SPACE_INFO_CURRENT_VERSION ) 
    15561555                        return ERROR_REVISION_MISMATCH; 
    15571556 
     
    15731572                if (pCardCapabilities->dwVersion != CARD_CAPABILITIES_CURRENT_VERSION && 
    15741573                        pCardCapabilities->dwVersion != 0) return ERROR_REVISION_MISMATCH; 
    1575                  
     1574 
    15761575                pCardCapabilities->dwVersion = CARD_CAPABILITIES_CURRENT_VERSION; 
    15771576                pCardCapabilities->fCertificateCompression = TRUE; 
     
    15901589                if (pKeySizes->dwVersion != CARD_KEY_SIZES_CURRENT_VERSION && 
    15911590                        pKeySizes->dwVersion != 0) return ERROR_REVISION_MISMATCH; 
    1592                  
     1591 
    15931592                pKeySizes->dwVersion = CARD_KEY_SIZES_CURRENT_VERSION; 
    15941593                pKeySizes->dwMinimumBitlen = 512; 
     
    15961595                pKeySizes->dwMaximumBitlen = 16384; 
    15971596                pKeySizes->dwIncrementalBitlen = 64; 
    1598          
     1597 
    15991598                logprintf(pCardData, 7, "pKeySizes "); 
    16001599                loghex(pCardData, 7, pbData, *pdwDataLen); 
    1601                  
     1600 
    16021601                return SCARD_S_SUCCESS; 
    16031602        } 
     
    16351634                return SCARD_S_SUCCESS; 
    16361635        } 
    1637         if (wcscmp(CP_CARD_GUID,wszProperty) == 0)  
     1636        if (wcscmp(CP_CARD_GUID,wszProperty) == 0) 
    16381637        { 
    16391638                if (pdwDataLen) *pdwDataLen = sizeof(vs->cardFiles.file_cardid); 
     
    16521651 
    16531652                CopyMemory(pbData,vs->p15card->tokeninfo->serial_number,sizeof(vs->p15card->tokeninfo->serial_number)); 
    1654                  
     1653 
    16551654                logprintf(pCardData, 7, "SerialNumber "); 
    16561655                loghex(pCardData, 7, pbData, *pdwDataLen); 
     
    16651664                p->PinType = AlphaNumericPinType; 
    16661665                p->dwFlags = 0; 
    1667                 switch (dwFlags)  
     1666                switch (dwFlags) 
    16681667                { 
    16691668                        case ROLE_USER: 
     
    16741673                                p->PinCachePolicy.PinCachePolicyType = PinCacheNormal; 
    16751674                                p->dwChangePermission = 0; 
    1676                                 p->dwUnblockPermission = 0;  
     1675                                p->dwUnblockPermission = 0; 
    16771676                                break; 
    16781677                        default: 
     
    16831682                loghex(pCardData, 7, pbData, *pdwDataLen); 
    16841683 
    1685                  
     1684 
    16861685                return SCARD_S_SUCCESS; 
    16871686        } 
     
    16941693                logprintf(pCardData, 7, "CARD_LIST_PINS "); 
    16951694                loghex(pCardData, 7, pbData, *pdwDataLen); 
    1696                  
     1695 
    16971696                return SCARD_S_SUCCESS; 
    16981697        } 
     
    17391738        logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData); 
    17401739        logprintf(pCardData, 1, "CardSetProperty\n"); 
    1741          
     1740 
    17421741        if (!pCardData) return SCARD_E_INVALID_PARAMETER; 
    1743          
     1742 
    17441743        logprintf(pCardData, 2, "CardSetProperty wszProperty=%S, cbDataLen=%u, dwFlags=%u",\ 
    17451744                NULLWSTR(wszProperty),cbDataLen,dwFlags); 
     
    17551754                return SCARD_S_SUCCESS; 
    17561755 
    1757         if (wcscmp(CP_CARD_CACHE_MODE, wszProperty) == 0 ||  
     1756        if (wcscmp(CP_CARD_CACHE_MODE, wszProperty) == 0 || 
    17581757                wcscmp(CP_SUPPORTS_WIN_X509_ENROLLMENT, wszProperty) == 0 || 
    17591758                wcscmp(CP_CARD_GUID, wszProperty) == 0 || 
     
    17661765 
    17671766        if (wcscmp(CP_PARENT_WINDOW, wszProperty) == 0) { 
    1768                 if (cbDataLen != sizeof(DWORD))  
     1767                if (cbDataLen != sizeof(DWORD)) 
    17691768                        return SCARD_E_INVALID_PARAMETER; 
    17701769                else 
     
    17881787        DWORD suppliedVersion = 0; 
    17891788        u8 challenge[8]; 
    1790          
    1791         if (!pCardData)  
     1789 
     1790        if (!pCardData) 
    17921791                return SCARD_E_INVALID_PARAMETER; 
    1793         if (dwFlags)  
     1792        if (dwFlags) 
    17941793                return SCARD_E_INVALID_PARAMETER; 
    1795          
     1794 
    17961795        suppliedVersion = pCardData->dwVersion; 
    17971796 
     
    18121811        vs->hScard = pCardData->hScard; 
    18131812        vs->hSCardCtx = pCardData->hSCardCtx; 
    1814          
     1813 
    18151814        /* The lowest supported version is 4. */ 
    18161815        if (pCardData->dwVersion < MINIMUM_VERSION_SUPPORTED) 
     
    18181817                return (DWORD) ERROR_REVISION_MISMATCH; 
    18191818        } 
    1820   
     1819 
    18211820        if( pCardData->hScard == 0) 
    18221821        { 
     
    18241823                return SCARD_E_INVALID_HANDLE; 
    18251824        } 
    1826          
     1825 
    18271826        logprintf(pCardData, 2, "request version pCardData->dwVersion = %d\n", pCardData->dwVersion); 
    18281827 
     
    18351834                int r; 
    18361835                sc_context_param_t ctx_param; 
    1837                  
     1836 
    18381837                vs->ctx = NULL; 
    1839                  
     1838 
    18401839                logprintf(pCardData, 3, "create ctx\n"); 
    1841                  
     1840 
    18421841                memset(&ctx_param, 0, sizeof(ctx_param)); 
    18431842                ctx_param.ver = 1; 
    18441843                ctx_param.app_name = "cardmod"; 
    1845                  
     1844 
    18461845                r = sc_context_create(&(vs->ctx), &ctx_param); 
    18471846                logprintf(pCardData, 3, "sc_context_create passed r = %d\n", r); 
    1848                 if (r)  
     1847                if (r) 
    18491848                { 
    18501849                        logprintf(pCardData, 0, "Failed to establish context: %s\n", \ 
     
    18531852                } 
    18541853        } 
    1855          
     1854 
    18561855        pCardData->pfnCardDeleteContext = CardDeleteContext; 
    18571856        pCardData->pfnCardQueryCapabilities = CardQueryCapabilities; 
     
    18801879        pCardData->pfnCardRSADecrypt = CardRSADecrypt; 
    18811880        pCardData->pfnCardConstructDHAgreement = CardConstructDHAgreement; 
    1882          
     1881 
    18831882        associate_card(pCardData); 
    1884          
    1885         logprintf(pCardData, 1, "Opensc init done.\n"); 
     1883 
     1884        logprintf(pCardData, 1, "OpenSC init done.\n"); 
    18861885 
    18871886        if(sc_get_challenge(vs->p15card->card, challenge, sizeof(challenge))) 
     
    18951894                vs->cardFiles.file_cardcf.wFilesFreshness = challenge[3]*256+challenge[4]; 
    18961895        } 
    1897                  
     1896 
    18981897        if (suppliedVersion > 4) { 
    1899                 pCardData->pfnCardDeriveKey = CardDeriveKey;  
    1900                 pCardData->pfnCardDestroyDHAgreement = CardDestroyDHAgreement;  
    1901                 pCardData->pfnCspGetDHAgreement = CspGetDHAgreement;  
    1902                  
     1898                pCardData->pfnCardDeriveKey = CardDeriveKey; 
     1899                pCardData->pfnCardDestroyDHAgreement = CardDestroyDHAgreement; 
     1900                pCardData->pfnCspGetDHAgreement = CspGetDHAgreement; 
     1901 
    19031902                if (suppliedVersion > 5 ) { 
    19041903                        pCardData->pfnCardGetChallengeEx = CardGetChallengeEx; 
     
    19231922        BYTE empty_cardcf[6]={0,0,0,0,0,0}; 
    19241923        BYTE empty_cardid[16]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; 
    1925          
     1924 
    19261925        logprintf(pCardData, 1, "associate_card\n"); 
    1927         vs = (VENDOR_SPECIFIC*)(pCardData->pvVendorSpecific); 
     1926        vs = (VENDOR_SPECIFIC*)(pCardData->pvVendorSpecific); 
    19281927        /* 
    19291928         * set the addresses of the reader and card handles 
    1930          * Our cardmod pcsc code will use these  when we call sc_ctx_use_reader  
     1929         * Our cardmod pcsc code will use these  when we call sc_ctx_use_reader 
    19311930         * We use the address of the handles as provided in the pCardData 
    19321931         */ 
     
    19411940        logprintf(pCardData, 5, "cardmod_use_handles %d\n", \ 
    19421941        sc_ctx_use_reader(vs->ctx, &vs->hSCardCtx, &vs->hScard)); 
    1943          
     1942 
    19441943        /* should be only one reader */ 
    19451944        logprintf(pCardData, 5, "sc_ctx_get_reader_count(ctx): %d\n", \ 
     
    19501949        { 
    19511950                logprintf(pCardData, 3, "%s\n", NULLSTR(vs->reader->name)); 
    1952                          
     1951 
    19531952                r = sc_connect_card(vs->reader, &(vs->card)); 
    19541953                logprintf(pCardData, 2, "sc_connect_card result = %d, %s\n", \ 
     
    19701969        /* 
    19711970         * We want a 16 byte unique serial number 
    1972          * PKCS15 gives us a char string, that  
     1971         * PKCS15 gives us a char string, that 
    19731972         * appears to have been formated with %02x or %02X 
    1974          * so as to make it printable.  
     1973         * so as to make it printable. 
    19751974         * So for now we will try and convert back to bin, 
    19761975         * and use the last 32 bytes of the vs-p15card->tokeninfo->serial_number 
     
    19811980                size_t len1, len2; 
    19821981                char * cserial; 
    1983                  
     1982 
    19841983                len1 = strlen(vs->p15card->tokeninfo->serial_number); 
    19851984                cserial = vs->p15card->tokeninfo->serial_number; 
    19861985                len2 = sizeof(vs->cardFiles.file_cardid) * 2; 
    19871986                if ( len1 > len2) { 
    1988                         cserial += len1 - len2;  
     1987                        cserial += len1 - len2; 
    19891988                        len1 = len2; 
    19901989                } 
     
    19941993                loghex(pCardData, 7, vs->cardFiles.file_cardid, sizeof(vs->cardFiles.file_cardid)); 
    19951994        } 
    1996          
    1997                  
     1995 
     1996 
    19981997        r = sc_pkcs15_get_objects(vs->p15card, SC_PKCS15_TYPE_CERT_X509, \ 
    19991998                vs->cert_objs, 32); 
    2000         if (r < 0)  
     1999        if (r < 0) 
    20012000        { 
    20022001                logprintf(pCardData, 0, "Certificate enumeration failed: %s\n", \ 
     
    20042003                return SCARD_F_UNKNOWN_ERROR; 
    20052004        } 
    2006          
     2005 
    20072006        vs->cert_count = r; 
    20082007        logprintf(pCardData, 2, "Found %d certificat(s) in the card.\n", \ 
    20092008                vs->cert_count); 
    2010          
     2009 
    20112010        r = sc_pkcs15_get_objects(vs->p15card, SC_PKCS15_TYPE_PRKEY_RSA, \ 
    20122011                vs->prkey_objs, 32); 
    2013         if (r < 0)  
     2012        if (r < 0) 
    20142013        { 
    20152014                logprintf(pCardData, 0, "Private key enumeration failed: %s\n", \ 
     
    20172016                return SCARD_F_UNKNOWN_ERROR; 
    20182017        } 
    2019          
     2018 
    20202019        vs->prkey_count = r; 
    20212020        logprintf(pCardData, 2, "Found %d private key(s) in the card.\n", \ 
     
    20242023        r = sc_pkcs15_get_objects(vs->p15card, SC_PKCS15_TYPE_AUTH_PIN, \ 
    20252024                vs->pin_objs, 8); 
    2026         if (r < 0)  
     2025        if (r < 0) 
    20272026        { 
    20282027                logprintf(pCardData, 2, "Pin object enumeration failed: %s\n", \ 
     
    20302029                return SCARD_F_UNKNOWN_ERROR; 
    20312030        } 
    2032          
     2031 
    20332032        vs->pin_count = r; 
    20342033        logprintf(pCardData, 2, "Found %d pin(s) in the card.\n", \ 
    20352034                vs->pin_count); 
    20362035 
    2037 #if 1    
     2036#if 1 
    20382037        dump_objects(pCardData); 
    20392038#endif 
     
    20452044static int disassociate_card(PCARD_DATA pCardData) 
    20462045{ 
    2047          
     2046 
    20482047    VENDOR_SPECIFIC *vs; 
    20492048        int i; 
     
    20512050        vs = (VENDOR_SPECIFIC*)(pCardData->pvVendorSpecific); 
    20522051        logprintf(pCardData, 1, "disassociate_card\n"); 
    2053          
     2052 
    20542053        if(vs->pin != NULL) 
    2055         {        
     2054        { 
    20562055                free(vs->pin); 
    20572056                vs->pin = NULL; 
     
    20622061        } 
    20632062        vs->cert_count = 0; 
    2064          
     2063 
    20652064        for (i = 0; i < vs->prkey_count; i++) { 
    20662065                vs->prkey_objs[i] = NULL; 
    20672066        } 
    20682067        vs->prkey_count = 0; 
    2069          
     2068 
    20702069        for (i = 0; i < vs->pin_count; i++) { 
    20712070                vs->pin_objs[i] = NULL; 
    20722071        } 
    20732072        vs->pin_count = 0; 
    2074          
     2073 
    20752074 
    20762075        if(vs->p15card) 
     
    21062105                hModule, ul_reason_for_call, lpReserved, GetCurrentProcessId(), GetCurrentThreadId()); 
    21072106#endif 
    2108         switch (ul_reason_for_call)  
     2107        switch (ul_reason_for_call) 
    21092108        { 
    21102109                case DLL_PROCESS_ATTACH: 
     
    21292128#pragma managed(pop) 
    21302129#endif 
     2130#endif 
  • src/minidriver/opensc-minidriver.inf.in

    rf636cc1 r44cf3d0  
    141141 
    142142[Strings] 
    143 ProviderName ="Opensc" 
    144 MediaDescription="Opensc Smart Card Minidriver Installation Disk" 
    145 CardDeviceName="Opensc Minidriver for Smart Card" 
     143ProviderName ="OpenSC" 
     144MediaDescription="OpenSC Smart Card Minidriver Installation Disk" 
     145CardDeviceName="OpenSC Minidriver" 
    146146SmartCardName="SOFTWARE\Microsoft\Cryptography\Calais\SmartCards\Cev Westcos" 
    147147SmartCardNameWOW64="SOFTWARE\Wow6432Node\Microsoft\Cryptography\Calais\SmartCards\Cev Westcos" 
    148 SmartCardCardModule="opensc-cardmod32.dll" 
    149 SmartCardCardModule64="opensc-cardmod64.dll" 
     148SmartCardCardModule="opensc-minidriver.dll" 
  • win32/Make.rules.mak

    r639ca65 r44cf3d0  
    11OPENSC_FEATURES = pcsc 
    22 
    3 #Include support of minidriver 'cardmod' 
    4 MINIDRIVER_DEF = /DENABLE_CARDMOD 
     3#Include support for minidriver 
     4MINIDRIVER_DEF = /DENABLE_MINIDRIVER 
    55 
    66#Build MSI with the Windows Installer XML (WIX) toolkit, requires WIX >= 3.6 
  • win32/OpenSC.wxs.in

    r4ec415f r44cf3d0  
    3232        </Component> 
    3333        <Component Id="opensc_minidriver.dll" Guid="*"> 
    34           <File Source="$(var.SOURCE_DIR)\src\cardmod\opensc-cardmod.dll" Vital="yes"/> 
     34          <File Source="$(var.SOURCE_DIR)\src\minidriver\opensc-minidriver.dll" Vital="yes"/> 
    3535        </Component> 
    3636      </Directory> 
Note: See TracChangeset for help on using the changeset viewer.