shekar_raja
June 24th, 2008, 10:32 AM
Hi,
I am using CryptprotectData and CryptUnprotectData to store user credentials in the registry. The CryptprotectData & CryptUnprotectData work fine when I pass the OUT datablob from the CryptprotectData to the CryptUnprotectData API immediately.
Things are different when I save the result of the CryptprotectData into a registry and read it later to decrypt it. I think it has something to do with string format (WCHAR to BYTE*) but I seem to be converting it before passing it to the CryptUnprotectData API.
Here is my code -
WRReg.GetUserName(&szData);
DATA_BLOB DataEncrypted;
DataEncrypted.pbData = (BYTE*)(W2A(szData));
DataEncrypted.cbData = 2;
if(!CryptUnprotectData(&DataEncrypted,&pDescrOut,
NULL,NULL,NULL,CRYPTPROTECT_UI_FORBIDDEN,&DataBlob) )
return FALSE;
Any clues???
I am using CryptprotectData and CryptUnprotectData to store user credentials in the registry. The CryptprotectData & CryptUnprotectData work fine when I pass the OUT datablob from the CryptprotectData to the CryptUnprotectData API immediately.
Things are different when I save the result of the CryptprotectData into a registry and read it later to decrypt it. I think it has something to do with string format (WCHAR to BYTE*) but I seem to be converting it before passing it to the CryptUnprotectData API.
Here is my code -
WRReg.GetUserName(&szData);
DATA_BLOB DataEncrypted;
DataEncrypted.pbData = (BYTE*)(W2A(szData));
DataEncrypted.cbData = 2;
if(!CryptUnprotectData(&DataEncrypted,&pDescrOut,
NULL,NULL,NULL,CRYPTPROTECT_UI_FORBIDDEN,&DataBlob) )
return FALSE;
Any clues???