B
bensonmp
Hi,
My application fails after making a call to the Windows
CryptAcquireContext API. I get the following error code
NTE_BAD_KEY_STATE ( 0x8009000BL ).
Code snippet and details below:
////////////////////////////////////////////////////////////////////////////////
/* @func UINT32 | get_key |
* Description: Get encryption key. In order to do this need to
* acquire encryption context and hashing object.
*
*---------------------------------------------------------------------
*/
////////////////////////////////////////////////////////////////////////////////
UINT32 get_key(TCHAR * szPassword, HCRYPTPROV * phProv,
HCRYPTHASH * phHash, HCRYPTKEY * phKey)
{
...
...
// Get handle to user default provider.
rc = CryptAcquireContext(phProv, NULL, MS_DEF_PROV,
PROV_RSA_FULL, 0);
if(!rc)
{
lRet = GetLastError();
if (lRet == NTE_BAD_KEYSET)
{
// create default key container
if (!CryptAcquireContext(phProv, NULL, MS_DEF_PROV,
PROV_RSA_FULL,
CRYPT_NEWKEYSET))
{
lRet = GetLastError();
}
}
}
...
...
}
The first call to CryptAcquireContext() here fails with
NTE_BAD_KEY_STATE, and there isn't sufficient information available on
MSDN bout the error code. All I got was that the error returned from
the failing API suggests that the user password has changed since the
private keys were encrypted. But there weren't any sort of user
modifications done recently on my machine.
The issue occurs on a Win2K3 HP server. But it seems to be happening
only on one of my servers and works fine on others.
Any ideas as to what might be going wrong here? I know that re-
installing the OS here would fix this (cause it happened on another
machine in the past and the only way out that time was re-installing
the OS). But re-installing the OS here would mean a lot of work to be
re-done at this point for me. Has anyone encountered such a problem in
the past, if so, how was it resolved?
Thanks in advance!
- Benson
My application fails after making a call to the Windows
CryptAcquireContext API. I get the following error code
NTE_BAD_KEY_STATE ( 0x8009000BL ).
Code snippet and details below:
////////////////////////////////////////////////////////////////////////////////
/* @func UINT32 | get_key |
* Description: Get encryption key. In order to do this need to
* acquire encryption context and hashing object.
*
*---------------------------------------------------------------------
*/
////////////////////////////////////////////////////////////////////////////////
UINT32 get_key(TCHAR * szPassword, HCRYPTPROV * phProv,
HCRYPTHASH * phHash, HCRYPTKEY * phKey)
{
...
...
// Get handle to user default provider.
rc = CryptAcquireContext(phProv, NULL, MS_DEF_PROV,
PROV_RSA_FULL, 0);
if(!rc)
{
lRet = GetLastError();
if (lRet == NTE_BAD_KEYSET)
{
// create default key container
if (!CryptAcquireContext(phProv, NULL, MS_DEF_PROV,
PROV_RSA_FULL,
CRYPT_NEWKEYSET))
{
lRet = GetLastError();
}
}
}
...
...
}
The first call to CryptAcquireContext() here fails with
NTE_BAD_KEY_STATE, and there isn't sufficient information available on
MSDN bout the error code. All I got was that the error returned from
the failing API suggests that the user password has changed since the
private keys were encrypted. But there weren't any sort of user
modifications done recently on my machine.
The issue occurs on a Win2K3 HP server. But it seems to be happening
only on one of my servers and works fine on others.
Any ideas as to what might be going wrong here? I know that re-
installing the OS here would fix this (cause it happened on another
machine in the past and the only way out that time was re-installing
the OS). But re-installing the OS here would mean a lot of work to be
re-done at this point for me. Has anyone encountered such a problem in
the past, if so, how was it resolved?
Thanks in advance!
- Benson