[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ms-cryptoapi
Subject:    Re: Implementing custom CSP on top of an existing Microsoft CSP
From:       Michael Virgil <mvirgil () NORTELNETWORKS ! COM>
Date:       2002-09-26 19:31:44
[Download RAW message or body]


Great, thanks a lot, that helps!

Thanks again,
Michael


-----Original Message-----
From: Laszlo Elteto [mailto:lelteto@RAINBOW.COM]
Sent: Thursday, September 26, 2002 3:15 PM
To: CryptoAPI@DISCUSS.MICROSOFT.COM
Subject: Re: Implementing custom CSP on top of an existing Microsoft CSP


It works as Rainbow has such an implementation. I also wrote a "logging" CSP
which simply calls down to the MS CSP and logs all in-out parameters to a
file. (Of course, it is dangerous as all data encryption showed. This was
only for testing - to see what call sequences with what parameters certain
applications were using the CSP.) Unfortunately, the code is Rainbow's
proprietary and we cannot share. However, I can tell you how you can easily
write one: 1. In your DllStart load the CSP you want to call "down". 2. With
GetProcAddress get all function's address in that CSP. 3. Write dummy
routines for each CSP function where you can simply call down to the other
CSP. Here is a sample:

in mycsp.c:

BOOL  WINAPI DllMain(HINSTANCE hInst, DWORD ul_reason_being_called, LPVOID
lpReserved)
{
    if (ul_reason_being_called == DLL_PROCESS_ATTACH )
    {
       // load external CSP dll
       R_EXT_Init();
       DisableThreadLibraryCalls(hInst);
    }
    return TRUE;
}

BOOL WINAPI CPAcquireContext(OUT HCRYPTPROV *phProv,
                             OUT CHAR *pszIdentity,
                             IN DWORD dwFlags,
                             IN PVTableProvStruc pVTable)
{
    return R_EXT_CPAcquireContext(phProv, pszIdentity,dwFlags,pVTable); }

in ext.c:

typedef BOOL (WINAPI *PF_CPAcquireContext) HCRYPTPROV *phProv, CHAR
*pszIdentity, DWORD dwFlags, PVTableProvStruc pVTable);

HINSTANCE m$dll;
PF_CPAcquireContext pf_CPAcquireContext = NULL;
:

#define GET_EXTERNAL_FUN(name)        \
    pf_##name = (PF_##name)GetProcAddress(m$dll, #name);   \
    if (! pf_##name)                   \
       return FALSE;

#define CALL_EXTERNAL_DLL(name)        \
    if (pf_##name)                      \
       rc = pf_##name

BOOL R_EXT_Init(void)
{
    m$dll = LoadLibrary(cspName);
    if (!m$dll)
       return FALSE;
    GET_EXTERNAL_FUN(CPAcquireContext);
    :
    return TRUE;
}

BOOL R_EXT_CPAcquireContext(OUT HCRYPTPROV *phProv,
                            OUT CHAR *pszIdentity,
                            IN DWORD dwFlags,
                            IN PVTableProvStruc pVTable)
{
    BOOL rc = CRYPT_FAILED;

    CALL_EXTERNAL_DLL(CPAcquireContext)(phProv,pszIdentity,
dwFlags,pVTable);

    return rc;
}

Hope this helps...

Laszlo Elteto
Fellow Scientist
Rainbow Technologies, Inc.

-----Original Message-----
From: Michael Virgil [mailto:mvirgil@NORTELNETWORKS.COM]
Sent: Thursday, September 26, 2002 11:39 AM
To: CryptoAPI@DISCUSS.MICROSOFT.COM
Subject: Implementing custom CSP on top of an existing Microsoft CSP


Hi folks,

I found a note in the Crypto-API archives with the subject: "Implementing
custom CSP on top of an existing Microsoft CSP". The reply stated that it
works.

Would anyone have a reference implementation of a "pass-thru" CSP? If this
works as advertised, I could just use almost all of the existing Microsoft
CSP entry points as is, use my own cert store location, and "plug-in" to all
the provided infrastructure and tools. Life would be good!

Any help would be appreciated.

Thanks,
Michael

----------------------------------------------------------------
Users Guide http://discuss.microsoft.com/archives/mailfaq.asp
contains important info. Save time, search the archives at
http://discuss.microsoft.com/archives/index.html . To unsubscribe,
mailto:CryptoAPI-signoff-request@DISCUSS.MICROSOFT.COM

----------------------------------------------------------------
Users Guide http://discuss.microsoft.com/archives/mailfaq.asp
contains important info. Save time, search the archives at
http://discuss.microsoft.com/archives/index.html . To unsubscribe,
mailto:CryptoAPI-signoff-request@DISCUSS.MICROSOFT.COM

----------------------------------------------------------------
Users Guide http://discuss.microsoft.com/archives/mailfaq.asp
contains important info. Save time, search the archives at
http://discuss.microsoft.com/archives/index.html .
To unsubscribe, mailto:CryptoAPI-signoff-request@DISCUSS.MICROSOFT.COM

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic