Aiman Rashid
August 20th, 2001, 04:15 AM
hello all,
I am using Microsoft Base Cryptographic service provider.
Problem is that, when I run this program it generates the keys properly but when I run it again(and this time trying to get the already made keys) I am unable to get the keys. I get "ERROR_INVALID_PARAMETER" as a result code for CryptGetUserKey().
Coding theme is as follows....
HCRYPTPROV hTp1;
HCRYPTKEY hK1;
//if the key container does not exist, create one.
if(CryptAcquireContext(&hTp1, "con1", MS_DEF_PROV,
PROV_RSA_FULL, CRYPT_NEWKEYSET))
{
/////generating new signature keys
if(CryptGenKey(hTp1, AT_SIGNATURE, 0, &hK1))
{
///any thing
}
else
{ ///getting old keys
if(CryptGetUserKey(hTp1, AT_SIGNATURE, &hK1))
{
///any thing
}
///any thing
}
}
else
{ ////key container already exists, so get keys
if(CryptGetUserKey(hTp1, AT_SIGNATURE, &hK1))
{
///any thing
}
else
{////if keys doesn't exist, generate new key set
if(CryptGenKey(hTp1, AT_SIGNATURE, 0, &hK1))
{
///any thing
}
///any thing
}
}
Please help me,
Thanks in advance
Aiman Rashid.
I am using Microsoft Base Cryptographic service provider.
Problem is that, when I run this program it generates the keys properly but when I run it again(and this time trying to get the already made keys) I am unable to get the keys. I get "ERROR_INVALID_PARAMETER" as a result code for CryptGetUserKey().
Coding theme is as follows....
HCRYPTPROV hTp1;
HCRYPTKEY hK1;
//if the key container does not exist, create one.
if(CryptAcquireContext(&hTp1, "con1", MS_DEF_PROV,
PROV_RSA_FULL, CRYPT_NEWKEYSET))
{
/////generating new signature keys
if(CryptGenKey(hTp1, AT_SIGNATURE, 0, &hK1))
{
///any thing
}
else
{ ///getting old keys
if(CryptGetUserKey(hTp1, AT_SIGNATURE, &hK1))
{
///any thing
}
///any thing
}
}
else
{ ////key container already exists, so get keys
if(CryptGetUserKey(hTp1, AT_SIGNATURE, &hK1))
{
///any thing
}
else
{////if keys doesn't exist, generate new key set
if(CryptGenKey(hTp1, AT_SIGNATURE, 0, &hK1))
{
///any thing
}
///any thing
}
}
Please help me,
Thanks in advance
Aiman Rashid.