The CryptVerifyMessageSignature function verifies a signed message's signature.
This function should not be used to verify the signature of a detached message. You should use the CryptVerifyDetachedMessageSignature function to verify the signature of a detached message.
BOOL CryptVerifyMessageSignature( PCRYPT_VERIFY_MESSAGE_PARA pVerifyPara, DWORD dwSignerIndex, const BYTE *pbSignedBlob, DWORD cbSignedBlob, BYTE *pbDecoded, DWORD *pcbDecoded, PCCERT_CONTEXT *ppSignerCert );
A pointer to a CRYPT_VERIFY_MESSAGE_PARA structure that contains verification parameters.
The index of the desired signature. There can be more than one signature. CryptVerifyMessageSignature can be called repeatedly, incrementing dwSignerIndex each time. Set this parameter to zero for the first signer, or if there is only one signer. If the function returns FALSE, and GetLastError returns CRYPT_E_NO_SIGNER, the previous call processed the last signer of the message.
A pointer to a buffer that contains the signed message.
The size, in bytes, of the signed message buffer.
A pointer to a buffer to receive the decoded message.
This parameter can be NULL if the decoded message is not needed for additional processing or to set the size of the message for memory allocation purposes. For more information, see Retrieving Data of Unknown Length.
A pointer to a DWORD value that specifies the size, in bytes, of the pbDecoded buffer. When the function returns, this DWORD contains the size, in bytes, of the decoded message. The decoded message will not be returned if this parameter is NULL.
The address of a CERT_CONTEXT structure pointer that receives the certificate of the signer. When you have finished using this structure, free it by passing this pointer to the CertFreeCertificateContext function. This parameter can be NULL if the signer's certificate is not needed.
If the function succeeds, the function returns nonzero. This does not necessarily mean that the signature was verified. In the case of a detached message, the variable pointed to by pcbDecoded will contain zero. In this case, this function will return nonzero, but the signature is not verified. To verify the signature of a detached message, use the CryptVerifyDetachedMessageSignature function.
If the function fails, it returns zero. For extended error information, call GetLastError.
The following table shows the error codes most commonly returned by the GetLastError function.
||If the buffer specified by the pbDecoded parameter is not large enough to hold the returned data, the function sets the ERROR_MORE_DATA code, and stores the required buffer size, in bytes, in the variable pointed to by pcbDecoded.|
||Invalid message and certificate encoding types. Currently only PKCS_7_ASN_ENCODING and X509_ASN_ENCODING_TYPE are supported. Invalid cbSize in *pVerifyPara.|
||Not a signed cryptographic message.|
||The message does not have any signers or a signer for the specified dwSignerIndex.|
||The message was hashed and signed by using an unknown or unsupported algorithm.|
||The message's signature was not verified.|
For a message that contains only certificates and CRLs, pcbDecoded is set to NULL.
For an example that uses this function, see Example C Program: Signing a Message and Verifying a Message Signature.
|Minimum supported client||Windows XP [desktop apps only]|
|Minimum supported server||Windows Server 2003 [desktop apps only]|