locked
CryptDeriveKey fails with errorcode -2146893819 in Win XP, .NET 3.5 SP1 RRS feed

  • Question

  • My problem is on Windows XP professional SP 3, installed with .NET 3.5 SP1

    I have the following in my DLL created in VC++ express edition (the DLL code is plain c code, nothing to do with MFC etc). this DLL exposes some functions which I call from c# code (in .NET 3.5, SP1)
    These exposed functions of the DLL when called, access the code given below in the given order.
    And it fails on the last CryptoAPI call to CryptDeriveKey with error code -2146893819
    Can someone please point me in the right direction.

    you can email me too at:  jas at aparcsystems dot com

    thanks




    CryptAcquireContext(
     hCryptProv,
     NULL,
     NULL, 
     PROV_RSA_AES,  // I have tried here PROV_RSA_FULL also
      0)


    CryptCreateHash(
           *hCryptProv,
           CALG_MD5, // I have tried CALG_SHA1 here also
           0,
           0,
           hHash)


    CryptHashData(
           *hHash,
           password,  // password string is 32 characters long
           strlen((char *)password),
           0)


    //  KEYLENGTH is defined as 0x01000000

     


    if(! CryptDeriveKey(
         *hCryptProv,
         CALG_AES_256,
         *hHash,
         KEYLENGTH|CRYPT_NO_SALT,
         hKey))
    {
                 GetLastError() // this returns error NTE_BAD_DATA (-2146893819)
    }

     

     

    Thursday, December 10, 2009 9:39 PM