Re: CryptAcquireContext Fails in Windows 98

From: Agnihotri (anonymous_at_discussions.microsoft.com)
Date: 05/28/04


Date: Thu, 27 May 2004 22:16:03 -0700

Hi,
Thanks a lot for the help now it is working but other function of the CryptoAPI fails.
The failing function is "CryptDeriveKey"
if have used this function in the following way:
if(!CryptAcquireContext(&hCryptProv,NULL, MS_DEF_PROV , PROV_RSA_FULL, CRYPT_NEWKEYSET))
{
         if(!CryptAcquireContext(&hCryptProv, NULL, MS_DEF_PROV, PROV_RSA_FULL,CRYPT_NEWKEYSET|CRYPT_MACHINE_KEYSET))
        {
              return E_FAIL;
        }
}
if(!CryptCreateHash(hCryptProv, CALG_MD5, 0, 0, &hHash))
{
      return E_FAIL;
}
if(!CryptHashData(hHash, (BYTE *)szPassword, strlen(szPassword), 0))
{
     return E_FAIL;
}
if(!CryptDeriveKey(hCryptProv, ENCRYPT_ALGORITHM, hHash, KEYLENGTH, &hKey))
{
     return E_FAIL;
}

i tried to use GetLastError but it returned 0.

Please help me out.
Thank You