|
证书的数字签名和认证(3) verify sign */ DWORD cbDecodeMessageBlob; BYTE* pbDecodeMessageBlob; CRYPT_VERIFY_MESSAGE_PARA verifyParams; verifyParams.cbSize = sizeof(CRYPT_VERIFY_MESSAGE_PARA); verifyParams.dwMsgAndCertEncodingType = MY_TYPE; verifyParams.hCryptProv = 0; verifyParams.pfnGetSignerCertificate = NULL; verifyParams.pvGetArg = NULL; if(CryptVerifyMessageSignature(&verifyParams,0,pbSignedMessageBlob,cbSignedMessageBlob,NULL,&cbDecodeMessageBlob,NULL)) { printf("total buffer%d\n",cbDecodeMessageBlob); } if(!(pbDecodeMessageBlob = (BYTE*)malloc(cbDecodeMessageBlob))) { printf("alloc failed!\n"); } if(CryptVerifyMessageSignature(&verifyParams,0,pbSignedMessageBlob,cbSignedMessageBlob,pbDecodeMessageBlob,&cbDecodeMessageBlob,NULL)) { printf("verify message:\n%s\n",(char*)pbDecodeMessageBlob); } /* some release operation........ */ if(pbSignedMessageBlob) free(pbSignedMessageBlob); if(pbDecodeMessageBlob) free(pbDecodeMessageBlob); if(pSignerCert) CertFreeCertificateContext(pSignerCert); if(CertCloseStore(hStoreHandle,CERT_CLOSE_STORE_CHECK_FLAG)) { printf("all release...\n"); } else { printf("......."); } return 0; }
|