I am using Microsoft Cryptography API. It is working fine on Windows 2008 server. We have a new machine - windows 2012 server R2. My code (C++) does not work on this machine.
Here is the code sample
This call works
CryptAcquireContext(&hProv, NULL, MS_DEF_PROV, PROV_RSA_FULL, 0)
but then this call fails
CryptImportKey(hProv, pbBlob, cbBlob, 0, 0, &_hSessionKey)
- pbBlob is memory pointer and contains a buffer read from a key file
The error is (ox57) - bad parameter
If I call instead
CryptImportKey(hProv, PrivateKeyWithExponentOfOne, sizeof(PrivateKeyWithExponentOfOne), 0, 0, &_hSessionKey)
Then it works but then
CryptDecrypt(_hSessionKey, 0, TRUE, 0, cipherBlock, &length)
does not decrypt the message. It does not error but does nothing.
Like I said it all works fine on windows 2008 server but not on Windows 2012 server. What do I need to change?