CryptMsgCountersign function (wincrypt.h)

The CryptMsgCountersign function countersigns an existing signature in a message. Countersignatures are used to sign an existing signature's encrypted hash of the message. Countersignatures can be used for various purposes including time stamping a message.


BOOL CryptMsgCountersign(
  [in, out] HCRYPTMSG                hCryptMsg,
  [in]      DWORD                    dwIndex,
  [in]      DWORD                    cCountersigners,
  [in]      PCMSG_SIGNER_ENCODE_INFO rgCountersigners


[in, out] hCryptMsg

Cryptographic message handle to be used.

[in] dwIndex

Zero-based index of the signer in the signed or signed-and-enveloped message to be countersigned.

[in] cCountersigners

Number of countersigners in the rgCountersigners array.

[in] rgCountersigners

Array of countersigners' CMSG_SIGNER_ENCODE_INFO structures.

Return value

If the function succeeds, the function returns nonzero (TRUE).

If the function fails, it returns zero (FALSE). For extended error information, call GetLastError.

An error can be propagated from CryptMsgCountersignEncoded.

The following error codes are returned most often.

Return code Description
One or more arguments are not valid.
Ran out of memory.
The specified area is not large enough to hold the returned data.

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.


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

See also



Low-level Message Functions

Simplified Message Functions