Re: countersiging problems

From: wayne sun[MSFT] (waynesun_at_online.microsoft.com)
Date: 02/25/04


Date: Tue, 24 Feb 2004 18:04:14 -0800

try

if(!(pbDecodedMessageBlob = (BYTE *)malloc(cbDecodedMessageBlob)))

-- 
This posting is provided "AS IS" with no warranties, and confers no rights.
"vivek" <anonymous@discussions.microsoft.com> wrote in message 
news:CD46DA74-8A36-44AD-83AE-B0197DBF33BD@microsoft.com...
> hi,
> I am trying to countersign a message. I first sign it (this signing is 
> done in a seperate function).Then for countersigning, i decode the 
> data(which is sucessfull) and then i check the signature of the signer and 
> initlialize the verifyparams data structure. The function fails at 
> CryptVerifyMessageSignature() with error code  "c0000005"
> i have the encoded contents of the first signer in pbEncodedBlob.
>
> VerifyParams.cbSize = sizeof(CRYPT_VERIFY_MESSAGE_PARA);
> VerifyParams.dwMsgAndCertEncodingType = MY_ENCODING_TYPE;
> VerifyParams.hCryptProv = 0;
> VerifyParams.pfnGetSignerCertificate = NULL;
> VerifyParams.pvGetArg = NULL;
>
> if(!(CryptVerifyMessageSignature(&VerifyParams,0,pbEncodedBlob,cbEncodedBlob,
>     NULL,&cbDecodedMessageBlob,NULL))){
> wsprintf(msg,"Getting the size of the verification message failed.\n");
> OutputDebugString (msg);
>     free(msg);
> }
>
> wsprintf(msg,"!!!!Length of encoded blob %d !!!!\n",cbEncodedBlob);
> OutputDebugString (msg);
> free(msg);
>
> if(!(pbDecodedMessageBlob = (BYTE *)(cbDecodedMessageBlob))){
> wsprintf(msg,"Memory allocation failed.\n");
> OutputDebugString (msg);
>     free(msg);
> }
>
> if(CryptVerifyMessageSignature(&VerifyParams,0,pbEncodedBlob,cbEncodedBlob,pbDecodedMessageBlob,
>        &cbDecodedMessageBlob,NULL)){
> wsprintf(msg,"Message verified for counter signing\n");
> OutputDebugString (msg);
>     free(msg);
> }
> else{
> wsprintf(msg,"Verification message failed for countersigning. 
> %x\n",GetLastError());
> OutputDebugString (msg);
>     free(msg);
> }