Re: CryptAcquireContext fails with no error number - only after reboot

From: Ali M (alibiz_at_aliandclaire.com)
Date: 03/24/05

  • Next message: rox.scott: "Authenticode for VBA in MSIE"
    Date: Thu, 24 Mar 2005 14:35:04 -0800
    
    

    Hi Laszlo,

    Yes I checked all of those and they are ok.
    Something else I tried today:
            I modified the code to use no container (empty name) with the
    CRYPT_VERIFYCONTEXT flag so that a in-memory-only container is created
    and that seems to work just fine. So, only when I attempt to create a
    physical (on-disk) container do I experience the problem.

    I don't know if this helps diagnose this issue at all...

    Thanks
    Ali

    On Thu, 24 Mar 2005 09:47:01 -0800, "lelteto"
    <lelteto@discussions.microsoft.com> wrote:

    >Did you manually check the Registry keys
    > HKLM\SOFTWARE\Microsoft\Cryptography\Defaults\Provider
    > HKLM\SOFTWARE\Microsoft\Cryptography\Defaults\Provider Types
    >to see if the MS Enhanced provider and Type 001 are correct?
    >Did you check that the rsaenh.dll file is O.K? (copy and compare with one on
    >another system) Maybe try to specify the FULL PATH for the MS Enhanced
    >provider (not just "rsaenh.dll" for the "Image Path" value but eg.
    >"c:\windows\system32\rsaenh.dll")
    >These are just possible explanations. If they are fine I don't know what the
    >problem might be...
    >
    >Laszlo Elteto
    >SafeNet, Inc.
    >
    >"Ali M" wrote:
    >
    >> Hi, I am running into a problem with Crypt API calls in my code at a
    >> customer's computer. Please note that the following has been working
    >> for the past two years at all of my customers with different client
    >> OSs including XP. This is the first time I run into this issue...
    >>
    >> The code needs to acquire a context and encrypt/decrypt string using
    >> passwords. The call to CryptAcquireContext fails returning 0 no
    >> matter what flags I pass. Note that I call GetLastError() right after
    >> CryptAcquireContext call the returned error number is also 0. I call
    >> CryptAcquireContext twice, first with the CRYPT_DELETEKEYSET flag and
    >> then with the CRYPT_NEWKEYSET flag. Both calls fail with the error
    >> number 0. Here is the code:
    >>
    >> sCSP = "Microsoft Enhanced Cryptographic Provider v1.0" & vbNullChar
    >> sContainer = "MyContainer"
    >>
    >> lRet = CryptAcquireContext(hCryptProv, sContainer, sCSP, _
    >> PROV_RSA_FULL, CRYPT_DELETEKEYSET)
    >> lErr = GetLastError()
    >> '// Both lRet and lErr are always 0 (zero)
    >> lRet = CryptAcquireContext(hCryptProv, sContainer, sCSP, _
    >> PROV_RSA_FULL, CRYPT_NEWKEYSET)
    >> lErr = GetLastError()
    >> '// Both lRet and lErr are always 0 (zero)
    >>
    >>
    >> Now, the really strange thing is that when he re-installed WinXP from
    >> a CD (fresh install), the code worked just fine, several times
    >> consistently. But when the computer was re-booted (for the first
    >> time), the issue manifested itself again consistently. He is running
    >> Windows XP Pro w/SP1 installed on a FAT32 partition, Novell
    >> environment, the machine is part of a workgroup (not domain), and he
    >> is logged on as the local administrator. Any ideas? Anyone run into
    >> this before? I am somewhat stuck...
    >>
    >> Thanks for any help...
    >> Ali
    >>
    >>


  • Next message: rox.scott: "Authenticode for VBA in MSIE"