Correct crypt context init in CryptProtectData/CryptUnprotectData.

This commit is contained in:
Kees Cook 2005-05-23 09:50:26 +00:00 committed by Alexandre Julliard
parent 54acd10dfe
commit 5eb460953f
1 changed files with 4 additions and 2 deletions

View File

@ -861,7 +861,8 @@ BOOL WINAPI CryptProtectData(DATA_BLOB* pDataIn,
szDataDescr=(WCHAR[]){'\0'};
/* get crypt context */
if (!CryptAcquireContextW(&hProv,NULL,NULL,CRYPT32_PROTECTDATA_PROV,0))
if (!CryptAcquireContextW(&hProv,NULL,NULL,CRYPT32_PROTECTDATA_PROV,0) &&
!CryptAcquireContextW(&hProv,NULL,NULL,CRYPT32_PROTECTDATA_PROV,CRYPT_NEWKEYSET))
{
ERR("CryptAcquireContextW failed\n");
goto finished;
@ -1042,7 +1043,8 @@ BOOL WINAPI CryptUnprotectData(DATA_BLOB* pDataIn,
}
/* get a crypt context */
if (!CryptAcquireContextW(&hProv,NULL,NULL,CRYPT32_PROTECTDATA_PROV,0))
if (!CryptAcquireContextW(&hProv,NULL,NULL,CRYPT32_PROTECTDATA_PROV,0) &&
!CryptAcquireContextW(&hProv,NULL,NULL,CRYPT32_PROTECTDATA_PROV,CRYPT_NEWKEYSET))
{
ERR("CryptAcquireContextW failed\n");
goto free_protect_data;