NB! This project is outdated and unmaintained, please refer to the OpenSC WindowsInstaller instead!

Changeset 99


Ignore:
Timestamp:
04/04/08 22:36:21 (4 years ago)
Author:
alonbl
Message:

Cleanup csp11 to be usable under mingw and autoconf/automake/libtool

Location:
trunk/csp11
Files:
6 deleted
23 edited
16 copied

Legend:

Unmodified
Added
Removed
  • trunk/csp11

    • Property svn:ignore set to
      Makefile
      Makefile.in
      core
      archive
      acinclude.m4
      aclocal.m4
      autom4te.cache
      compile
      confdefs.h
      config.*
      configure
      conftest
      conftest.c
      depcomp
      install-sh
      libtool
      libtool.m4
      ltmain.sh
      missing
      mkinstalldirs
      so_locations
      stamp-h*

      .deps
      .libs
      .#*#
      .*.bak
      .*.orig
      .*.rej
      .*~
      #*#
      *.bak
      *.d
      *.def
      *.dll
      *.exe
      *.la
      *.lib
      *.lo
      *.orig
      *.pdb
      *.rej
      *.u
      *.rc
      *.pc
      *~
      *.gz
      *.bz2
      *.[0-9]
      *.html
      *.gif
      *.css
      *.out
  • trunk/csp11/README

    r39 r99  
    2121 - copy cspsign.exe to system32 
    2222 - run cspsign s csp11.dll csp11.sig 
    23  - run csp11ins 
     23 - run csp11ins csp11.sig 
    2424 
    2525Win 95/98/ME/NT4 was not tested. Note from the original README: 
  • trunk/csp11/cert-installer

    • Property svn:ignore set to
      Makefile
      Makefile.in
      core
      archive
      acinclude.m4
      aclocal.m4
      autom4te.cache
      compile
      confdefs.h
      config.*
      configure
      conftest
      conftest.c
      depcomp
      install-sh
      libtool
      libtool.m4
      ltmain.sh
      missing
      mkinstalldirs
      so_locations
      stamp-h*

      .deps
      .libs
      .#*#
      .*.bak
      .*.orig
      .*.rej
      .*~
      #*#
      *.bak
      *.d
      *.def
      *.dll
      *.exe
      *.la
      *.lib
      *.lo
      *.orig
      *.pdb
      *.rej
      *.u
      *.rc
      *.pc
      *~
      *.gz
      *.bz2
      *.[0-9]
      *.html
      *.gif
      *.css
      *.out
  • trunk/csp11/installer

    • Property svn:ignore set to
      Makefile
      Makefile.in
      core
      archive
      acinclude.m4
      aclocal.m4
      autom4te.cache
      compile
      confdefs.h
      config.*
      configure
      conftest
      conftest.c
      depcomp
      install-sh
      libtool
      libtool.m4
      ltmain.sh
      missing
      mkinstalldirs
      so_locations
      stamp-h*

      .deps
      .libs
      .#*#
      .*.bak
      .*.orig
      .*.rej
      .*~
      #*#
      *.bak
      *.d
      *.def
      *.dll
      *.exe
      *.la
      *.lib
      *.lo
      *.orig
      *.pdb
      *.rej
      *.u
      *.rc
      *.pc
      *~
      *.gz
      *.bz2
      *.[0-9]
      *.html
      *.gif
      *.css
      *.out
  • trunk/csp11/installer/csp11ins.c

    r39 r99  
    3434 */ 
    3535 
    36 #undef UNICODE                                  // ## Not Yet 
     36#ifdef HAVE_CONFIG_H 
     37#include <config.h> 
     38#endif 
    3739#include <stdlib.h> 
    3840#include <stdio.h> 
     
    6668/** \brief Register the CSP11 DLL. 
    6769 */ 
    68 int __cdecl main() 
     70int main(int argc, char *argv[]) 
    6971{ 
     72    char *szSigFile = NULL; 
     73 
     74    if (argc != 2) { 
     75        fprintf (stderr, "Usage: %s sig-file\n", argv[0]); 
     76        exit (1); 
     77    } 
     78 
     79    szSigFile = argv[1]; 
     80 
    7081    /** 1. Open the signature file.*/ 
    71     if ((hSigFile = CreateFile("csp11.sig", 
     82    if ((hSigFile = CreateFileA(szSigFile, 
    7283                               GENERIC_READ, 0, NULL, 
    7384                               OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 
     
    117128 
    118129        /** 6.Create or open a key in local machine for CSP #11:*/ 
    119         if ((ret = RegCreateKeyEx(HKEY_LOCAL_MACHINE, 
     130        if ((ret = RegCreateKeyExA(HKEY_LOCAL_MACHINE, 
    120131                                  (const char *) szProvider, 
    121132                                  0L, "", REG_OPTION_NON_VOLATILE, 
     
    127138 
    128139        /** 7. Register the "Image Path" for CSP 11 DLL.*/ 
    129         if ((ret = RegSetValueEx(hKey, "Image Path", 0L, REG_SZ, szImagePath, 
    130                                  strlen(szImagePath)+1)) != ERROR_SUCCESS) 
     140        if ((ret = RegSetValueExA(hKey, "Image Path", 0L, REG_SZ, (PBYTE)szImagePath, 
     141                                 (DWORD)strlen(szImagePath)+1)) != ERROR_SUCCESS) 
    131142        { 
    132143            printf("Error setting registry Image Path.\n"); 
     
    136147        /** 8. Set CSP type to PROV_RSA_FULL (==1). */ 
    137148        dwValue = CSP11_PROV_TYPE; 
    138         if ((ret = RegSetValueEx(hKey, "Type", 0L, REG_DWORD, 
    139                                  (LPTSTR) &dwValue, 
     149        if ((ret = RegSetValueExA(hKey, "Type", 0L, REG_DWORD, 
     150                                 (PBYTE)&dwValue, 
    140151                                 sizeof(DWORD))) != ERROR_SUCCESS) 
    141152        { 
     
    145156 
    146157        /** 9. Store signature. */ 
    147         if ((ret = RegSetValueEx(hKey, "Signature", 0L, REG_BINARY,  
    148                                  (LPTSTR) lpvAddress, 
     158        if ((ret = RegSetValueExA(hKey, "Signature", 0L, REG_BINARY,  
     159                                 lpvAddress, 
    149160                                 fileSize)) != ERROR_SUCCESS) 
    150161        { 
     
    157168 
    158169        /** 10.Create or open a key in local machine for CSP of type 001*/ 
    159         if ((ret = RegCreateKeyEx(HKEY_LOCAL_MACHINE, 
     170        if ((ret = RegCreateKeyExA(HKEY_LOCAL_MACHINE, 
    160171                                  (const char *) szType, 
    161172                                  0L, "", REG_OPTION_NON_VOLATILE, 
  • trunk/csp11/src

    • Property svn:ignore set to
      Makefile
      Makefile.in
      core
      archive
      acinclude.m4
      aclocal.m4
      autom4te.cache
      compile
      confdefs.h
      config.*
      configure
      conftest
      conftest.c
      depcomp
      install-sh
      libtool
      libtool.m4
      ltmain.sh
      missing
      mkinstalldirs
      so_locations
      stamp-h*

      .deps
      .libs
      .#*#
      .*.bak
      .*.orig
      .*.rej
      .*~
      #*#
      *.bak
      *.d
      *.def
      *.dll
      *.exe
      *.la
      *.lib
      *.lo
      *.orig
      *.pdb
      *.rej
      *.u
      *.rc
      *.pc
      *~
      *.gz
      *.bz2
      *.[0-9]
      *.html
      *.gif
      *.css
      *.out
  • trunk/csp11/src/Makefile.mak

    r39 r99  
    33LIBS = User32.lib 
    44 
    5 COPTS =  /Zi /MD /nologo /D_WIN32_WINNT=0x0400 /I$(CSPDK_INC) /I$(OPENSC_INC) 
     5COPTS =  /Zi /MD /nologo /D_WIN32_WINNT=0x0400 /DWIN32_LEAN_AND_MEAN /DUNICODE /I$(CSPDK_INC) /I$(OPENSC_INC) /I../include 
    66LINKFLAGS = /DEBUG /NOLOGO /INCREMENTAL:NO /MACHINE:IX86 
    77 
     
    1616        cl $(COPTS) /c $< 
    1717 
    18 $(TARGET): $(OBJECTS)  
    19         rc csp11.rc 
     18csp11.def:      csp11.exports 
     19        echo LIBRARY CSP11 > csp11.def 
     20        echo DESCRIPTION 'Cryptographic Service Provider #11' >> csp11.def 
     21        type csp11.exports >> csp11.def 
     22 
     23$(TARGET): $(OBJECTS) csp11.def 
     24        rc resource.rc 
    2025        link $(LINKFLAGS) /dll /def:csp11.def /implib:csp11.lib /out:csp11.dll \ 
    21                 csp11.res $(OBJECTS) $(LIBS) 
     26                resource.res $(OBJECTS) $(LIBS) 
  • trunk/csp11/src/csp-debug.c

    r39 r99  
    2828 */ 
    2929 
     30#ifdef HAVE_CONFIG_H 
     31#include <config.h> 
     32#endif 
    3033#include <stdlib.h> 
    3134#include <stdio.h> 
  • trunk/csp11/src/csp-debug.h

    r39 r99  
    3030 
    3131#ifndef _CSP_DEBUG_H_ 
    32 #define UNICODE 
    3332#define _CSP_DEBUG_H_       /**< csp11.h inclusion tag. */ 
    3433#ifdef __cplusplus 
     
    6968} 
    7069#endif 
    71 #endif // _CSP_DEBUG_H_ 
     70#endif /* _CSP_DEBUG_H_ */ 
    7271 
  • trunk/csp11/src/csp11.c

    r39 r99  
    4343 */ 
    4444 
    45 #ifndef WIN32_LEAN_AND_MEAN 
    46 #define WIN32_LEAN_AND_MEAN 
     45#ifdef HAVE_CONFIG_H 
     46#include <config.h> 
    4747#endif 
    48  
    49 #define UNICODE             
    5048#include <stdio.h> 
    5149#include <stdlib.h> 
     
    5452#ifdef _MSC_VER 
    5553#include <cspdk.h> 
    56 #include "missdef.h" 
     54#include <missdef.h> 
    5755#else 
    58 #include "misscrypt.h" 
     56#include <misscrypt.h> 
    5957#endif 
    60 #include <rsaref/win32.h> 
    61 #include <rsaref/pkcs11.h> 
     58#include <pkcs11.h> 
    6259#include "csp11.h" 
    6360#include "pkcs11-services.h" 
    6461#include "ui-pin.h" 
    6562#include "csp-debug.h" 
     63 
     64/** \brief Return the wanted handler index in the given granted handlers list. 
     65 * 
     66 *  \param grantedHandles   Pointer to the beginning of the granted handlers 
     67 *                          tab. 
     68 *  \param  max_len         The maximum lenth of the granted handlers list. 
     69 *  \param wantedHandle    The wanted handler. 
     70 * 
     71 *  \return An integer from 0 to max_len-1 if a granted context is found. 
     72 *          Negative value if not. 
     73 *  \ingroup    SPInternal 
     74 */ 
     75static int findGrantedHandle(HANDLE *grantedHandles, int max_len, HANDLE wantedHandle); 
     76 
     77/** \brief Grants a cryptographic handle. 
     78 * 
     79 *  Used to remember granted handlers. 
     80 * 
     81 *  \param  grantedHandles Pointer to the granted handler list pointer. 
     82 *  \param  lenth   Pointer to the lenth of the list. 
     83 *  \param  lenth Maximum authorized lenth of the list. 0 means unlimited. 
     84 *  \param  handle  The handle to grant. 
     85 * 
     86 *  \return TRUE if everything went OK. 
     87 *  \ingroup    SPInternal 
     88 */ 
     89static BOOL grantHandle(HANDLE **grantedHandles, int *lenth, 
     90                  HANDLE handle); 
     91 
     92/** \brief Revokes a granted cryptographic handle. 
     93 * 
     94 *  Used to forget a granted handle. 
     95 * 
     96 *  \param  handle   Handler to the provided context to forget. 
     97 *  \param  lenth   Lenth of the granted handles list. 
     98 *  \param  grantedHandles  Pointer to the granted handles list. 
     99 * 
     100 *  \return TRUE if everything went OK. 
     101 *  \ingroup    SPInternal 
     102 */ 
     103static BOOL revokeHandle(HANDLE **grantedHandles, int *lenth, HANDLE handle); 
     104 
     105/** \brief Check if a crypto handler was provided. 
     106 * 
     107 *  Check if the given handler is really a valid cryptographic context handler. 
     108 * 
     109 *  \param  lenth   Number of granted handles. 
     110 *  \param  grantedHandles  Pointer to the granted handles list. 
     111 *  \param  handle  Handle to check. 
     112 * 
     113 *  \return TRUE if the handler was granted by CSP-eleven, FALSE if not. 
     114 *  \ingroup    SPInternal 
     115 */ 
     116static BOOL grantedHandle(HANDLE *grantedHandles, int lenth, HANDLE handle); 
     117 
     118/** \brief Return the algId csp11 ALGORITHM. 
     119 * 
     120 *  Browse the algorithms table and get the wanted definition. 
     121 *   
     122 *  \param  algId   The wanted CAPI algorithm ID. 
     123 *  \param  algorithm The corresponding ALGORITHM structure. 
     124 * 
     125 *  \return TRUE if algorithm found, FALSE if not. 
     126 * 
     127 *  \ingroup SPInternal 
     128 */ 
     129static BOOL getAlgorithm(ALG_ID algId, ALGORITHM *algorithm); 
     130 
     131/** \brief Return size of produced hash value in bytes. 
     132 *   
     133 *  \warning The size is returned in BYTES. 
     134 *   
     135 *  \param Algid    Id of wanted algorithm size. 
     136 * 
     137 *  \return >0 integer if the id is supported, -1 if not. 
     138 * 
     139 *  \ingroup SPInternal 
     140 */ 
     141static DWORD getHashSize(ALG_ID Algid); 
     142 
     143/** \brief Initialise a key handler. 
     144 *   
     145 *  \param pProvCtx Pointer to the used crypto context. 
     146 *  \param pKey Pointer to the handler to fill. 
     147 *  \param algId Key algorithm CAPI ID. 
     148 *  \return TRUE; 
     149 * 
     150 *  \ingroup SPInternal 
     151 */ 
     152static BOOL initKey(PROV_CTX *pProvCtx, KEY_INFO *pKey, ALG_ID algId); 
     153 
     154/** \brief Reverse a byte string. 
     155 *  
     156 *  \param pBytes       Pointer to the bytes string. 
     157 *  \param stringLen    Length of the bytes string. 
     158 * 
     159 *  \return TRUE if the bytes string was successfully reversed. 
     160 *  \ingroup SPInternal 
     161 *  \note Hey school boys, students or better, take a look ! 
     162 *  Gambin gave us a teach: a very good algo to reverse bytes string. 
     163 */ 
     164static BOOL reverseBytesString(BYTE *pBytes, DWORD stringLen); 
     165 
     166/** \brief Set hash algi and alg oid. 
     167 * 
     168 *  Set the hash algid and try to get the corresponding oid. 
     169 *  If no oid found, bad alg id. 
     170 *  \param  algId   The alg Id to set. 
     171 *  \param  pHash    Pointer to the key information structure. 
     172 *  \ingroup SPInternal 
     173 * 
     174 *  \return TRUE if algid and oid are set. 
     175 */ 
     176static BOOL setHashAlgId(ALG_ID algId, HASH_INFO *pHash); 
     177 
     178/** \brief Set key algi and alg oid. 
     179 * 
     180 *  Set the key algid and try to get the corresponding oid. 
     181 *  If no oid found, bad alg id. 
     182 *  \param  algId   The alg Id to set. 
     183 *  \param  pKey    Pointer to the key information structure. 
     184 * 
     185 *  \ingroup SPInternal 
     186 *  \return TRUE if algid and oid are set. 
     187 */ 
     188static BOOL setKeyAlgId(ALG_ID algId, KEY_INFO *pKey); 
    66189 
    67190 
     
    83206static int  grantedKeysNb = 0; /**< Number of actual granted keys.*/ 
    84207 
    85 //static HANDLE  GetProcessHeap() = NULL;     /**< Handle to the csp11 heap object. */ 
     208#if 0 
     209static HANDLE  GetProcessHeap() = NULL;     /**< Handle to the csp11 heap object. */ 
     210#endif 
    86211 
    87212ALGORITHM Algs[] = { 
     
    120245BOOL WINAPI 
    121246DllMain( 
    122   HINSTANCE hinstDLL,  // handle to the DLL module 
    123   DWORD fdwReason,     // reason for calling function 
    124   LPVOID lpvReserved)  // reserved 
     247  HINSTANCE hinstDLL,  /* handle to the DLL module */ 
     248  DWORD fdwReason,     /* reason for calling function */ 
     249  LPVOID lpvReserved)  /* reserved */ 
    125250{ 
    126251    switch( fdwReason )  
     
    151276 */ 
    152277BOOL WINAPI 
    153 CPAcquireContext( 
     278CPAcquireContextW( 
    154279    OUT HCRYPTPROV *phProv, 
    155280    IN  LPCSTR szContainer, 
    156281    IN  DWORD dwFlags, 
    157     IN  PVTableProvStruc pVTable) 
     282    IN  PVTableProvStrucW pVTable) 
    158283{ 
    159     LPSTR cName = NULL;            /*  Local copy of szContainer C string pointer */ 
     284    LPCSTR cName = NULL;            /*  Local copy of szContainer C string pointer */ 
    160285    size_t nameSize = 0;        /* Size of the provided container name.*/ 
    161286    PROV_CTX *pProvCtx = NULL;      /* Provider context */ 
     
    165290                                         applicable.*/ 
    166291    char debug[255]; 
    167     DWORD FuncReturnedhWnd = 0; 
     292    HWND FuncReturnedhWnd = 0; 
    168293     
    169294    DEBUG(3,"_-_-_-_-_-_-_-_-_Acquiring Context-_-_-_-_-_-_-_-_-\n"); 
     
    19112036    hashValLen = getHashSize(pHash->Algid); 
    19122037    /**   - If hash size < 0, bad hash.*/ 
    1913     if(hashValLen < 0) 
     2038    if(hashValLen == 0) 
    19142039    { 
    19152040        SetLastError(NTE_BAD_HASH); 
     
    20062131                hashLen = getHashSize(pHash->Algid); 
    20072132                /**   - If hash size < 0, bad hash.*/ 
    2008                 if(hashLen < 0) 
     2133                if(hashLen == 0) 
    20092134                { 
    20102135                    SetLastError(NTE_BAD_HASH); 
     
    20472172                hashLen = getHashSize(pHash->Algid); 
    20482173                /**   - If hash size < 0, bad hash.*/ 
    2049                 if(hashLen < 0) 
     2174                if(hashLen == 0) 
    20502175                { 
    20512176                    SetLastError(NTE_BAD_HASH); 
     
    20792204                hashLen = getHashSize(pHash->Algid); 
    20802205                /**   - If hash size < 0, bad hash.*/ 
    2081                 if(hashLen < 0) 
     2206                if(hashLen == 0) 
    20822207                { 
    20832208                    SetLastError(NTE_BAD_HASH); 
     
    22772402    OUT HCRYPTKEY *phKey) 
    22782403{ 
    2279     *phKey = (HCRYPTKEY)NULL;    // Replace NULL with your own structure. 
     2404    *phKey = (HCRYPTKEY)NULL;    /* Replace NULL with your own structure. */ 
    22802405    DEBUG(3,"_-_-_-_-_-_-_-_-_Importing key-_-_-_-_-_-_-_-_-\n"); 
    22812406    DEBUG(1, "ERROR: A not implemented function was called !!!\n"); 
     
    32493374        hashValLen = getHashSize(pHash->Algid); 
    32503375        /**   - If hash size < 0, bad hash.*/ 
    3251         if(hashValLen < 0) 
     3376        if(hashValLen == 0) 
    32523377        { 
    32533378            SetLastError(NTE_BAD_HASH); 
     
    32873412    OUT HCRYPTKEY *phKey) 
    32883413{ 
    3289     *phKey = (HCRYPTKEY)NULL;    // Replace NULL with your own structure. 
     3414    *phKey = (HCRYPTKEY)NULL;    /* Replace NULL with your own structure. */ 
    32903415    /** \todo code it.*/ 
    32913416    DEBUG(3,"_-_-_-_-_-_-_-_-_Duplicate key-_-_-_-_-_-_-_-_-\n"); 
     
    32983423 
    32993424/** \brief Return the wanted handler index in the granted handlers list.*/ 
    3300 int findGrantedHandle(HANDLE *grantedHandles, int max_len, HANDLE wantedHandle) 
     3425static int findGrantedHandle(HANDLE *grantedHandles, int max_len, HANDLE wantedHandle) 
    33013426{ 
    33023427    HANDLE *current;    /* Current handler index in the handlers list.*/ 
     
    33533478 
    33543479/** \brief Grants a handler.*/ 
    3355 BOOL grantHandle(HANDLE **grantedHandles, int *length, HANDLE handle) 
     3480static BOOL grantHandle(HANDLE **grantedHandles, int *length, HANDLE handle) 
    33563481{ 
    33573482    int index, i;  /* Position indexes in the handlers list.*/ 
     
    34223547         
    34233548    /** - If the context index is valid.*/ 
    3424     if (index>=0 && index<(*length)+1) 
     3549    if (index>=0 && index<=(*length)) 
    34253550    { 
    34263551        /**  - Fill the new list with the provided context.*/ 
     
    34533578 
    34543579/** \brief Revokes a granted cryptographic handler.*/ 
    3455 BOOL revokeHandle(HANDLE **grantedHandles, int *length, HANDLE handle) 
     3580static BOOL revokeHandle(HANDLE **grantedHandles, int *length, HANDLE handle) 
    34563581{ 
    34573582    int index, i;  /* Position indexes in the handlers list.*/ 
     
    35443669} 
    35453670 
    3546 BOOL grantedHandle(HANDLE *grantedHandles, int length, HANDLE handle) 
     3671static BOOL grantedHandle(HANDLE *grantedHandles, int length, HANDLE handle) 
    35473672{ 
    35483673    /** - If the wanted handle has a position index >=0, it has been granted.*/ 
     
    35573682} 
    35583683 
    3559 int getHashSize(ALG_ID Algid) 
     3684static DWORD getHashSize(ALG_ID Algid) 
    35603685{ 
    35613686    switch(Algid) 
     
    35863711            return 20+16; 
    35873712        default: 
    3588             /** - Everything else: -1.*/ 
    3589             return -1; 
     3713            /** - Everything else: 0.*/ 
     3714            return 0; 
    35903715    } 
    35913716} 
  • trunk/csp11/src/csp11.h

    r39 r99  
    6262 
    6363#ifndef _CSP11_H_ 
    64 #define UNICODE 
    6564#define _CSP11_H_       /**< csp11.h inclusion tag. */ 
    6665#ifdef __cplusplus 
     
    319318 */ 
    320319BOOL WINAPI 
    321 CPAcquireContext( 
     320CPAcquireContextW( 
    322321    OUT HCRYPTPROV *phProv, 
    323322    IN  LPCSTR szContainer, 
    324323    IN  DWORD dwFlags, 
    325     IN  PVTableProvStruc pVTable); 
     324    IN  PVTableProvStrucW pVTable); 
    326325 
    327326 
     
    14881487    OUT HCRYPTKEY *phKey); 
    14891488 
    1490  
    1491  
    1492 /** \brief Return the wanted handler index in the given granted handlers list. 
    1493  * 
    1494  *  \param grantedHandles   Pointer to the beginning of the granted handlers 
    1495  *                          tab. 
    1496  *  \param  max_len         The maximum lenth of the granted handlers list. 
    1497  *  \param wantedHandle    The wanted handler. 
    1498  * 
    1499  *  \return An integer from 0 to max_len-1 if a granted context is found. 
    1500  *          Negative value if not. 
    1501  *  \ingroup    SPInternal 
    1502  */ 
    1503 int findGrantedHandle(HANDLE *grantedHandles, int max_len, HANDLE wantedHandle); 
    1504  
    1505 /** \brief Grants a cryptographic handle. 
    1506  * 
    1507  *  Used to remember granted handlers. 
    1508  * 
    1509  *  \param  grantedHandles Pointer to the granted handler list pointer. 
    1510  *  \param  lenth   Pointer to the lenth of the list. 
    1511  *  \param  lenth Maximum authorized lenth of the list. 0 means unlimited. 
    1512  *  \param  handle  The handle to grant. 
    1513  * 
    1514  *  \return TRUE if everything went OK. 
    1515  *  \ingroup    SPInternal 
    1516  */ 
    1517 BOOL grantHandle(HANDLE **grantedHandles, int *lenth, 
    1518                   HANDLE handle); 
    1519  
    1520 /** \brief Revokes a granted cryptographic handle. 
    1521  * 
    1522  *  Used to forget a granted handle. 
    1523  * 
    1524  *  \param  handle   Handler to the provided context to forget. 
    1525  *  \param  lenth   Lenth of the granted handles list. 
    1526  *  \param  grantedHandles  Pointer to the granted handles list. 
    1527  * 
    1528  *  \return TRUE if everything went OK. 
    1529  *  \ingroup    SPInternal 
    1530  */ 
    1531 BOOL revokeHandle(HANDLE **grantedHandles, int *lenth, HANDLE handle); 
    1532  
    1533 /** \brief Check if a crypto handler was provided. 
    1534  * 
    1535  *  Check if the given handler is really a valid cryptographic context handler. 
    1536  * 
    1537  *  \param  lenth   Number of granted handles. 
    1538  *  \param  grantedHandles  Pointer to the granted handles list. 
    1539  *  \param  handle  Handle to check. 
    1540  * 
    1541  *  \return TRUE if the handler was granted by CSP-eleven, FALSE if not. 
    1542  *  \ingroup    SPInternal 
    1543  */ 
    1544 BOOL grantedHandle(HANDLE *grantedHandles, int lenth, HANDLE handle); 
    1545  
    1546 /** \brief Return the algId csp11 ALGORITHM. 
    1547  * 
    1548  *  Browse the algorithms table and get the wanted definition. 
    1549  *   
    1550  *  \param  algId   The wanted CAPI algorithm ID. 
    1551  *  \param  algorithm The corresponding ALGORITHM structure. 
    1552  * 
    1553  *  \return TRUE if algorithm found, FALSE if not. 
    1554  * 
    1555  *  \ingroup SPInternal 
    1556  */ 
    1557 BOOL getAlgorithm(ALG_ID algId, ALGORITHM *algorithm); 
    1558  
    1559 /** \brief Return size of produced hash value in bytes. 
    1560  *   
    1561  *  \warning The size is returned in BYTES. 
    1562  *   
    1563  *  \param Algid    Id of wanted algorithm size. 
    1564  * 
    1565  *  \return >0 integer if the id is supported, -1 if not. 
    1566  * 
    1567  *  \ingroup SPInternal 
    1568  */ 
    1569 int getHashSize(ALG_ID Algid); 
    1570  
    1571 /** \brief Initialise a key handler. 
    1572  *   
    1573  *  \param pProvCtx Pointer to the used crypto context. 
    1574  *  \param pKey Pointer to the handler to fill. 
    1575  *  \param algId Key algorithm CAPI ID. 
    1576  *  \return TRUE; 
    1577  * 
    1578  *  \ingroup SPInternal 
    1579  */ 
    1580 BOOL initKey(PROV_CTX *pProvCtx, KEY_INFO *pKey, ALG_ID algId); 
    1581  
    1582 /** \brief Reverse a byte string. 
    1583  *  
    1584  *  \param pBytes       Pointer to the bytes string. 
    1585  *  \param stringLen    Length of the bytes string. 
    1586  * 
    1587  *  \return TRUE if the bytes string was successfully reversed. 
    1588  *  \ingroup SPInternal 
    1589  *  \note Hey school boys, students or better, take a look ! 
    1590  *  Gambin gave us a teach: a very good algo to reverse bytes string. 
    1591  */ 
    1592 BOOL reverseBytesString(BYTE *pBytes, DWORD stringLen); 
    1593  
    1594 /** \brief Set hash algi and alg oid. 
    1595  * 
    1596  *  Set the hash algid and try to get the corresponding oid. 
    1597  *  If no oid found, bad alg id. 
    1598  *  \param  algId   The alg Id to set. 
    1599  *  \param  pHash    Pointer to the key information structure. 
    1600  *  \ingroup SPInternal 
    1601  * 
    1602  *  \return TRUE if algid and oid are set. 
    1603  */ 
    1604 BOOL setHashAlgId(ALG_ID algId, HASH_INFO *pHash); 
    1605  
    1606 /** \brief Set key algi and alg oid. 
    1607  * 
    1608  *  Set the key algid and try to get the corresponding oid. 
    1609  *  If no oid found, bad alg id. 
    1610  *  \param  algId   The alg Id to set. 
    1611  *  \param  pKey    Pointer to the key information structure. 
    1612  * 
    1613  *  \ingroup SPInternal 
    1614  *  \return TRUE if algid and oid are set. 
    1615  */ 
    1616 BOOL setKeyAlgId(ALG_ID algId, KEY_INFO *pKey); 
    1617  
    16181489#ifdef __cplusplus 
    16191490} 
    16201491#endif 
    1621 #endif // _CSP11_H_ 
    1622  
     1492#endif /* _CSP11_H_ */ 
     1493 
  • trunk/csp11/src/pkcs11-helpers.c

    r39 r99  
    3636 */ 
    3737 
    38 #ifndef WIN32_LEAN_AND_MEAN 
    39 #define WIN32_LEAN_AND_MEAN 
     38#ifdef HAVE_CONFIG_H 
     39#include <config.h> 
    4040#endif 
    41  
    42 #undef UNICODE             
    4341#include <stdio.h> 
    4442#include <windows.h> 
     
    4644#ifdef _MSC_VER 
    4745#include <cspdk.h> 
    48 #include "missdef.h" 
     46#include <missdef.h> 
    4947#else 
    50 #include "misscrypt.h" 
     48#include <misscrypt.h> 
    5149#endif 
    52 #include <rsaref/win32.h> 
    53 #include <rsaref/pkcs11.h> 
     50#include <pkcs11.h> 
    5451#include "pkcs11-helpers.h" 
    5552 
     
    112109        } 
    113110    } 
    114     return -1; 
     111    return 0; 
    115112} 
    116113 
  • trunk/csp11/src/pkcs11-helpers.h

    r39 r99  
    3939 
    4040#ifndef _PKCS11_HELPERS_H_ 
    41 #define UNICODE 
    4241#define _PKCS11_HELPERS_H_     /**< pkcs11_helpers.h inclusion tag. */ 
    4342 
  • trunk/csp11/src/pkcs11-services.c

    r60 r99  
    4141 */ 
    4242 
    43 #ifndef WIN32_LEAN_AND_MEAN 
    44 #define WIN32_LEAN_AND_MEAN 
     43#ifdef HAVE_CONFIG_H 
     44#include <config.h> 
    4545#endif 
    46  
    47 #undef UNICODE             
    4846#include <stdio.h> 
    4947#include <windows.h> 
     
    5250#ifdef _MSC_VER 
    5351#include <cspdk.h> 
    54 #include "missdef.h" 
     52#include <missdef.h> 
    5553#else 
    56 #include "misscrypt.h" 
     54#include <misscrypt.h> 
    5755#endif 
    58 #include <rsaref/win32.h> 
    59 #include <rsaref/pkcs11.h> 
     56#include <pkcs11.h> 
    6057#include "csp11.h" 
    6158#include "pkcs11-services.h" 
     
    7572 *  \return True if the object can decrypt. 
    7673 */ 
    77 PATTRIBUTE_FUNCTION_MACRO(DECRYPT, CK_BBOOL); 
     74PATTRIBUTE_FUNCTION_MACRO(DECRYPT, CK_BBOOL) 
    7875 
    7976/** \fn CK_BBOOL * getENCRYPT(CK_FUNCTION_LIST_PTR p11, PROV_CTX *pProvCtx, CK_OBJECT_HANDLE obj, CK_ULONG_PTR pulCount)  
     
    8582 *  \return True if the object can decrypt. 
    8683 */ 
    87 PATTRIBUTE_FUNCTION_MACRO(ENCRYPT, CK_BBOOL); 
     84PATTRIBUTE_FUNCTION_MACRO(ENCRYPT, CK_BBOOL) 
    8885 
    8986/** \fn CK_BBOOL * getEXTRACTABLE(CK_FUNCTION_LIST_PTR p11, PROV_CTX *pProvCtx, CK_OBJECT_HANDLE obj, CK_ULONG_PTR pulCount)  
     
    9592 *  \return True if the object is extractable. 
    9693 */ 
    97 PATTRIBUTE_FUNCTION_MACRO(EXTRACTABLE, CK_BBOOL); 
     94PATTRIBUTE_FUNCTION_MACRO(EXTRACTABLE, CK_BBOOL) 
    9895 
    9996/** \fn unsigned char * getID(CK_FUNCTION_LIST_PTR p11, PROV_CTX *pProvCtx, CK_OBJECT_HANDLE obj, CK_ULONG_PTR pulCount)  
     
    105102 *  \return The Object ID. 
    106103 */ 
    107 PATTRIBUTE_FUNCTION_MACRO(ID, unsigned char); 
     104PATTRIBUTE_FUNCTION_MACRO(ID, unsigned char) 
    108105 
    109106/** \fn CK_KEY_TYPE * getKEY_TYPE(CK_FUNCTION_LIST_PTR p11, PROV_CTX *pProvCtx,CK_OBJECT_HANDLE obj, CK_ULONG_PTR pulCount) 
     
    115112 *  \return The Object ID. 
    116113 */ 
    117 PATTRIBUTE_FUNCTION_MACRO(KEY_TYPE, CK_KEY_TYPE); 
     114PATTRIBUTE_FUNCTION_MACRO(KEY_TYPE, CK_KEY_TYPE) 
    118115 
    119116/** \fn CK_UTF8CHAR * getLABEL(CK_FUNCTION_LIST_PTR p11, PROV_CTX *pProvCtx, CK_OBJECT_HANDLE obj, CK_ULONG_PTR pulCount)   
     
    126123 *  \return the object label. 
    127124 */ 
    128 PATTRIBUTE_FUNCTION_MACRO(LABEL, CK_UTF8CHAR); 
     125PATTRIBUTE_FUNCTION_MACRO(LABEL, CK_UTF8CHAR) 
    129126 
    130127/** \fn unsigned char * getMODULUS(CK_FUNCTION_LIST_PTR p11, PROV_CTX *pProvCtx, CK_OBJECT_HANDLE obj, CK_ULONG_PTR pulCount)  
     
    136133 *  \return The Object modulus. 
    137134 */ 
    138 PATTRIBUTE_FUNCTION_MACRO(MODULUS, unsigned char); 
     135PATTRIBUTE_FUNCTION_MACRO(MODULUS, unsigned char) 
    139136 
    140137/** \fn CK_ULONG * getMODULUS_BITS(CK_FUNCTION_LIST_PTR p11, PROV_CTX *pProvCtx, CK_OBJECT_HANDLE obj, CK_ULONG_PTR pulCount)  
     
    146143 *  \return The Object modulus length. 
    147144 */ 
    148 PATTRIBUTE_FUNCTION_MACRO(MODULUS_BITS, CK_ULONG); 
     145PATTRIBUTE_FUNCTION_MACRO(MODULUS_BITS, CK_ULONG) 
    149146 
    150147/** \fn CK_BYTE * getPUBLIC_EXPONENT(CK_FUNCTION_LIST_PTR p11, PROV_CTX *pProvCtx, CK_OBJECT_HANDLE obj, CK_ULONG_PTR pulCount)   
     
    157154 *  \return the object public exponent. 
    158155 */ 
    159 PATTRIBUTE_FUNCTION_MACRO(PUBLIC_EXPONENT, CK_BYTE); 
     156PATTRIBUTE_FUNCTION_MACRO(PUBLIC_EXPONENT, CK_BYTE) 
    160157 
    161158/** \fn CK_BBOOL * getSIGN(CK_FUNCTION_LIST_PTR p11, PROV_CTX *pProvCtx, CK_OBJECT_HANDLE obj, CK_ULONG_PTR pulCount)   
     
    168165 *  \return the object label. 
    169166 */ 
    170 PATTRIBUTE_FUNCTION_MACRO(SIGN, CK_BBOOL); 
     167PATTRIBUTE_FUNCTION_MACRO(SIGN, CK_BBOOL) 
    171168 
    172169/** \fn CK_BYTE *getVALUE(CK_FUNCTION_LIST_PTR p11, PROV_CTX *pProvCtx, CK_OBJECT_HANDLE obj, CK_ULONG_PTR pulCount)  
     
    178175 *  \return The Object value. 
    179176 */ 
    180 PATTRIBUTE_FUNCTION_MACRO(VALUE, unsigned char); 
     177PATTRIBUTE_FUNCTION_MACRO(VALUE, unsigned char) 
    181178 
    182179BOOL keyObjectCanEncrypt(PROV_CTX *pProvCtx, CK_OBJECT_HANDLE hKey) 
     
    422419            /*hashLen = 
    423420             * getHashLenFromcIdentifier(containerInfo.sigKeyHashAlg);*/ 
    424             if(hashLen < 0) 
     421            if(hashLen == 0) 
    425422            { 
    426423                return FALSE; 
     
    562559            mechanism.mechanism = getMechFromcIdentifier(containerInfo.kxKeyHashAlg); 
    563560            /*hashLen = getHashLenFromcIdentifier(containerInfo.kxKeyHashAlg);*/ 
    564             if(hashLen < 0) 
     561            if(hashLen == 0) 
    565562            { 
    566563                return FALSE; 
     
    707704 
    708705    /** - Wrap Crosof Algid with PKCS #11 mechanism id.*/ 
    709     if(mechanism.mechanism<0) 
     706    if(mechanism.mechanism == (CK_MECHANISM_TYPE)-1) 
    710707    { 
    711708        return FALSE; 
     
    810807    hServiceInfo = pProvCtx->container.hServiceInformation; 
    811808    /** - Fill structure info.*/ 
    812     //pSigKey->signPrivateKey = privateKey; 
     809    /*pSigKey->signPrivateKey = privateKey;*/ 
    813810    pKeyInfo->hKey = publicKey; 
    814811     
     
    846843    memset(pPubExp,0, sizeof(DWORD)); 
    847844    memcpy(pPubExp, pPublicExponent, 3); 
    848     //*pPubExp = (*pPubExp)>>8; 
     845    /* *pPubExp = (*pPubExp)>>8; */ 
    849846    HeapFree(pProvCtx->heap, 0, pPublicExponent); 
    850847    return TRUE; 
     
    975972    } 
    976973     
    977     //rv = p11->C_WrapKey(hServiceInfo->hSession, ); 
     974    /*rv = p11->C_WrapKey(hServiceInfo->hSession, );*/ 
    978975     
    979976    return FALSE; 
     
    991988                   HANDLE *phKeyInformation, ALG_ID algId) 
    992989{ 
    993     CK_OBJECT_HANDLE *phPublicKey; /* Pointer to PKCS #11 Handle to the public key object.*/ 
    994     CK_OBJECT_HANDLE *phPrivateKey; /* Pointer to PKCS #11 Handle to the private key object. 
     990    CK_OBJECT_HANDLE hPublicKey; /* Pointer to PKCS #11 Handle to the public key object.*/ 
     991    CK_OBJECT_HANDLE hPrivateKey; /* Pointer to PKCS #11 Handle to the private key object. 
    995992                                      */ 
    996993    PKCS11_KEY_INFO  *pKeyInformation=NULL; /* PKCS11 key information.*/ 
     
    10091006    } 
    10101007    /** - Call service specific key pair generation function.*/ 
    1011     if(PKCS11_genKeyPair(pProvCtx, modulusBits, phPrivateKey, phPublicKey)) 
     1008    if(PKCS11_genKeyPair(pProvCtx, modulusBits, &hPrivateKey, &hPublicKey)) 
    10121009    { 
    10131010        /**  - Allocate memory for pkcs11 key information structure.*/ 
     
    10201017        } 
    10211018        /**  - Fill key structure.*/ 
    1022         if(!fillP11Key(pProvCtx, *phPublicKey, pKeyInformation)) 
     1019        if(!fillP11Key(pProvCtx, hPublicKey, pKeyInformation)) 
    10231020        { 
    10241021            SetLastError(NTE_FAIL); 
     
    10661063    PKCS11_SERVICE_INFO    *hServiceInfo = NULL;  /* Pointer to the key container structure. */ 
    10671064    CK_MECHANISM    mechanism = { 
    1068         //CKM_RSA_X9_31, NULL, 0 };  /* Mechanism used in order to simple sign.*/ 
    1069         //CKM_RSA_PKCS_PSS, NULL, 0 };  /* Mechanism used in order to simple sign.*/ 
    1070         //CKM_RSA_9796, NULL, 0 };  /* Mechanism used in order to simple sign.*/ 
     1065#if 0 
     1066        CKM_RSA_X9_31, NULL, 0 };  /* Mechanism used in order to simple sign.*/ 
     1067        CKM_RSA_PKCS_PSS, NULL, 0 };  /* Mechanism used in order to simple sign.*/ 
     1068        CKM_RSA_9796, NULL, 0 };  /* Mechanism used in order to simple sign.*/ 
     1069#endif 
    10711070        CKM_RSA_PKCS, NULL, 0 };  /* Mechanism used in order to simple sign.*/ 
    1072         //CKM_RSA_X_509, NULL, 0 };  /* Mechanism used in order to simple sign.*/ 
     1071#if 0 
     1072        CKM_RSA_X_509, NULL, 0 };  /* Mechanism used in order to simple sign.*/ 
     1073#endif 
    10731074    char debug[100]; 
    10741075 
     
    17031704            return FALSE; 
    17041705        } 
    1705          
    1706         if(valueLenth<0) 
     1706 
     1707#if 0 
     1708        if(valueLenth < 0) 
    17071709        { 
    17081710            return FALSE; 
    17091711        } 
    1710          
     1712#endif 
    17111713    } 
    17121714    /** - If objectValue is not NULL, this is the final call.*/ 
     
    20682070    { 
    20692071        hashLen = getHashLenFromcIdentifier(containerInfo->sigKeyHashAlg); 
    2070         if(hashLen < 0) 
     2072        if(hashLen == 0) 
    20712073        { 
    20722074            return FALSE; 
     
    21382140    { 
    21392141        hashLen = getHashLenFromcIdentifier(containerInfo->kxKeyHashAlg); 
    2140         if(hashLen < 0) 
     2142        if(hashLen == 0) 
    21412143        { 
    21422144            return FALSE; 
     
    24182420            modulus = getMODULUS(p11, pProvCtx, hPublicKey, &idsNumber); 
    24192421            mechanism.mechanism = getMechFromcIdentifier(cIdentifier); 
    2420             if(mechanism.mechanism < 0) 
     2422            if(mechanism.mechanism == (CK_MECHANISM_TYPE)-1) 
    24212423            { 
    24222424                return FALSE; 
     
    25932595    char debug[100]; 
    25942596     
    2595     char * dllName = "opensc-pkcs11.dll"; 
     2597    WCHAR * dllName = L"opensc-pkcs11.dll"; 
    25962598 
    25972599    /** - Set cryptoki initialization arguments.*/ 
     
    27832785                                                            /* attribute*/ 
    27842786    /** - Set up ID attribute template.*/ 
    2785     //template[0].type = CKA_CLASS; 
    2786     //objectClass = CKO_PRIVATE_KEY; 
    2787     //template[0].pValue = &objectClass; 
    2788     //template[0].ulValueLen = 0; 
    2789     //template[0].ulValueLen = sizeof(objectClass);   /*We want a public key 
    2790     /*                                                  class object.*/  
     2787#if 0 
     2788    template[0].type = CKA_CLASS; 
     2789    objectClass = CKO_PRIVATE_KEY; 
     2790    template[0].pValue = &objectClass; 
     2791    template[0].ulValueLen = 0; 
     2792    template[0].ulValueLen = sizeof(objectClass);   /*We want a public key 
     2793                                                    class object.*/  
     2794#endif 
    27912795    /** \todo Filter key to sign. */ 
    27922796    template[1].type = CKA_SIGN; 
     
    27952799    /** - Initiate signature key research.*/ 
    27962800    rv = p11->C_FindObjectsInit(hServiceInfo->hSession, template, 2);  
    2797     //rv = p11->C_FindObjectsInit(hServiceInfo->hSession, template, 1);  
     2801    /*rv = p11->C_FindObjectsInit(hServiceInfo->hSession, template, 1); */ 
    27982802    if (rv != CKR_OK) 
    27992803    { 
     
    28422846    CK_SLOT_ID slotId = NO_SLOT; /* The selected slot Id. */ 
    28432847    PKCS11_SERVICE_INFO    *hServiceInfo = NULL;  /* Pointer to the key container structure. */ 
    2844     // char             *pin = NULL;    /* Local pointer on the pin string. */ 
    2845     //char              *pin = "1234";    /* Local pointer on the pin string 
    2846                                             //For testing purpose: 1234. */ 
     2848#if 0 
     2849    char                *pin = NULL;    /* Local pointer on the pin string. */ 
     2850    char                *pin = "1234";    /* Local pointer on the pin string 
     2851                                            For testing purpose: 1234. */ 
     2852#endif 
    28472853     
    28482854    hServiceInfo = pProvCtx->container.hServiceInformation; 
     
    28922898    CK_OBJECT_HANDLE     signatureKey; /* Pointer to the key used to sign.*/ 
    28932899    CK_MECHANISM    mechanism = { 
    2894         //CKM_RSA_X9_31, NULL, 0 };  /* Mechanism used in order to simple sign.*/ 
    2895         //CKM_RSA_PKCS_PSS, NULL, 0 };  /* Mechanism used in order to simple sign.*/ 
    2896         //CKM_RSA_9796, NULL, 0 };  /* Mechanism used in order to simple sign.*/ 
     2900#if 0 
     2901        CKM_RSA_X9_31, NULL, 0 };  /* Mechanism used in order to simple sign.*/ 
     2902        CKM_RSA_PKCS_PSS, NULL, 0 };  /* Mechanism used in order to simple sign.*/ 
     2903        CKM_RSA_9796, NULL, 0 };  /* Mechanism used in order to simple sign.*/ 
     2904#endif 
    28972905        CKM_RSA_PKCS, NULL, 0 };  /* Mechanism used in order to simple sign.*/ 
    2898         //CKM_RSA_X_509, NULL, 0 };  /* Mechanism used in order to simple sign.*/ 
     2906#if 0 
     2907        CKM_RSA_X_509, NULL, 0 };  /* Mechanism used in order to simple sign.*/ 
     2908#endif 
    28992909    char debug[100]; 
    29002910     
  • trunk/csp11/src/pkcs11-services.h

    r39 r99  
    5151 
    5252#ifndef _PKCS11_SERVICES_H_ 
    53 #define UNICODE 
    5453#define _PKCS11_SERVICES_H_     /**< pkcs11_services.h inclusion tag. */ 
    5554 
     
    799798BOOL validateKeySigPin(PROV_CTX provCtx, char *pin); 
    800799 
    801 #endif // _PKCS11_SERVICES_H_ 
    802  
     800#endif /* _PKCS11_SERVICES_H_ */ 
     801 
  • trunk/csp11/src/resource.h

    r39 r99  
     1/* 
    12//{{NO_DEPENDENCIES}} 
    23// Microsoft Developer Studio generated include file. 
    34// Used by csp11.rc 
    45// 
     6*/ 
    57#define IDS_CHV                         1 
    68#define IDS_CHV_PROMPT                  2 
     
    4345#define IDC_STATIC                      -1 
    4446 
     47/* 
    4548// Next default values for new objects 
    46 //  
     49// 
     50*/ 
    4751#ifdef APSTUDIO_INVOKED 
    4852#ifndef APSTUDIO_READONLY_SYMBOLS 
  • trunk/csp11/src/ui-pin.c

    r39 r99  
    2727 */ 
    2828 
     29#ifdef HAVE_CONFIG_H 
     30#include <config.h> 
     31#endif 
    2932#include <stdio.h> 
    3033#include <stdlib.h> 
     
    6568    wc.lpfnWndProc = DefWindowProc; 
    6669    wc.hInstance = csp11hInstance; 
    67     wc.lpszClassName = "csp11GUI"; 
    68     wc.lpszMenuName = "MMenu"; 
     70    wc.lpszClassName = L"csp11GUI"; 
     71    wc.lpszMenuName = L"MMenu"; 
    6972    wc.hbrBackground = (HBRUSH)( COLOR_WINDOW + 1 ); 
    7073    wc.hIcon = NULL; /*LoadIcon( hInstance, MAKEINTRESOURCE( 100 ) );*/ 
     
    8386    /**  - Create the main window.*/ 
    8487    cspHWnd = CreateWindowEx(WS_EX_APPWINDOW | WS_EX_TOPMOST, 
    85                              "csp11GUI",  
    86                              "CSP #11 Graphical User Interface", 
     88                             L"csp11GUI",  
     89                             L"CSP #11 Graphical User Interface", 
    8790                             WS_MINIMIZEBOX | 
    8891                             WS_SIZEBOX | 
     
    117120        /**  - Dialog box initialization:*/ 
    118121        case WM_INITDIALOG: 
    119         {                                     //  Save string pointer passed here 
     122        {                                     /*  Save string pointer passed here */ 
    120123            SETPOINTER( hDlg, lParam ); 
    121124 
    122             if( lstrlen( (LPSTR)lParam ) )       //  If something is in the string 
    123                 SetWindowText( GetDlgItem( hDlg, 100 ),         //  put it into the 
    124                         (LPSTR)lParam );                //  edit control now 
     125            if( lstrlen( (LPWSTR)lParam ) )       /*  If something is in the string */ 
     126                SetWindowText( GetDlgItem( hDlg, 100 ),         /*  put it into the */ 
     127                        (LPWSTR)lParam );                /*  edit control now */ 
    125128            SetFocus(hDlg); 
    126129            LoadString(csp11hInstance, IDS_CHV_PROMPT, message, 
     
    138141 
    139142    case WM_COMMAND: 
    140         if( wParam == IDCANCEL )                //  If Cancel is pressed, quit 
     143        if( wParam == IDCANCEL )                /*  If Cancel is pressed, quit */ 
    141144        { 
    142145            KILLPOINTER( hDlg ); 
    143146 
    144             EndDialog( hDlg, FALSE );  //  Cause DialogBoxParam to return FALSE 
     147            EndDialog( hDlg, FALSE );  /*  Cause DialogBoxParam to return FALSE */ 
    145148            return( TRUE ); 
    146149        } 
    147150        if( wParam == IDOK ) 
    148151            { 
    149                 char szStr[ 128 ]; 
    150                 if( ! GetDlgItemText( hDlg, 100, szStr, 128 ) )   //  If nothing in 
    151                 break;                                //  the edit control, quit 
    152                //  Copy from here to pointer passed to WM_INITDIALOG 
    153                lstrcpy( (CHAR *)GETPOINTER( hDlg ), szStr ); 
     152                WCHAR wszStr[ 128 ]; 
     153                if( ! GetDlgItemText( hDlg, 100, wszStr, 128 ) )   /* If nothing in */ 
     154                break;                                /*  the edit control, quit */ 
     155               /* Copy from here to pointer passed to WM_INITDIALOG */ 
     156               lstrcpy( (WCHAR *)GETPOINTER( hDlg ), wszStr ); 
    154157               KILLPOINTER( hDlg ); 
    155158 
    156                EndDialog( hDlg, TRUE );    //  Cause DialogBoxParam to return TRUE 
     159               EndDialog( hDlg, TRUE );    /*  Cause DialogBoxParam to return TRUE */ 
    157160               return( TRUE ); 
    158161            } 
     
    172175        /**  - Dialog box initialization:*/ 
    173176        case WM_INITDIALOG: 
    174         {                                     //  Save string pointer passed here 
     177        {                                     /*  Save string pointer passed here */ 
    175178            SetFocus(hDlg); 
    176179            LoadString(csp11hInstance, IDS_BAD_PIN_MSG, message, 
     
    184187 
    185188    case WM_COMMAND: 
    186         if( wParam == IDOK )                //  If Cancel is pressed, quit 
     189        if( wParam == IDOK )                /*  If Cancel is pressed, quit */ 
    187190        { 
    188191            KILLPOINTER( hDlg ); 
    189192 
    190             EndDialog( hDlg, TRUE );  //  Cause DialogBoxParam to return FALSE 
     193            EndDialog( hDlg, TRUE );  /* Cause DialogBoxParam to return FALSE */ 
    191194            return( TRUE ); 
    192195        } 
     
    205208        /**  - Dialog box initialization:*/ 
    206209        case WM_INITDIALOG: 
    207         {                                     //  Save string pointer passed here 
     210        {                                     /*  Save string pointer passed here */ 
    208211            SetFocus(hDlg); 
    209212            LoadString(csp11hInstance, IDS_INVALID_PIN_MSG, message, 
     
    217220 
    218221    case WM_COMMAND: 
    219         if( wParam == IDOK )                //  If Cancel is pressed, quit 
     222        if( wParam == IDOK )                /*  If Cancel is pressed, quit */ 
    220223        { 
    221224            KILLPOINTER( hDlg ); 
    222225 
    223             EndDialog( hDlg, TRUE );  //  Cause DialogBoxParam to return FALSE 
     226            EndDialog( hDlg, TRUE );  /*  Cause DialogBoxParam to return FALSE */ 
    224227            return( TRUE ); 
    225228        } 
     
    237240        /**  - Dialog box initialization:*/ 
    238241        case WM_INITDIALOG: 
    239         {                                     //  Save string pointer passed here 
     242        {                                     /*  Save string pointer passed here */ 
    240243            SetFocus(hDlg); 
    241244            LoadString(csp11hInstance, IDS_PIN_LOCKED_MSG, message, 
     
    249252 
    250253    case WM_COMMAND: 
    251         if( wParam == IDCANCEL )                //  If Cancel is pressed, quit 
     254        if( wParam == IDCANCEL )                /* If Cancel is pressed, quit */ 
    252255        { 
    253256            KILLPOINTER( hDlg ); 
    254257 
    255             EndDialog( hDlg, FALSE );  //  Cause DialogBoxParam to return FALSE 
     258            EndDialog( hDlg, FALSE );  /*  Cause DialogBoxParam to return FALSE */ 
    256259            return( TRUE ); 
    257260        } 
    258261        if( wParam == ID_MB_UNLOCK ) 
    259262            { 
    260                EndDialog( hDlg, TRUE );    //  Cause DialogBoxParam to return TRUE 
     263               EndDialog( hDlg, TRUE );    /*  Cause DialogBoxParam to return TRUE */ 
    261264               return( TRUE ); 
    262265            } 
     
    277280        /**  - Dialog box initialization:*/ 
    278281        case WM_INITDIALOG: 
    279         {                                     //  Save string pointer passed here 
     282        {                                     /*  Save string pointer passed here */ 
    280283            SetFocus(hDlg); 
    281284            LoadString(csp11hInstance, IDS_WRONG_CARD_MSG, message, 
     
    292295 
    293296    case WM_COMMAND: 
    294         if( wParam == IDCANCEL )                //  If Cancel is pressed, quit 
     297        if( wParam == IDCANCEL )                /*  If Cancel is pressed, quit */ 
    295298        { 
    296299            KILLPOINTER( hDlg ); 
    297300 
    298             EndDialog( hDlg, FALSE );  //  Cause DialogBoxParam to return FALSE 
     301            EndDialog( hDlg, FALSE );  /*  Cause DialogBoxParam to return FALSE */ 
    299302            return( TRUE ); 
    300303        } 
    301304        if( wParam == IDRETRY ) 
    302305            { 
    303                EndDialog( hDlg, TRUE );    //  Cause DialogBoxParam to return TRUE 
     306               EndDialog( hDlg, TRUE );    /*  Cause DialogBoxParam to return TRUE */ 
    304307               return( TRUE ); 
    305308            } 
     
    312315{ 
    313316    int validPIN = 0; /* If a validpin is found.*/ 
    314     char szText[9]; 
     317    WCHAR wszText[9]; 
    315318    int i;  /* iterator*/ 
    316319    BOOL badPin; 
    317320 
    318     lstrcpy(szText, ""); 
     321    lstrcpy(wszText, L""); 
    319322     
    320323    if(csp11hInstance == NULL) 
     
    346349        badPin = FALSE; 
    347350        if(DialogBoxParam(csp11hInstance, MAKEINTRESOURCE( 10000 ), *pHWnd, 
    348                                 InputDlgProc, (LPARAM)(LPSTR)szText ) ) 
     351                                InputDlgProc, (LPARAM)wszText ) ) 
    349352        { 
    350353                
    351             if((lstrlen(szText)>8) || !lstrlen(szText) || (lstrlen(szText)<4)) 
     354            if((lstrlen(wszText)>8) || !lstrlen(wszText) || (lstrlen(wszText)<4)) 
    352355            { 
    353356                badPin = TRUE; 
    354357            } 
    355             for(i=0; i<lstrlen(szText);i++) 
    356             { 
    357                 if((szText[i]>'9') || (szText[i]<'0')) 
     358            for(i=0; i<lstrlen(wszText);i++) 
     359            { 
     360                if((wszText[i]>L'9') || (wszText[i]<L'0')) 
    358361                { 
    359362                    badPin = TRUE; 
     
    366369            else 
    367370            { 
    368                 strncpy(pin, szText, 8); 
     371                int i; 
     372                for (i=0;i<8;i++) { 
     373                        pin[i] = '0' + (wszText[i] - L'0'); 
     374                } 
    369375                return TRUE; 
    370376            } 
  • trunk/csp11/tests

    • Property svn:ignore set to
      Makefile
      Makefile.in
      core
      archive
      acinclude.m4
      aclocal.m4
      autom4te.cache
      compile
      confdefs.h
      config.*
      configure
      conftest
      conftest.c
      depcomp
      install-sh
      libtool
      libtool.m4
      ltmain.sh
      missing
      mkinstalldirs
      so_locations
      stamp-h*

      .deps
      .libs
      .#*#
      .*.bak
      .*.orig
      .*.rej
      .*~
      #*#
      *.bak
      *.d
      *.def
      *.dll
      *.exe
      *.la
      *.lib
      *.lo
      *.orig
      *.pdb
      *.rej
      *.u
      *.rc
      *.pc
      *~
      *.gz
      *.bz2
      *.[0-9]
      *.html
      *.gif
      *.css
      *.out
  • trunk/csp11/tests/Makefile.mak

    r39 r99  
    11CSPDK_INC = ..\..\CSPDK\SDKINC 
    2 COPTS = /Zi /MD /nologo /D_WIN32_WINNT=0x0400 /I$(CSPDK_INC) 
     2COPTS = /Zi /MD /nologo /D_WIN32_WINNT=0x0400 /I$(CSPDK_INC) /I../include 
    33LINKFLAGS = /DEBUG /NOLOGO /INCREMENTAL:NO /MACHINE:IX86 
    44LIBS= user32.lib gdi32.lib advapi32.lib 
  • trunk/csp11/tests/cspTests.c

    r39 r99  
    3939#ifdef _MSC_VER 
    4040#include <cspdk.h> 
     41#else 
     42#include <misscrypt.h> 
    4143#endif 
    4244 
  • trunk/csp11/utils

    • Property svn:ignore set to
      Makefile
      Makefile.in
      core
      archive
      acinclude.m4
      aclocal.m4
      autom4te.cache
      compile
      confdefs.h
      config.*
      configure
      conftest
      conftest.c
      depcomp
      install-sh
      libtool
      libtool.m4
      ltmain.sh
      missing
      mkinstalldirs
      so_locations
      stamp-h*

      .deps
      .libs
      .#*#
      .*.bak
      .*.orig
      .*.rej
      .*~
      #*#
      *.bak
      *.d
      *.def
      *.dll
      *.exe
      *.la
      *.lib
      *.lo
      *.orig
      *.pdb
      *.rej
      *.u
      *.rc
      *.pc
      *~
      *.gz
      *.bz2
      *.[0-9]
      *.html
      *.gif
      *.css
      *.out
  • trunk/csp11/utils/Makefile.mak

    r39 r99  
    11CSPDK_INC = ..\..\CSPDK\SDKINC 
    2 COPTS = /Zi /MD /nologo /D_WIN32_WINNT=0x0400 /I$(CSPDK_INC) 
     2COPTS = /Zi /MD /nologo /D_WIN32_WINNT=0x0400 /I$(CSPDK_INC) /I../include 
    33LINKFLAGS = /DEBUG /NOLOGO /INCREMENTAL:NO /MACHINE:IX86 
    44LIBS= crypt32.lib 
  • trunk/csp11/utils/myCerts.c

    r39 r99  
    4040#include <windows.h> 
    4141#include <wincrypt.h> 
     42#ifndef _MSC_VER 
     43#include <misscrypt.h> 
     44#endif 
    4245 
    4346#define ENTRYPOINT APIENTRY /**< define the WinMain type.*/ 
Note: See TracChangeset for help on using the changeset viewer.