关于CryptoApi的调用问题,急,在线等待
微软msdn有这样一段demo代码,演示hash签名。
hcryptprov hprov;
byte *pbbuffer= (byte *)"the data that is to be hashed and signed.";
dword dwbufferlen = strlen((char *)pbbuffer)+1;
hcrypthash hhash;
hcryptkey hkey;
hcryptkey hpubkey;
byte *pbkeyblob;
byte *pbsignature;
dword dwsiglen;
dword dwbloblen;
lptstr szdescription = "test data description";
//--------------------------------------------------------------------
// acquire a csp.
if(cryptacquirecontext(
&hprov,
null,
null,
prov_rsa_full,
0))
{
printf("csp context acquired.\n");
}
else
{
handleerror("error during cryptacquirecontext.");
}
//--------------------------------------------------------------------
// get the public at signature key. this is the public key
// that will be used by the receiver of the hash to verify
// the signature. in situations where the receiver could obtain the
// senders public key from a certificate, this step would not be
// needed.
if(cryptgetuserkey(
hprov,
at_signature,
&hkey))
{
printf("the signature key has been acquired. \n");
}
else
{
handleerror("error during cryptgetuserkey for signkey.");
}
=====================================================
我在使用时,调用cryptgetuserkey函数总是错误,错误代码是nte_no_key,大意是说at_signature参数所要求的key不存在,不知如何解决,请有经验的兄弟指点
推荐阅读


讨论区