CryptMsgVerifyCountersignatureEncodedEx function
Applies to: desktop apps only
The CryptMsgVerifyCountersignatureEncodedEx function verifies that the pbSignerInfoCounterSignature parameter contains the encrypted hash of the encryptedDigest field of the pbSignerInfo parameter structure. The signer can be a CERT_PUBLIC_KEY_INFO structure, a certificate context, or a chain context.
Syntax
BOOL WINAPI CryptMsgVerifyCountersignatureEncodedEx( __in_opt HCRYPTPROV_LEGACY hCryptProv, __in DWORD dwEncodingType, __in PBYTE pbSignerInfo, __in DWORD cbSignerInfo, __in PBYTE pbSignerInfoCountersignature, __in DWORD cbSignerInfoCountersignature, __in DWORD dwSignerType, __in void *pvSigner, __reserved DWORD dwFlags, __reserved void *pvExtra );
Parameters
- hCryptProv [in, optional]
-
This parameter is not used and should be set to NULL.
Windows Server 2003, Windows XP, and Windows 2000: NULL or the handle of the cryptographic provider to use to hash the encryptedDigest field of pbSignerInfo.This parameter's data type is HCRYPTPROV.
Unless there is a strong reason for passing in a specific cryptographic provider in hCryptProv, pass NULL to cause the default RSA or DSS provider to be used.
- dwEncodingType [in]
-
The encoding type used. Currently, only X509_ASN_ENCODING and PKCS_7_ASN_ENCODING are being used; however, additional encoding types may be added in the future. For either current encoding type, use: X509_ASN_ENCODING | PKCS_7_ASN_ENCODING.
- pbSignerInfo [in]
-
A pointer to the encoded BLOB that contains the signer of the contents of a message to be countersigned.
- cbSignerInfo [in]
-
The count, in bytes, of the encoded BLOB for the signer of the contents.
- pbSignerInfoCountersignature [in]
-
A pointer to the encoded BLOB containing the countersigner information.
- cbSignerInfoCountersignature [in]
-
The count, in bytes, of the encoded BLOB for the countersigner of the message.
- dwSignerType [in]
-
The structure that contains the signer information. The following table shows the predefined values and the structures indicated.
Value Meaning - CMSG_VERIFY_SIGNER_PUBKEY
pvSigner is a pointer to a CERT_PUBLIC_KEY_INFO structure.
- CMSG_VERIFY_SIGNER_CERT
pvSigner is a pointer to a CERT_CONTEXT structure.
- CMSG_VERIFY_SIGNER_CHAIN
pvSigner is a pointer to a CERT_CHAIN_CONTEXT structure.
- pvSigner [in]
-
A pointer to a CERT_PUBLIC_KEY_INFO structure, a certificate context, or a chain context depending on the value of dwSignerType.
- dwFlags
-
Flags that modify the function behavior. This can be zero or the following value.
Value Meaning - CMSG_VERIFY_COUNTER_SIGN_ENABLE_STRONG_FLAG
- 0x00000001
Performs a strong signature check after successful signature verification. Set the pvExtra parameter to point to a CERT_STRONG_SIGN_PARA structure that contains the parameters needed to check the signature strength..
Windows 8 and Windows Server 8 Beta: Support for this flag begins. - pvExtra
-
If you set the dwFlags parameter to CMSG_VERIFY_COUNTER_SIGN_ENABLE_STRONG_FLAG, set this parameter (pvExtra) to point to a CERT_STRONG_SIGN_PARA structure that contains the parameters used to check the signature strength.
Return value
If the function succeeds, the return value is nonzero (TRUE).
If the function fails, the return value is zero (FALSE). For extended error information, call GetLastError.
The following error codes are most commonly returned by the GetLastError function.
| Return code | Description |
|---|---|
|
The message does not contain an expected authenticated attribute. |
|
The hash value is not correct. |
|
The message is not encoded as expected. |
|
The cryptographic algorithm is unknown. |
|
One or more arguments are not valid. |
|
Ran out of memory. |
Propagated errors from the following functions might be returned.
If the function fails, GetLastError may return an Abstract Syntax Notation One (ASN.1) encoding/decoding error. For information about these errors, see ASN.1 Encoding/Decoding Return Values.
Remarks
Countersigner verification is done using the PKCS #7 SIGNERINFO structure. The signature must contain the encrypted hash of the encryptedDigest field of pbSignerInfo.
The issuer and serial number of the countersigner must match the countersigner information from pbSignerInfoCountersignature. The only fields referenced from pciCountersigner are SerialNumber, Issuer, and SubjectPublicKeyInfo. The SubjectPublicKeyInfo is used to access the public key that is then used to encrypt the hash from the pciCountersigner so compare it with the hash from the pbSignerInfo.
Examples
For an example that uses this function, see Example C Program: Encoding and Decoding a CounterSigned Message.
Requirements
|
Minimum supported client | Windows 2000 Professional |
|---|---|
|
Minimum supported server | Windows 2000 Server |
|
Header |
|
|
Library |
|
|
DLL |
|
See also
- Low-level Message Functions
- Simplified Message Functions
- CryptMsgCountersign
- CryptMsgCountersignEncoded
Send comments about this topic to Microsoft
Build date: 3/6/2012