CryptoAPI question
-
I used CryptAcquireContext with MS_ENHANCED_PROV and then created an RC4 key. I want to export this key without any encryption. I tried using PLAINTEXTBLOB on CryptExportKey. It works fine on XP, but fails on 2000 (with Enhanced Provider installed) with error NTE_BADKEY. m_sessionkey is valid at that point. I can export it using my public key. The line of code:
if (!CryptExportKey(m_sessionkey, 0, PLAINTEXTKEYBLOB, 0, NULL, &length)) { DWORD dwErr = GetLastError(); LogError(dwErr); return false; } std::vector<BYTE > keydata; keydata.resize(length); if (!CryptExportKey(m_sessionkey, 0, PLAINTEXTKEYBLOB, 0, &keydata[0], &length)) { DWORD dwErr = GetLastError(); LogError(dwErr); return false; }
My article on a reference-counted smart pointer that supports polymorphic objects and raw pointers -
I used CryptAcquireContext with MS_ENHANCED_PROV and then created an RC4 key. I want to export this key without any encryption. I tried using PLAINTEXTBLOB on CryptExportKey. It works fine on XP, but fails on 2000 (with Enhanced Provider installed) with error NTE_BADKEY. m_sessionkey is valid at that point. I can export it using my public key. The line of code:
if (!CryptExportKey(m_sessionkey, 0, PLAINTEXTKEYBLOB, 0, NULL, &length)) { DWORD dwErr = GetLastError(); LogError(dwErr); return false; } std::vector<BYTE > keydata; keydata.resize(length); if (!CryptExportKey(m_sessionkey, 0, PLAINTEXTKEYBLOB, 0, &keydata[0], &length)) { DWORD dwErr = GetLastError(); LogError(dwErr); return false; }
My article on a reference-counted smart pointer that supports polymorphic objects and raw pointers -
not being an expert with microsoft's cryptoapi I would check if the key is generated with Exportable flag. Might be also the Q228786 will be usefull for you. Don't have any more clue with great microsoft's CryptoAPI X|
Thank you. But the issue is the same executable works on XP, and not on 2000. The docs does not mention any XP dependency. ... and ofcourse, the key is exportable. Thomas My article on a reference-counted smart pointer that supports polymorphic objects and raw pointers
-
Thank you. But the issue is the same executable works on XP, and not on 2000. The docs does not mention any XP dependency. ... and ofcourse, the key is exportable. Thomas My article on a reference-counted smart pointer that supports polymorphic objects and raw pointers
-
I used CryptAcquireContext with MS_ENHANCED_PROV and then created an RC4 key. I want to export this key without any encryption. I tried using PLAINTEXTBLOB on CryptExportKey. It works fine on XP, but fails on 2000 (with Enhanced Provider installed) with error NTE_BADKEY. m_sessionkey is valid at that point. I can export it using my public key. The line of code:
if (!CryptExportKey(m_sessionkey, 0, PLAINTEXTKEYBLOB, 0, NULL, &length)) { DWORD dwErr = GetLastError(); LogError(dwErr); return false; } std::vector<BYTE > keydata; keydata.resize(length); if (!CryptExportKey(m_sessionkey, 0, PLAINTEXTKEYBLOB, 0, &keydata[0], &length)) { DWORD dwErr = GetLastError(); LogError(dwErr); return false; }
My article on a reference-counted smart pointer that supports polymorphic objects and raw pointersIf you want the key value try this article: http://www.codeproject.com/cpp/plaintextsessionkey.asp Raphael Amorim Dantas Leite VC++, VB, Java, .NET and eMbedded Programmer
-
If you want the key value try this article: http://www.codeproject.com/cpp/plaintextsessionkey.asp Raphael Amorim Dantas Leite VC++, VB, Java, .NET and eMbedded Programmer