Re: CSP error

From: lelteto (lelteto_at_discussions.microsoft.com)
Date: 10/20/05


Date: Thu, 20 Oct 2005 12:31:06 -0700

Yes, thats' correct. You get the dll name from the Registry
(Cryptography\Defaults - unless you want to just "assume" rsaenh.dll is what
you want to use), use LoadLibrary then GetProcAddress to get all the CP...
functions. You should do thi sin your DllMain.
Then for each of YOUR CP... function (including the very first
CPAcquireContext) you call down the corresponding CP... function in the
loaded Microsoft provider.

One cautionary note:
This behavior have some security risks because you load a potentially
"unknown" CSP which may or may not signed by Microsoft. The CryptoAPI takes
care of signature checking for the CSPs it loads. Now if you want to be a
good security citizen than you SHOULD check the signature of the CSP you are
loading. (If you always want to load the standard Microsoft DLLs than you can
skip the trouble checking if Kernel mode debugger loaded - the MS CSPs must
always be signed anyway.)

Laszlo Elteto
SafeNet, Inc.

"bender" wrote:

> ahh, i really like that idea. It makes more sense anyways, since the way I
> am trying to do it is to call back to the Crypto level which is not a very
> nice design since I start to "bounce" around between levels. So if I
> understand what you are saying, I should load the crypto DLL of my choosing,
> then call it directly using the CP.... functions?
>
> "lelteto" wrote:
>
> > Actually, your CSP is called by the CryptoAPI level, so I don't think that's
> > the problem. Sorry my previous post on that part. I still think you should
> > create your own context.
> > Note that I don't have much experience calling Crypt... functions from my
> > CSP. Instead, what I always did was to load and call the Microsoft CSP layer
> > (ie. the CP... functions). That always worked for me.
> >
> > Laszlo Elteto
> > SafeNet, Inc.
> >
> > "bender" wrote:
> >
> > >
> > > "lelteto" wrote:
> > >
> > > > You should check why the CALLER sets the (I think bad) phProv value. The
> > > > error may not be in your code but the test code in its CryptAcquireContext.
> > > >
> > >
> > > The test code is a .exe file distributed by Microsoft in the CSPDK. I cant
> > > see what the code is doing (without reverse engineering which seems like more
> > > work than it is worth). I would think an error like this would have been
> > > caught by someone else in their use by now....



Relevant Pages

  • RE: Debugging a CSP dll
    ... you are registring your CSP the right way. ... it's not sufficient for winlogon to load it. ... Actually, by default, Winlogon ... dll unless it appears as a PC/SC reader to the system, ...
    (microsoft.public.platformsdk.security)
  • RE: MSCAPI integrity checks of CSPs - Downgrade Attack
    ... One thing you can do is to go to the Registry, ... the CSP dll file name from the crypto provider entry the VERIFY the dll ... the advapi32.dll file to completely bypass CSP signature check so can install ... I configure certificate server templates or xenroll to only issue ...
    (microsoft.public.platformsdk.security)
  • RE: Debugging a CSP dll
    ... Just for testing I changed the default CSP to my CSP and now it loads ... What I want to do with the HSM is actually not logon. ... it's not sufficient for winlogon to load it. ... load the Microsoft Gina dll that supports only smart cards as an additional ...
    (microsoft.public.platformsdk.security)
  • Re: CSP types
    ... You can write one dll and expose/register it via different types of CSPs. ... > I can write one CSP and one DLL and declare my self as supporting a few> CSP ... >> So on Windows 95 and Windows NT 4.0, there's a one-to-one mapping between>> CSPs and DLLs. ... one DLL can support any number of CSPs and>> types. ...
    (microsoft.public.platformsdk.security)
  • Re: CSP types
    ... You'll probably end up using the same entry points within ... specific to the CSP selected, as most of the code will be the same for all ... Note that each CSP supported by the DLL must have a separate unique name. ... >> On Windows 98, one DLL can support multiple CSPs, as long as each CSP is ...
    (microsoft.public.platformsdk.security)