CryptMsgCountersignEncoded function (wincrypt.h)
The CryptMsgCountersignEncoded function countersigns an existing PKCS #7 message signature. The pbCountersignature BYTE buffer it creates is a PKCS #7 encoded SignerInfo that can be used as an unauthenticated Countersignature attribute of a PKCS #9 signed-data or signed-and-enveloped-data message.
Syntax
BOOL CryptMsgCountersignEncoded(
[in] DWORD dwEncodingType,
[in] PBYTE pbSignerInfo,
[in] DWORD cbSignerInfo,
[in] DWORD cCountersigners,
[in] PCMSG_SIGNER_ENCODE_INFO rgCountersigners,
[out] PBYTE pbCountersignature,
[in, out] PDWORD pcbCountersignature
);
Parameters
[in] dwEncodingType
Specifies 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.
[in] pbSignerInfo
A pointer to the encoded SignerInfo that is to be countersigned.
[in] cbSignerInfo
Count, in bytes, of the encoded SignerInfo data.
[in] cCountersigners
Number of countersigners in the rgCountersigners array.
[in] rgCountersigners
Array of countersigners' CMSG_SIGNER_ENCODE_INFO structures.
[out] pbCountersignature
A pointer to a buffer to receive an encoded PKCS #9 countersignature attribute.
On input, this parameter can be NULL to set the size of this information for memory allocation purposes. For more information, see Retrieving Data of Unknown Length.
[in, out] pcbCountersignature
A pointer to a variable that specifies the size, in bytes, of the buffer pointed to by the pbCountersignature parameter. When the function returns, the variable pointed to by the pcbCountersignature parameter contains the number of bytes stored in the buffer.
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 table lists the error codes most commonly returned by the GetLastError function.
Return code | Description |
---|---|
|
The object identifier is badly formatted. |
|
One or more arguments are not valid. |
|
Ran out of memory. |
Propagated errors might be returned from one of the following functions:
- CryptCreateHash
- CryptHashData
- CryptGetHashParam
- CryptSignHash
- CryptMsgOpenToEncode
- CryptMsgUpdate
- CryptMsgControl
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows XP [desktop apps | UWP apps] |
Minimum supported server | Windows Server 2003 [desktop apps | UWP apps] |
Target Platform | Windows |
Header | wincrypt.h |
Library | Crypt32.lib |
DLL | Crypt32.dll |