"Param" <Pa...@discussions.microsoft.com> wrote in message news:1A6A06B0-0021-440A...@microsoft.com...
1)hMsg = CryptMsgOpenToDecode(MY_ENCODING_TYPE,0,0,0,NULL,NULL);
2)if(!(CryptMsgUpdate(hMsg,pbData,cbData,TRUE)))
{
}
3)if(!(CryptMsgGetParam(hMsg,CMSG_HASH_DATA_PARAM,0,NULL,&cbHash)))
{
}
4)if(!(CryptMsgGetParam(hMsg,CMSG_HASH_DATA_PARAM,0,pbHash,&cbHash)))
{
}
in step 3 i am getting CRYPT_E_INVALID_MSG_TYPE error.
but this message is pkcs7 signed message and also i am able to verify the
signature using other tools.Is there any wrong in this?
thanx
in the above i am getting dwMsgType as CMSG_SIGNED for the same message.
thanx
"Param" <Pa...@discussions.microsoft.com> wrote in message news:FB8A92CD-A333-465A...@microsoft.com...
And, that only seems to return the SHA1 hash value for the following cases:
(1) a pkcs7 signature with the content INCLUDED (i.e. a non-null data sequence following
that SHA1 sequence.
(2) a detached signature WITH authenticated attributes, where the hash returned is that of
all the authenticated attributes (binary DER sequences).
I don't know exactly what the CMSG_HASH_DATA_PARAM is supposed to return, but
it for the cases that i tested, it always returns a byte buffer of zero size!
- Mitch Gallant
"Param" <Pa...@discussions.microsoft.com> wrote in message news:FB8A92CD-A333-465A...@microsoft.com...
(1) Get the pkcs#1 "signature" (encrypted hash) from your PKCS#7 signed message using:
CryptMsgGetParam(hMsg, CMSG_ENCRYPTED_DIGEST ..... This returns encrypted hash
in big-endian order.
(2) Next, use the lower level signature verification function CryptVerifySignature(...) which
uses these pkcs#1 signatures (not CMS/pkcs#7). This uses little-endian ordered pkcs1
signature blob, so reverse the bytes from (1). You need to compute the hash (which
you can do via streaming, for any size file) and get the publickey handle, no problem, for this function.
CryptVerifySignature(...) compares recomputed hash with the hash in the pkcs#1 signature,
and returns the validity status of the signature.
Combine your CryptMsgGetParam(..) code with the CryptVerifySignature code here:
There should be no file-size limitations in this mixed approach to verifying
a given detached pkcs#7 signature, with data of any size, using CryptoAPI.
- Mitch Gallant
"Michel Gallant" <neu...@istar.ca> wrote in message news:%23feeNLn...@tk2msftngp13.phx.gbl...